CClass.hpp

Go to the documentation of this file.
00001 #ifndef __CClass__
00002 #define __CClass__
00003 
00009 //  ===========================================================================
00010 
00011 #include "StdDefines.h"
00012 #include "StdIncludes.h"
00013 #include "CClassManager.hpp"
00014 
00015 using Exponent::Basics::CClassManager;
00016 
00017 //  ===========================================================================
00018 
00019 namespace Exponent
00020 {
00021     namespace Basics
00022     {
00096         class CClass
00097         {
00098         public:
00099 
00100 //  ===========================================================================
00101 
00102             const static long CCLASS_MAX_CLASSNAME_LENGTH = 128;                
00104 //  ===========================================================================
00105 
00110             CClass(const char *className);
00111 
00117             CClass(const char *className, const char *parentName);
00118 
00124             CClass(const char *templateName, const std::type_info &theType);
00125 
00132             CClass(const char *templateName, const std::type_info &theType, const char *parentName);
00133 
00141             CClass(const char *templateName, const std::type_info &theType, const char *parentName, const std::type_info &parentType);
00142 
00146             CClass();
00147 
00152             CClass(const CClass &theClass);
00153 
00157             virtual ~CClass();
00158 
00159 //  ===========================================================================
00160 
00169             static int compareClasses(const CClass **class1, const CClass **class2);
00170 
00171 //  ===========================================================================
00172 
00178             CClass &operator = (const CClass &other);
00179 
00185             bool operator == (const CClass &other) const;
00186 
00192             void operator ++ (int /* Undefined */);
00193 
00199             void operator -- (int /* Undefined */);
00200 
00201 //  ===========================================================================
00202 
00207             void setClassInformation(const char *className);
00208 
00213             const char *getClassName() const { return m_className; }
00214 
00215 //  ===========================================================================
00216 
00225             bool isTypeOf(const char *className) const;
00226 
00251             bool isTypeOf(const CClass &other) const;
00252 
00276             bool isSubClassOf(const CClass &other) const;
00277 
00282             long getCurrentInstanceCount() const { return m_instanceCount; }
00283 
00288             long getTotalNumberOfClassConstructions() const { return m_maxInstanceCount; }
00289 
00294             static CClassManager *getClassManager() { return CCLASSCLASS_MANAGER; }
00295 
00300             static void deleteClassManager(const char *filePath);
00301 
00302 //  ===========================================================================
00303 
00304         protected:
00305 
00306 //  ===========================================================================
00307 
00318             static bool computeTemplateName(const char *templateName, const std::type_info &theType, char *theBuffer, const long bufferSize);
00319 
00320 //  ===========================================================================
00321 
00322             static CClassManager *CCLASSCLASS_MANAGER;          
00324 //  ===========================================================================
00325 
00326             char m_className[CCLASS_MAX_CLASSNAME_LENGTH];      
00327             char m_parentName[CCLASS_MAX_CLASSNAME_LENGTH];     
00328             long m_instanceCount;                               
00329             long m_maxInstanceCount;                            
00330         };
00331     }
00332 }
00333 
00339 #define EXPONENT_CLASS_DECLARATION\
00340     public:\
00341         virtual const CClass &getObjectClass() const { return CCLASS_THE_CLASS; }\
00342         static const CClass &getClass() { return CCLASS_THE_CLASS; }\
00343     private:\
00344         static CClass CCLASS_THE_CLASS;
00345 
00350 #define EXPONENT_CLASS_IMPLEMENTATION_NO_PARENT(theClassName)\
00351     CClass theClassName::CCLASS_THE_CLASS(#theClassName);
00352 
00358 #define EXPONENT_CLASS_IMPLEMENTATION(theClassName, theParentName)\
00359     CClass theClassName::CCLASS_THE_CLASS(#theClassName, #theParentName);
00360 
00365 #define EXPONENT_TEMPLATE_CLASS_IMPLEMENTATION_NO_PARENT(theClassName, TypeName)\
00366     template<class TypeName> CClass theClassName::CCLASS_THE_CLASS(#theClassName, typeid(TypeName));
00367 
00372 #define EXPONENT_TEMPLATE_CLASS_IMPLEMENTATION(theClassName, TypeName, theParentName)\
00373     template<class TypeName> CClass theClassName::CCLASS_THE_CLASS(#theClassName, typeid(TypeName), #theParentName);
00374 
00379 #define EXPONENT_TEMPLATE_CLASS_IMPLEMENTATION_TEMPLATE_PARENT(theClassName, TypeName, theParentName, ParentTypeName)\
00380     template<class TypeName> CClass theClassName::CCLASS_THE_CLASS(#theClassName, typeid(TypeName), #theParentName, typeid(ParentTypeName));
00381 
00386 #define EXPONENT_CLASS_CONSTRUCTION(theClassName)\
00387     theClassName::CCLASS_THE_CLASS++;
00388 
00393 #define EXPONENT_CLASS_DESTRUCTION(theClassName)\
00394     theClassName::CCLASS_THE_CLASS--;
00395 
00396 #endif // End of CClass.hpp

Infinity API - CClass.hpp Source File generated on 7 Mar 2007