#include <ccobject.h>
Public Member Functions | |
void (PASCAL *m_pfnConstruct)(void *p) | |
CCObject * | CreateObject () |
Dynamic creation of objects. This function should be used when you want to create an object and you do not know what type it should be until runtime. An example would be copying another object derived from CCObject. | |
BOOL | ConstructObject (void *pThis) |
Dynamically construct an instance of this class in the memory pointed to by 'pThis'. Return FALSE if can't construct (i.e. an abstract class). | |
BOOL | IsKindOf (const CCRuntimeClass *pClass) const |
This function will return TRUE if the object is of the same class as that specified by pClass, or if it is derived from the class specified by pClass. | |
LPCTSTR | GetClassName () const |
CCRuntimeClass * | GetBaseClass1 () const |
INT32 | GetSize () const |
Public Attributes | |
LPCTSTR | m_lpszClassName |
INT32 | m_nObjectSize |
UINT32 | m_wSchema |
CCRuntimeClass * | m_pBaseClass |
CCRuntimeClass * | m_pNextClass |
Static Public Attributes | |
static CCRuntimeClass * | pFirstClass = NULL |
Definition at line 124 of file ccobject.h.
|
Dynamically construct an instance of this class in the memory pointed to by 'pThis'. Return FALSE if can't construct (i.e. an abstract class).
Definition at line 1039 of file ccobject.cpp. 01040 { 01041 // Make sure memory we've been given is not a brown cylindrical object. 01042 ENSURE( IsValidAddress(pThis, m_nObjectSize), 01043 "CCRuntimeClass::ConstructObject: pThis pointer is invalid"); 01044 01045 // Try to create the object. 01046 if (m_pfnConstruct != NULL) 01047 { 01048 // It's not an abstract class, so call the constructor 01049 (*m_pfnConstruct)(pThis); 01050 return TRUE; 01051 } 01052 else 01053 { 01054 // Error - cannot construct an instance of an abstract class. 01055 TRACE( _T("Error: Trying to construct object of an abstract class %s.\n"), 01056 m_lpszClassName); 01057 return FALSE; 01058 } 01059 }
|
|
Dynamic creation of objects. This function should be used when you want to create an object and you do not know what type it should be until runtime. An example would be copying another object derived from CCObject.
Definition at line 994 of file ccobject.cpp. 00995 { 00996 void* pObject = NULL; 00997 00998 // Allocate memory for the new object. 00999 pObject = CCObject::operator new(m_nObjectSize, THIS_FILE, __LINE__); 01000 01001 // Attempt to construct it using dynamic creation facilities 01002 if ((pObject != NULL) && ConstructObject(pObject)) 01003 // All ok - return pointer to new object 01004 return (CCObject*) pObject; 01005 else 01006 { 01007 // Something went wrong... 01008 TRACE0( wxT("Warning: CCRuntimeClass::CreateObject failed\n") ); 01009 01010 // Did the 'new' succeed? If so, deallocate the storage 01011 if (pObject != NULL) 01012 CCObject::operator delete(pObject); // clean up 01013 01014 // Object creation failed. 01015 return NULL; 01016 } 01017 }
|
|
Definition at line 151 of file ccobject.h. 00151 {return m_pBaseClass;}
|
|
Definition at line 150 of file ccobject.h. 00150 {return m_lpszClassName;}
|
|
Definition at line 152 of file ccobject.h. 00152 {return m_nObjectSize;}
|
|
This function will return TRUE if the object is of the same class as that specified by pClass, or if it is derived from the class specified by pClass.
Definition at line 800 of file ccobject.cpp. 00801 { 00802 // Do some sanity checking 00803 ENSURE( this != NULL, 00804 "CCRuntimeClass::IsKindOf: Object pointer is null"); 00805 00806 // It had better be in valid memory, at least for CCObject size 00807 ENSURE( IsValidAddress(this, sizeof(CCRuntimeClass)), 00808 "CCRuntimeClass::IsKindOf: Object is in invalid memory area"); 00809 00810 // Get the runtime class information for this object 00811 register const CCRuntimeClass* pClassThis = this; 00812 00813 // Sanity checks 00814 ENSURE( pClass != NULL, 00815 "CCRuntimeClass::IsKindOf: pClass pointer is null"); 00816 ENSURE(pClassThis != NULL, 00817 "CCRuntimeClass::IsKindOf: pClassThis pointer is null"); 00818 00819 // Check for objects of the same class, or walk the base class chain until 00820 // it runs out, or we find a match. 00821 while (pClassThis != NULL) 00822 { 00823 if (pClassThis == pClass) 00824 return TRUE; 00825 pClassThis = pClassThis->m_pBaseClass; 00826 } 00827 00828 // No match - these classes are not the same. 00829 return FALSE; 00830 }
|
|
|
|
Definition at line 128 of file ccobject.h. |
|
Definition at line 131 of file ccobject.h. |
|
Definition at line 143 of file ccobject.h. |
|
Definition at line 159 of file ccobject.h. |
|
Definition at line 135 of file ccobject.h. |
|
Definition at line 158 of file ccobject.h. |