#include <typeHandle.h>
Public Member Functions | |
TypeHandle () | |
The default constructor must do nothing, because we can't guarantee ordering of static initializers. | |
TypeHandle (const TypeHandle ©) | |
bool | operator== (const TypeHandle &other) const |
bool | operator!= (const TypeHandle &other) const |
bool | operator< (const TypeHandle &other) const |
bool | operator<= (const TypeHandle &other) const |
bool | operator> (const TypeHandle &other) const |
bool | operator>= (const TypeHandle &other) const |
int | compare_to (const TypeHandle &other) const |
Sorts TypeHandles arbitrarily (according to <, >, etc.). | |
string | get_name (TypedObject *object=(TypedObject *) NULL) const |
Returns the name of the type. | |
bool | is_derived_from (TypeHandle parent, TypedObject *object=(TypedObject *) NULL) const |
Returns true if this type is derived from the indicated type, false otherwise. | |
int | get_num_parent_classes (TypedObject *object=(TypedObject *) NULL) const |
Returns the number of parent classes that this type is known to have. | |
TypeHandle | get_parent_class (int index) const |
Returns the nth parent class of this type. | |
int | get_num_child_classes (TypedObject *object=(TypedObject *) NULL) const |
Returns the number of child classes that this type is known to have. | |
TypeHandle | get_child_class (int index) const |
Returns the nth child class of this type. | |
TypeHandle | get_parent_towards (TypeHandle ancestor, TypedObject *object=(TypedObject *) NULL) const |
Returns the parent class that is in a direct line of inheritance to the indicated ancestor class. | |
int | get_index () const |
Returns the integer index associated with this TypeHandle. | |
void | output (ostream &out) const |
Static Public Member Functions | |
TypeHandle | none () |
Returns a special zero-valued TypeHandle that is used to indicate no type. | |
Private Attributes | |
int | _index |
Static Private Attributes | |
TypeHandle | _none |
Friends | |
class | TypeRegistry |
Any C++ classes that inherit from some base class, and must be differentiated at run time, should store a static TypeHandle object that can be queried through a static member function named get_class_type(). Most of the time, it is also desirable to inherit from TypedObject, which provides some virtual functions to return the TypeHandle for a particular instance.
At its essence, a TypeHandle is simply a unique identifier that is assigned by the TypeRegistry. The TypeRegistry stores a tree of TypeHandles, so that ancestry of a particular type may be queried, and the type name may be retrieved for run-time display.
Definition at line 111 of file typeHandle.h.
|
The default constructor must do nothing, because we can't guarantee ordering of static initializers. If the constructor tried to initialize its value, it might happen after the value had already been set previously by another static initializer! Definition at line 45 of file typeHandle.I. |
|
Definition at line 56 of file typeHandle.I. |
|
Sorts TypeHandles arbitrarily (according to <, >, etc.). Returns a number less than 0 if this type sorts before the other one, greater than zero if it sorts after, 0 if they are equivalent. Definition at line 146 of file typeHandle.I. References INLINE, TypeRegistry::is_derived_from(), and TypeRegistry::ptr(). |
|
Returns the nth child class of this type. The index should be in the range 0 <= index < get_num_child_classes(). Definition at line 294 of file typeHandle.I. |
|
Returns the integer index associated with this TypeHandle. Each different TypeHandle will have a different index. However, you probably shouldn't be using this method; you should just treat the TypeHandles as opaque classes. This is provided for the convenience of non-C++ scripting languages to build a hashtable of TypeHandles. Definition at line 358 of file typeHandle.I. Referenced by RenderState::Attribute::operator=(), RenderEffects::Effect::operator=(), TypedObject::operator=(), and TypeRegistry::write(). |
|
Returns the name of the type. The "object" pointer is an optional pointer to the TypedObject class that owns this TypeHandle. It is only used in case the TypeHandle is inadvertantly undefined. Definition at line 169 of file typeHandle.I. References TypeRegistry::get_num_parent_classes(), INLINE, and TypeRegistry::ptr(). Referenced by TypedObject::get_type_index(), PartGroup::pick_channel_index(), and AnimGroup::write_datagram(). |
|
Returns the number of child classes that this type is known to have. This may then be used to index into get_child_class(). The "object" pointer is an optional pointer to the TypedObject class that owns this TypeHandle. It is only used in case the TypeHandle is inadvertantly undefined. Definition at line 277 of file typeHandle.I. |
|
Returns the number of parent classes that this type is known to have. This may then be used to index into get_parent_class(). The result will be 0 if this class does not inherit from any other classes, 1 if normal, single inheritance is in effect, or greater than one if multiple inheritance is in effect. The "object" pointer is an optional pointer to the TypedObject class that owns this TypeHandle. It is only used in case the TypeHandle is inadvertantly undefined. Definition at line 233 of file typeHandle.I. References TypeRegistry::get_parent_towards(), INLINE, and TypeRegistry::ptr(). |
|
Returns the nth parent class of this type. The index should be in the range 0 <= index < get_num_parent_classes(). Definition at line 250 of file typeHandle.I. |
|
Returns the parent class that is in a direct line of inheritance to the indicated ancestor class. This is useful in the presence of multiple inheritance to try to determine what properties an unknown type may have. The return value is TypeHandle::none() if the type does not inherit from the ancestor. If ancestor is the same as this type, the return value is this type. The "object" pointer is an optional pointer to the TypedObject class that owns this TypeHandle. It is only used in case the TypeHandle is inadvertantly undefined. Definition at line 333 of file typeHandle.I. |
|
Returns true if this type is derived from the indicated type, false otherwise. The "object" pointer is an optional pointer to the TypedObject class that owns this TypeHandle. It is only used in case the TypeHandle is inadvertantly undefined. Definition at line 198 of file typeHandle.I. References TypeRegistry::get_num_child_classes(), INLINE, and TypeRegistry::ptr(). Referenced by FactoryBase::get_preferred(), and GraphicsPipeSelection::print_pipe_types(). |
|
Returns a special zero-valued TypeHandle that is used to indicate no type.
Definition at line 386 of file typeHandle.I. Referenced by AnimGroup::find_child(), FactoryBase::find_registered_type(), TypeRegistry::get_num_parent_classes(), FactoryBase::make_instance(), and operator>=(). |
|
Definition at line 79 of file typeHandle.I. |
|
Definition at line 91 of file typeHandle.I. |
|
Definition at line 103 of file typeHandle.I. References _index. |
|
Definition at line 67 of file typeHandle.I. |
|
Definition at line 115 of file typeHandle.I. |
|
Definition at line 127 of file typeHandle.I. References TypeRegistry::get_name(), INLINE, none(), and TypeRegistry::ptr(). |
|
Definition at line 371 of file typeHandle.I. |
|
Definition at line 145 of file typeHandle.h. |
|
Definition at line 142 of file typeHandle.h. Referenced by get_parent_class(), operator!=(), operator<(), operator<=(), operator==(), operator>(), TypeRegistry::ptr(), and TypeHandle(). |
|
Definition at line 25 of file typeHandle.cxx. |