Skip to content
Snippets Groups Projects
Commit cc12f4c5 authored by Shon Ferguson's avatar Shon Ferguson
Browse files

Gave Type it's own files and finished implementing member functions.

parent 7fcaa845
No related branches found
No related tags found
No related merge requests found
......@@ -794,6 +794,9 @@
<File
RelativePath=".\obj\TriBasedGeomData.cpp">
</File>
<File
RelativePath=".\obj\Type.cpp">
</File>
</Filter>
</Filter>
<Filter
......@@ -1457,6 +1460,9 @@
<File
RelativePath=".\obj\TriBasedGeomData.h">
</File>
<File
RelativePath=".\obj\Type.h">
</File>
</Filter>
</Filter>
<Filter
......
......@@ -9,30 +9,6 @@ const Type NiObject::TYPE("NiObject", NULL );
//Static to track total number of objects in memory. Initialize to zero.
unsigned int NiObject::objectsInMemory = 0;
/*
* Type Methods
*/
bool Type::IsSameType( const Type & compare_to ) const {
return &compare_to == this;
}
bool Type::IsDerivedType( const Type & compare_to ) const {
const Type * search = this;
while ( search != NULL ) {
if ( search == &compare_to ) {
return true;
}
search = search->base_type;
}
return false;
}
/*
* NiObject Methods
*/
bool NiObject::IsSameType( const Type & compare_to) const {
return GetType().IsSameType( compare_to );
}
......
......@@ -14,27 +14,12 @@ All rights reserved. Please see niflib.h for licence. */
#include <vector>
#include "NIF_IO.h"
#include "Ref.h"
#include "Type.h"
#include "xml_extract.h"
using namespace std;
/**
* Run Time Type Inforamtion Class
*/
class Type {
public:
Type (const string & type_name, const Type * base_type );
~Type();
string GetTypeName() const;
bool IsSameType ( const Type & compare_to ) const;
bool IsDerivedType ( const Type & compare_to ) const;
bool operator<( const Type & compare_to ) const { return (this < &compare_to); }
private:
string name;
const Type * base_type;
};
/**
* NiObject - Base Object class from which all other objects derive
......
/* Copyright (c) 2006, NIF File Format Library and Tools
All rights reserved. Please see niflib.h for licence. */
#include "Type.h"
Type::Type (const string & type_name, const Type * par_type ) : name(type_name), base_type(par_type) {}
Type::~Type() {}
bool Type::operator<( const Type & compare_to ) const {
return (this < &compare_to);
}
bool Type::IsSameType( const Type & compare_to ) const {
return &compare_to == this;
}
bool Type::IsDerivedType( const Type & compare_to ) const {
const Type * search = this;
while ( search != NULL ) {
if ( search == &compare_to ) {
return true;
}
search = search->base_type;
}
return false;
}
\ No newline at end of file
/* Copyright (c) 2006, NIF File Format Library and Tools
All rights reserved. Please see niflib.h for licence. */
#ifndef _TYPE_H_
#define _TYPE_H_
#include <string>
using namespace std;
/**
* Run Time Type Inforamtion Class
*/
class Type {
public:
Type (const string & type_name, const Type * par_type );
~Type();
string GetTypeName() const;
bool IsSameType ( const Type & compare_to ) const;
bool IsDerivedType ( const Type & compare_to ) const;
bool operator<( const Type & compare_to ) const;
private:
string name;
const Type * base_type;
};
#endif
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment