Exponent::Basics::CClass Class Reference
List of all members.
Detailed Description
Class representation class.
CClass stores information about a class. Every object in the exponent
API that is dynamically available (ie - non static classes, and classes
without entirely static functions should have a CClass
Currently CClass only stores the name of the class, this will change in future
versions of the API.
Macros are setup so that you can easily implement the correct style of class handling
When you write a class, simply perform the following steps:
-
Include the macro EXPONENT_CLASS_DECLARATION BEFORE the openeing public statement. Ie it should be the first thing in your classes opening bracket
-
In the class cpp file place the macro EXPONENT_CLASS_IMPLEMENTATION at the top of the file
-
In the case of a template class use the macro EXPONENT_TEMPLATE_CLASS_IMPLEMENTATION instead
-
Inside the constructor place the macro EXPONENT_CLASS_CONSTRUCTION (This ensure that the correct class count is maintained)
-
Inside the destructor place the macro EXPONENT_CLASS_DESTRUCTION (This ensure that the correct class count is maintained)
Code is better than a thousand bullet points ;)
Header (myClass.hpp)
Implementation (myClass.cpp)
- See also:
- CClassManager
EXPONENT_CLASS_DECLARATION
EXPONENT_CLASS_IMPLEMENTATION
EXPONENT_CLASS_CONSTRUCTION
EXPONENT_CLASS_DESTRUCTION
EXPONENT_TEMPLATE_CLASS_IMPLEMENTATION
- Date:
- 28/02/2005
- Author:
- Paul Chana
- Version:
- 1.0.0 Initial version
1.1.0 Converted to split class/header files to ensure proper handling in other classes
- Note:
- All contents of this source code are copyright 2005 Exp Digital Uk.
This source file is covered by the licence conditions of the Infinity API. You should have recieved a copy
with the source code. If you didnt, please refer to http://www.expdigital.co.uk All content is the Intellectual property of Exp Digital Uk.
Certain sections of this code may come from other sources. They are credited where applicable.
If you have comments, suggestions or bug reports please visit http://support.expdigital.co.uk
- Id
- CClass.hpp,v 1.10 2007/02/08 21:06:44 paul Exp
Definition at line 96 of file CClass.hpp.
Public Member Functions
Static Public Member Functions
Static Public Attributes
Static Protected Member Functions
- static bool computeTemplateName (const char *templateName, const std::type_info &theType, char *theBuffer, const long bufferSize)
Protected Attributes
Static Protected Attributes
Constructor & Destructor Documentation
Exponent::Basics::CClass::CClass |
( |
const char * |
className |
) |
|
Construction with the name of the class
- Parameters:
-
| className | The name of the class |
Exponent::Basics::CClass::CClass |
( |
const char * |
className, |
|
|
const char * |
parentName | |
|
) |
| | |
Construction with the name of the class and its parent
- Parameters:
-
| className | The name of the class |
| parentName | The name of the parent |
Exponent::Basics::CClass::CClass |
( |
const char * |
templateName, |
|
|
const std::type_info & |
theType | |
|
) |
| | |
Construction for use with templates when the parent is nothing
- Parameters:
-
| templateName | The name of the template (of the form Name<TypeName>) |
| theType | The type of the type (whatever it is) |
Exponent::Basics::CClass::CClass |
( |
const char * |
templateName, |
|
|
const std::type_info & |
theType, |
|
|
const char * |
parentName | |
|
) |
| | |
Construction for use with templates when the parent is a counted object type
- Parameters:
-
| templateName | The name of the template (of the form Name<TypeName>) |
| theType | The type of the type (whatever it is) |
| parentName | The name of the parent |
Exponent::Basics::CClass::CClass |
( |
const char * |
templateName, |
|
|
const std::type_info & |
theType, |
|
|
const char * |
parentName, |
|
|
const std::type_info & |
parentType | |
|
) |
| | |
Construction for use with templates when the parent is a template
- Parameters:
-
| templateName | The name of the template (of the form Name<TypeName>) |
| theType | The type of the type (whatever it is) |
| parentName | The name of the parent |
| parentType | The type of the type (whatever it is) |
Exponent::Basics::CClass::CClass |
( |
|
) |
|
Exponent::Basics::CClass::CClass |
( |
const CClass & |
theClass |
) |
|
Copy construction
- Parameters:
-
| theClass | The class to copy |
virtual Exponent::Basics::CClass::~CClass |
( |
|
) |
[virtual] |
Member Function Documentation
static int Exponent::Basics::CClass::compareClasses |
( |
const CClass ** |
class1, |
|
|
const CClass ** |
class2 | |
|
) |
| | [static] |
Comparison for a qsort
- Parameters:
-
| class1 | The first class |
| class2 | The second class |
- Return values:
-
| <0 | class1 goes before class2 0 class1 == class2 >0 class1 goes after class2 |
- See also:
- CClassManager::classCompareFunction
TPointerCollection::qsortCompare
static bool Exponent::Basics::CClass::computeTemplateName |
( |
const char * |
templateName, |
|
|
const std::type_info & |
theType, |
|
|
char * |
theBuffer, |
|
|
const long |
bufferSize | |
|
) |
| | [static, protected] |
Compute a template typename combination
- Return values:
-
| CClass | The class that is constructed |
- Parameters:
-
| templateName | The name of the template (of the form Name<TypeName>) |
| theType | The type of the type (whatever it is) |
| theBuffer | The buffer to write to |
| bufferSize | The size of the buffer |
- Note:
- NOT INTENDED FOR PUBLIC USE. THIS IS AN INTERNAL FUNCTION THAT IS REQUIRED TO BE PUBLIC BY ITS NATURE. YOU ARE NOT EXPECTED TO DIRECTLY CALL THIS
UNLESS YOU ABSOLUTELY TOTALLY KNOW WHAT YOU ARE DOING
static void Exponent::Basics::CClass::deleteClassManager |
( |
const char * |
filePath |
) |
[static] |
Delete the class manager
- Parameters:
-
| filePath | The path to write out the class information |
static CClassManager* Exponent::Basics::CClass::getClassManager |
( |
|
) |
[inline, static] |
const char* Exponent::Basics::CClass::getClassName |
( |
|
) |
const [inline] |
Get the name of the class
- Return values:
-
| const | char* The class name |
Definition at line 213 of file CClass.hpp.
References m_className.
long Exponent::Basics::CClass::getCurrentInstanceCount |
( |
|
) |
const [inline] |
Get the current instance count
- Return values:
-
| long | The number of instances of this class that were created and not destroyed (ie still alive) |
Definition at line 282 of file CClass.hpp.
References m_instanceCount.
long Exponent::Basics::CClass::getTotalNumberOfClassConstructions |
( |
|
) |
const [inline] |
Get total number of this class constructed thus far
- Return values:
-
| long | The total number of classes created thus far |
Definition at line 288 of file CClass.hpp.
References m_maxInstanceCount.
bool Exponent::Basics::CClass::isSubClassOf |
( |
const CClass & |
other |
) |
const |
Check if this class is a sub class of another class
- Note:
- This is purely a run time type information. Do not rely on this information to be cross platform available or even
the same within different instanciations of the program. Inside the program you can rely on this information, however, dont assume that the name of the object
in the code (for example CString) will be the same as the name in the class info. They may be different!
class a { };
class b : public a { }
b *myObject = new b;
if (myObject->getObjectClass().isSubClassOf(a::getClass()))
{
cout << "It is a sub type" << endl;
}
else
{
cout << "It is not a sub type" << endl;
}
- Parameters:
-
| other | The class of the type that you want to check that this is |
- Return values:
-
| bool | True if class passed is a parent type of this |
bool Exponent::Basics::CClass::isTypeOf |
( |
const CClass & |
other |
) |
const |
Check if this class is of a specific type
- Note:
- This is purely a run time type information. Do not rely on this information to be cross platform available or even
the same within different instanciations of the program. Inside the program you can rely on this information, however, dont assume that the name of the object
in the code (for example CString) will be the same as the name in the class info. They may be different!
Also note that this is the specific type of class ie if you have class a and class b : public a, this function will return false for:
objectOfClassB->isTypeOf(b::getClass()) if (myObject->getObjectClass().isTypeOf(SomeClass::getClass()))
{
cout << "It is of the same type" << endl;
}
else
{
cout << "It is of a different type" << endl;
}
if (myObject->getObjectClass().isTypeOf(SomeClass<CString>::getClass()))
- Parameters:
-
| other | The class of the type that you want to check that this is |
- Return values:
-
| bool | True if class names are equal, false otherwise |
bool Exponent::Basics::CClass::isTypeOf |
( |
const char * |
className |
) |
const |
Check if this class is of a specific type.
- Note:
- that this function is not a recommended function, due to the name mangling which may occur during template use
although it is usually safe on CCountedObject inheritors that are not templates
- See also:
- bool isTypeOf(const CClass &other) const
- Parameters:
-
| className | The name of the type of class you want to check that this is |
- Return values:
-
| bool | True if class names are equal, false otherwise |
void Exponent::Basics::CClass::operator++ |
( |
int |
|
) |
|
Increment the class count
- Note:
- POSTFIX increment operator
Class this function each time you construct your class
void Exponent::Basics::CClass::operator-- |
( |
int |
|
) |
|
Decrement the class count
- Note:
- POSTFIX decrement operator
Class this function each time you destruct your class
CClass& Exponent::Basics::CClass::operator= |
( |
const CClass & |
other |
) |
|
Assignment operator
- Parameters:
-
| other | The class to copy the name of |
- Return values:
-
| CClass& | A reference to this |
bool Exponent::Basics::CClass::operator== |
( |
const CClass & |
other |
) |
const |
Equality operator
- Parameters:
-
| other | The class to check if this is equal to |
- Return values:
-
| bool | if the classes have the same name, false otherwise |
void Exponent::Basics::CClass::setClassInformation |
( |
const char * |
className |
) |
|
Set the name of the class
- Parameters:
-
| className | The name of the class |
Member Data Documentation
Maximum length of class name
Definition at line 102 of file CClass.hpp.
Name of the parent class
Definition at line 327 of file CClass.hpp.
Infinity API - Exponent::Basics::CClass Class Reference generated on 7 Mar 2007