ccobject.h File Reference

(r1785/r751)

Go to the source code of this file.

Classes

class  CCRuntimeClass
 Provide run-time class information and dynamic class creation for objects derived from CCObject. More...
class  SimpleCCObject
 Override new and delete, so that new returns NULL when no more memory is available, rather than throwing an exception. More...
class  CCObject
 CCObject is derived from SimpleCCObject, so it provides the same new and delete operators. It also provides facilities for dynamic class information, and dynamic construction of objects. More...
class  AutoDeleteCCObject
 Simplifies cleanup of temporary CCObject derived objects. More...
class  CC_CLASSINIT
 This type is important because it is used to build up the runtime class information used by CCObject and CCRuntimeClass. What happens is that any class declared as dynamic has a static instance of an object of this type. This static object is declared by the CC_IMPLEMENT_{DYNAMIC,DYNCREATE} macro. Declaring this object as static means that its constructor is called at program startup (very early on in the initialisation. The constructor is the important part - the object is declared passing in a pointer to the runtime class object (CCRuntimeClass) associated with the class in question. The CC_CLASSINIT then adds this object to the list of classes maintained and used by the CCRuntimeClass class. More...

Defines

#define CAM_DEBUG_NEW   new
#define IS_SAME_CLASS(pObj1, pObj2)   (((pObj1)->GetRuntimeClass()) == ((pObj2)->GetRuntimeClass()))
 This macro determines whether or not two CCObject-derived objects have the same runtime class identifier, i.e. they are of the same class. This is a strict check, unlike IsKindOf(), which follows the inheritance chain.
#define IS_A(pObj, ClassName)   (((pObj)->GetRuntimeClass()) == (CC_RUNTIME_CLASS(ClassName)))
 This macro is a convenient shorthand for checking to see if a CCObject- derived object is of a particular class. This is a strict check, unlike IsKindOf(), which follows the inheritance chain.
#define IS_KIND_OF(ClassName)   IsKindOf(CC_RUNTIME_CLASS(ClassName))
 This macro is a convenient shorthand for the IsKindOf() function.
#define CC_RUNTIME_CLASS(class_name)   (&class_name::cc_class##class_name)
 This macro returns a pointer to the CCRuntimeClass object associated with the named class. This structure can be used for determining if an object is of a particular type, or for dynamically creating a new object of this type. To use such features, the class must have been declared as supporting them with CC_DECLARE_DYNAMIC and so on.
#define CC_DECLARE_DYNAMIC(class_name)
 Adds declarations to a class which has been derived from CCObject which enable it to use runtime classing facilities.
#define CC_DECLARE_DYNCREATE(class_name)
 Adds declarations to a class which has been derived from CCObject which enable it to use runtime classing and dynamic object construction facilities.
#define _CC_IMPLEMENT_RUNTIMECLASS(class_name, base_class_name, wSchema, pfnNew)
#define CC_IMPLEMENT_DYNAMIC(class_name, base_class_name)   _CC_IMPLEMENT_RUNTIMECLASS(class_name, base_class_name, 0xFFFF, NULL)
 This macro provides the definitions required to make a class dynamic, i.e. make it possible to determine its type at runtime. Note that this macro should be used in the .cpp file, and will only work if the class declaration (.h file) also uses the CC_DECLARE_DYNAMIC macro.
#define CC_IMPLEMENT_DYNCREATE(class_name, base_class_name)
 This macro provides the definitions required to make a class dynamic, i.e. make it possible to determine its type at runtime, and to make it possible to create an object dynamically without knowing its type at runtime (see CCObject for more details). Note that this macro should be used in the .cpp file, and will only work if the class declaration (.h file) also uses the CC_DECLARE_DYNCREATE macro.
#define CC_CLASS_MEMDUMP   SimpleCCObject
#define CC_DECLARE_MEMDUMP(class_name)
 Used when runtime class information is desirable in debug builds, but not in retail builds. Use as follows in your class declaration:.
#define CC_IMPLEMENT_MEMDUMP(class_name, base_class_name)
 Used when runtime class information is desirable in debug builds, but not in retail builds. Use as follows in your class definition (.cpp file):.
#define CC_ASSERT_VALID(pOb)   ((void)0)
 This function is used to check the validity of an object - it checks for things like NULL pointers, bad segment selectors, incorrect vtable pointers etc - see CCAssertValidObject for more details.

Functions

void CCAPI CCAssertValidObject (const CCObject *pOb, LPCSTR FileName, INT32 Line)


Define Documentation

#define _CC_IMPLEMENT_RUNTIMECLASS class_name,
base_class_name,
wSchema,
pfnNew   ) 
 

Value:

/* Provide textual name of class */ \
    static TCHAR BASED_CODE _lpsz##class_name[] = wxT( #class_name ); \
    /* Declare runtime class information for this class */ \
    CCRuntimeClass class_name::cc_class##class_name = { \
        _lpsz##class_name, sizeof(class_name), wSchema, pfnNew, \
            CC_RUNTIME_CLASS(base_class_name), NULL }; \
    /* Declare the CC_CLASSINIT structure so that the class info is linked in */ \
    static CC_CLASSINIT _init_##class_name(&class_name::cc_class##class_name); \
    /* Implement GetRuntimeClass() */ \
    CCRuntimeClass* class_name::GetRuntimeClass() const \
        { return &class_name::cc_class##class_name; } \
    /* Implement GetMyClass() (a static function) */ \
    CCRuntimeClass* class_name::GetMyClass() \
        { return &class_name::cc_class##class_name; } \

Definition at line 643 of file ccobject.h.

#define CAM_DEBUG_NEW   new
 

Definition at line 245 of file ccobject.h.

#define CC_ASSERT_VALID pOb   )     ((void)0)
 

This function is used to check the validity of an object - it checks for things like NULL pointers, bad segment selectors, incorrect vtable pointers etc - see CCAssertValidObject for more details.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/7/93
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
CCAssertValidObject

Definition at line 896 of file ccobject.h.

#define CC_CLASS_MEMDUMP   SimpleCCObject
 

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/7/93 Comment: This is a macro that is used when runtime class information is desirable in debug builds, but not in retail builds. Use as follows in your class declaration:
MonoOn class MyClass : public CC_CLASS_MEMDUMP { ... }; MonoOff

This macro evaluates to CCObject in debug builds, i.e. it provides dynamic class information, and in retail builds it evaluates to SimpleCCObject, i.e. it overrides new and delete, but you don't get the dynamic class information, or the overhead of a virtual function table.

It should be used in conjunction with CC_DECLARE_MEMDUMP and CC_IMPLEMENT_MEMDUMP.

Using this facility makes memory diagnostics much more detailed, and so it is easier to tell which objects are not being cleaned up.

See also:
CC_DECLARE_MEMDUMP; CC_IMPLEMENT_MEMDUMP; CCObject; SimpleCCObject

Definition at line 784 of file ccobject.h.

#define CC_DECLARE_DYNAMIC class_name   ) 
 

Value:

public: \
    static CCRuntimeClass cc_class##class_name; \
    static CCRuntimeClass* GetMyClass(); \
    virtual CCRuntimeClass* GetRuntimeClass() const;
Adds declarations to a class which has been derived from CCObject which enable it to use runtime classing facilities.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/7/93
Parameters:
Name of the class being declared as dynamic. [INPUTS]
- [OUTPUTS]
Returns:
-
NB. Do not have a trailing semi-colon after this macro.

Returns:
Errors: -
See also:
CC_IMPLEMENT_DYNAMIC; CC_RUNTIME_CLASS; CCObject; CCRuntimeClass

Definition at line 580 of file ccobject.h.

#define CC_DECLARE_DYNCREATE class_name   ) 
 

Value:

CC_DECLARE_DYNAMIC(class_name) \
    static void PASCAL Construct(void* p);
Adds declarations to a class which has been derived from CCObject which enable it to use runtime classing and dynamic object construction facilities.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/7/93
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-
NB. Do not have a trailing semi-colon after this macro.

Returns:
Errors: -
See also:
CC_IMPLEMENT_DYNCREATE; CC_RUNTIME_CLASS; CCObject; CCRuntimeClass

Definition at line 605 of file ccobject.h.

#define CC_DECLARE_MEMDUMP class_name   ) 
 

Used when runtime class information is desirable in debug builds, but not in retail builds. Use as follows in your class declaration:.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/7/93
Parameters:
class_name - Name of the class being declared as dynamic. [INPUTS]
- [OUTPUTS]
Returns:
-
MonoOn class MyClass : public CCObject { CC_DECLARE_MEMDUMP(MyClass) ... }; MonoOff

This macro evaluates to CC_DECLARE_DYNAMIC in debug builds, i.e. it provides dynamic class information, and in retail builds it evaluates to nothing, i.e. the runtime classing disappears.

It should be used in conjunction with CC_IMPLEMENT_MEMDUMP (and CC_CLASS_MEMDUMP if your class is normally derived from SimpleCCObject).

Using this facility makes memory diagnostics much more detailed, and so it is easier to tell which objects are not being cleaned up.

NB. Do not have a trailing semi-colon after this macro.

Returns:
Errors: -
See also:
CC_CLASS_MEMDUMP; CC_IMPLEMENT_MEMDUMP; CCObject; SimpleCCObject

Definition at line 827 of file ccobject.h.

#define CC_IMPLEMENT_DYNAMIC class_name,
base_class_name   )     _CC_IMPLEMENT_RUNTIMECLASS(class_name, base_class_name, 0xFFFF, NULL)
 

This macro provides the definitions required to make a class dynamic, i.e. make it possible to determine its type at runtime. Note that this macro should be used in the .cpp file, and will only work if the class declaration (.h file) also uses the CC_DECLARE_DYNAMIC macro.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/7/93
Parameters:
class_name - Name of the class being declared as dynamic. [INPUTS] base_class_name - Immediate base class of class 'class_name'.
- [OUTPUTS]
Returns:
-
The base class name is used so that the correct result is returned for derived classes, e.g. MonoOn

pObject is really a NodeRenderableInk object CCObject *pObject = SomeObject;

This succeeds because NodeRenderableInk is also a Node because NodeRenderableInk is (ultimately) derived from Node ASSERT(pObject->IsKindOf(CC_RUNTIME_CLASS(Node)));

MonoOff

NB. Do not have a trailing semi-colon after this macro.

Returns:
Errors: -
See also:
CC_DECLARE_DYNAMIC; CCObject; CCRuntimeClass; CC_RUNTIME_CLASS; GetRuntimeClass; IsKindOf

Definition at line 697 of file ccobject.h.

#define CC_IMPLEMENT_DYNCREATE class_name,
base_class_name   ) 
 

Value:

/* Implement the Construct() function */ \
    void PASCAL class_name::Construct(void* p) \
        { new(p) class_name; } \
    _CC_IMPLEMENT_RUNTIMECLASS(class_name, base_class_name, 0xFFFF, \
        class_name::Construct)
This macro provides the definitions required to make a class dynamic, i.e. make it possible to determine its type at runtime, and to make it possible to create an object dynamically without knowing its type at runtime (see CCObject for more details). Note that this macro should be used in the .cpp file, and will only work if the class declaration (.h file) also uses the CC_DECLARE_DYNCREATE macro.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/7/93
Parameters:
class_name - Name of the class being declared as dynamic. [INPUTS] base_class_name - Immediate base class of class 'class_name'.
- [OUTPUTS]
Returns:
-
The base class name is used so that the correct result is returned for derived classes, e.g. MonoOn

pObject is really a NodeRenderableInk object CCObject *pObject = SomeObject;

This succeeds because NodeRenderableInk is also a Node because NodeRenderableInk is (ultimately) derived from Node ASSERT(pObject->IsKindOf(CC_RUNTIME_CLASS(Node)));

MonoOff

NB. Do not have a trailing semi-colon after this macro.

Returns:
Errors: -
See also:
CC_DECLARE_DYNCREATE; CCObject; CCRuntimeClass; CC_RUNTIME_CLASS; GetRuntimeClass; IsKindOf; CreateObject

Definition at line 739 of file ccobject.h.

#define CC_IMPLEMENT_MEMDUMP class_name,
base_class_name   ) 
 

Used when runtime class information is desirable in debug builds, but not in retail builds. Use as follows in your class definition (.cpp file):.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/7/93
Parameters:
class_name - Name of the class being declared as dynamic. [INPUTS] base_class_name - Immediate base class of class 'class_name'.
- [OUTPUTS]
Returns:
-
MonoOn CC_IMPLEMENT_MEMDUMP(MyClass, MyBaseClass) MonoOff

This macro evaluates to CC_IMPLEMENT_DYNAMIC in debug builds, i.e. it provides dynamic class information, and in retail builds it evaluates to nothing, i.e. the runtime classing disappears.

It should be used in conjunction with CC_DECLARE_MEMDUMP (and CC_CLASS_MEMDUMP if your class is normally derived from SimpleCCObject).

Using this facility makes memory diagnostics much more detailed, and so it is easier to tell which objects are not being cleaned up.

NB. Do not have a trailing semi-colon after this macro.

Returns:
Errors: -
See also:
CC_CLASS_MEMDUMP; CC_DECLARE_MEMDUMP; CCObject; SimpleCCObject

Definition at line 868 of file ccobject.h.

#define CC_RUNTIME_CLASS class_name   )     (&class_name::cc_class##class_name)
 

This macro returns a pointer to the CCRuntimeClass object associated with the named class. This structure can be used for determining if an object is of a particular type, or for dynamically creating a new object of this type. To use such features, the class must have been declared as supporting them with CC_DECLARE_DYNAMIC and so on.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/7/93
Parameters:
Name of the class [INPUTS]
- [OUTPUTS]
Returns:
Pointer to a CCRuntimeClass object

Errors: If used on a class that does not support runtime classing, it will cause a compile-time error.

See also:
CCObject; CCRuntimeClass; CreateObject; IsKindOf

Definition at line 558 of file ccobject.h.

#define IS_A pObj,
ClassName   )     (((pObj)->GetRuntimeClass()) == (CC_RUNTIME_CLASS(ClassName)))
 

This macro is a convenient shorthand for checking to see if a CCObject- derived object is of a particular class. This is a strict check, unlike IsKindOf(), which follows the inheritance chain.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/8/94
Parameters:
pObj - Pointer to the object to test (must be CCObject derived, or a [INPUTS] CCRuntime class object). ClassName - Name of the class to test for
Returns:
TRUE if pObj is the same class as, or derived from, the class specified by ClassName.
e.g. MonoOn if (IS_A(pNode, NodeRenderable)) { ... } MonoOff

Returns:
Errors: If used on a class that does not support runtime classing, it will cause a compile-time error.
See also:
CCObject; CCRuntimeClass; CreateObject; IsKindOf

Definition at line 503 of file ccobject.h.

#define IS_KIND_OF ClassName   )     IsKindOf(CC_RUNTIME_CLASS(ClassName))
 

This macro is a convenient shorthand for the IsKindOf() function.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/8/94
Parameters:
ClassName - Name of the class to test for [INPUTS]
Returns:
TRUE if pObj is the same class as, or derived from, the class specified by ClassName.
e.g. MonoOn if (pNode->IS_KIND_OF(NodeRenderable)) { ... } MonoOff

Returns:
Errors: If used on a class that does not support runtime classing, it will cause a compile-time error.
See also:
CCObject; CCRuntimeClass; CreateObject; IsKindOf

Definition at line 531 of file ccobject.h.

#define IS_SAME_CLASS pObj1,
pObj2   )     (((pObj1)->GetRuntimeClass()) == ((pObj2)->GetRuntimeClass()))
 

This macro determines whether or not two CCObject-derived objects have the same runtime class identifier, i.e. they are of the same class. This is a strict check, unlike IsKindOf(), which follows the inheritance chain.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/8/94
Parameters:
pObj1,pObj2 - Pointers to the objects to compare. [INPUTS]
Returns:
TRUE if both objects are EXACTLY the same class type; FALSE if not.
e.g. MonoOn if (IS_SAME_CLASS(pNode, pOtherNode)) { ... } MonoOff

Returns:
Errors: If used on a class that does not support runtime classing, it will cause a compile-time error.
See also:
CCObject; CCRuntimeClass; CreateObject; IsKindOf

Definition at line 471 of file ccobject.h.


Function Documentation

void CCAPI CCAssertValidObject const CCObject pOb,
LPCSTR  FileName,
INT32  Line
 


Generated on Sat Nov 10 03:49:28 2007 for Camelot by  doxygen 1.4.4