#include <typeRegistry.h>
Public Member Functions | |
bool | register_type (TypeHandle &type_handle, const string &name) |
Creates a new Type of the given name and assigns a unique value to the type_handle. | |
TypeHandle | register_dynamic_type (const string &name) |
Registers a new type on-the-fly, presumably at runtime. | |
void | record_derivation (TypeHandle child, TypeHandle parent) |
Records that the type referenced by child inherits directly from the type referenced by parent. | |
void | record_alternate_name (TypeHandle type, const string &name) |
Indicates an alternate name for the same type. | |
TypeHandle | find_type (const string &name) const |
Looks for a previously-registered type of the given name. | |
string | get_name (TypeHandle type, TypedObject *object) const |
Returns the name of the indicated type. | |
bool | is_derived_from (TypeHandle child, TypeHandle base, TypedObject *child_object) |
Returns true if the first type is derived from the second type, false otherwise. | |
int | get_num_root_classes () |
Returns the number of root classes--that is, classes that do not inherit from any other classes--known in the system. | |
TypeHandle | get_root_class (int n) |
Returns the nth root class in the system. | |
int | get_num_parent_classes (TypeHandle child, TypedObject *child_object) const |
Returns the number of parent classes that the indicated type is known to have. | |
TypeHandle | get_parent_class (TypeHandle child, int index) const |
Returns the nth parent class of this type. | |
int | get_num_child_classes (TypeHandle child, TypedObject *child_object) const |
Returns the number of child classes that the indicated type is known to have. | |
TypeHandle | get_child_class (TypeHandle child, int index) const |
Returns the nth child class of this type. | |
TypeHandle | get_parent_towards (TypeHandle child, TypeHandle base, TypedObject *child_object) |
Returns the parent of the indicated child class that is in a direct line of inheritance to the indicated ancestor class. | |
void | write (ostream &out) const |
Makes an attempt to format the entire TypeRegistry in a nice way that shows the derivation tree as intelligently as possible. | |
Static Public Member Functions | |
void | reregister_types () |
Walks through the TypeRegistry tree and makes sure that each type that was previously registered is still* registered. | |
TypeRegistry * | ptr () |
Returns the pointer to the global TypeRegistry object. | |
Private Types | |
typedef pvector< TypeRegistryNode * > | HandleRegistry |
typedef pmap< string, TypeRegistryNode * > | NameRegistry |
typedef pvector< TypeRegistryNode * > | RootClasses |
Private Member Functions | |
TypeRegistry () | |
TypeRegistryNode * | look_up (TypeHandle type, TypedObject *object) const |
Returns the TypeRegistryNode associated with the indicated TypeHandle. | |
void | freshen_derivations () |
Rebuilds the derivation data structures after some derivation relationship has been modified, so that class relationships can quickly be determined. | |
void | rebuild_derivations () |
Rebuilds the derivation data structures after some derivation relationship has been modified, so that class relationships can quickly be determined. | |
void | write_node (ostream &out, int indent_level, const TypeRegistryNode *node) const |
Writes a single TypeRegistryNode out, along with all of its descendants. | |
Static Private Member Functions | |
void | init_global_pointer () |
Constructs the TypeRegistry object for the first time. | |
Private Attributes | |
HandleRegistry | _handle_registry |
NameRegistry | _name_registry |
RootClasses | _root_classes |
bool | _derivations_fresh |
Static Private Attributes | |
TypeRegistry * | _global_pointer = NULL |
There should be only one TypeRegistry class during the lifetime of the application. It will be created on the local heap initially, and it should be migrated to shared memory as soon as shared memory becomes available.
Definition at line 51 of file typeRegistry.h.
|
Definition at line 111 of file typeRegistry.h. |
|
Definition at line 114 of file typeRegistry.h. |
|
Definition at line 117 of file typeRegistry.h. |
|
Definition at line 578 of file typeRegistry.cxx. |
|
Looks for a previously-registered type of the given name. Returns its TypeHandle if it exists, or TypeHandle::none() if there is no such type. Definition at line 266 of file typeRegistry.cxx. References _root_classes. Referenced by FactoryBase::make_instance(). |
|
Rebuilds the derivation data structures after some derivation relationship has been modified, so that class relationships can quickly be determined.
Definition at line 57 of file typeRegistry.I. References INLINE, TypeRegistryNode::is_derived_from(), look_up(), nassertr, and NULL. Referenced by get_num_parent_classes(). |
|
Returns the nth child class of this type. The index should be in the range 0 <= index < get_num_child_classes(). Definition at line 437 of file typeRegistry.cxx. References _global_pointer, init_global_pointer(), and NULL. |
|
Returns the name of the indicated 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 296 of file typeRegistry.cxx. References TypeRegistryNode::_parent_classes, look_up(), nassertr, and NULL. Referenced by TypeHandle::operator>=(). |
|
Returns the number of child classes that the indicated 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 418 of file typeRegistry.cxx. References _handle_registry, NULL, root, and write_node(). Referenced by TypeHandle::is_derived_from(). |
|
Returns the number of parent classes that the indicated 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 368 of file typeRegistry.cxx. References freshen_derivations(), TypeRegistryNode::get_parent_towards(), look_up(), nassertr, TypeHandle::none(), and NULL. Referenced by TypeHandle::get_name(). |
|
Returns the number of root classes--that is, classes that do not inherit from any other classes--known in the system.
Definition at line 315 of file typeRegistry.cxx. |
|
Returns the nth parent class of this type. The index should be in the range 0 <= index < get_num_parent_classes(). Definition at line 387 of file typeRegistry.cxx. References TypeRegistryNode::_handle, _handle_registry, TypeRegistryNode::_name, TypeRegistryNode::_ref, NULL, and ptr(). |
|
Returns the parent of the indicated child 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 "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 472 of file typeRegistry.cxx. References _global_pointer, TypeRegistryNode::_paranoid_inheritance, and get_paranoid_inheritance(). Referenced by TypeHandle::get_num_parent_classes(). |
|
Returns the nth root class in the system. Definition at line 331 of file typeRegistry.cxx. References TypeRegistryNode::_child_classes, look_up(), nassertr, and NULL. |
|
Constructs the TypeRegistry object for the first time. It is initially created on the local heap, then as soon as shared memory becomes available, it should be moved into shared memory. Definition at line 602 of file typeRegistry.cxx. Referenced by get_child_class(). |
|
Returns true if the first type is derived from the second type, false otherwise. The "child_object" pointer is an optional pointer to the TypedObject class that owns the child TypeHandle. It is only used in case the TypeHandle is inadvertently undefined. This function definition follows the definitions for look_up() and freshen_derivations() just to maximize the chance the the compiler will be able to inline the above functions. Yeah, a compiler shouldn't care, but there's a big different between "shouldn't" and "doesn't". Definition at line 99 of file typeRegistry.I. Referenced by TypeHandle::compare_to(). |
|
Returns the TypeRegistryNode associated with the indicated TypeHandle. If there is no associated TypeRegistryNode, reports an error condition and returns NULL. The associated TypedObject pointer is the pointer to the object that owns the handle, if available. It is only used in an error condition, if for some reason the handle was uninitialized. Definition at line 714 of file typeRegistry.cxx. Referenced by freshen_derivations(), get_name(), get_num_parent_classes(), get_root_class(), record_alternate_name(), and record_derivation(). |
|
Returns the pointer to the global TypeRegistry object.
Definition at line 557 of file typeRegistry.cxx. References TypeHandle::_index, TypedObject::force_init_type(), and NULL. Referenced by TypeHandle::compare_to(), TypeHandle::get_name(), TypeHandle::get_num_parent_classes(), get_parent_class(), TypeHandle::is_derived_from(), FactoryBase::make_instance(), TypeHandle::operator>=(), register_dynamic_type(), and register_type(). |
|
Rebuilds the derivation data structures after some derivation relationship has been modified, so that class relationships can quickly be determined.
Definition at line 623 of file typeRegistry.cxx. |
|
Indicates an alternate name for the same type. This is particularly useful when a type has changed names, since the type is stored in a Bam file by name; setting the original name as the alternate will allow the type to be correctly read from old Bam files. Definition at line 240 of file typeRegistry.cxx. References TypeRegistryNode::_name, look_up(), nassertr, and NULL. |
|
Records that the type referenced by child inherits directly from the type referenced by parent. In the event of multiple inheritance, this should be called once for each parent class. Definition at line 204 of file typeRegistry.cxx. References TypeRegistryNode::_name, _name_registry, look_up(), and NULL. Referenced by register_dynamic_type(), and register_type(). |
|
Registers a new type on-the-fly, presumably at runtime. A new TypeHandle is returned if the typename was not seen before; otherwise the same TypeHandle that was last used for this typename is returned. Definition at line 154 of file typeRegistry.cxx. References _derivations_fresh, _handle_registry, and _name_registry. Referenced by register_dynamic_type(), and register_type(). |
|
Creates a new Type of the given name and assigns a unique value to the type_handle. All type names must be unique. If the type name has already been used, the supplied type_handle value must match the name's assigned type_handle or an error is triggered. Returns true if the name wasn't defined before, false if it was. Definition at line 58 of file typeRegistry.cxx. References _name_registry. Referenced by register_type(). |
|
Walks through the TypeRegistry tree and makes sure that each type that was previously registered is still* registered. This seems to get broken in certain circumstances when compiled against libc5--it is as if the static initializer stomps on the _type_handle values of each class after they've been registered. Definition at line 504 of file typeRegistry.cxx. References _handle_registry, and NULL. |
|
Makes an attempt to format the entire TypeRegistry in a nice way that shows the derivation tree as intelligently as possible.
Definition at line 532 of file typeRegistry.cxx. References TypeRegistryNode::_child_classes, TypeRegistryNode::_handle, TypeRegistryNode::_name, TypeRegistryNode::_parent_classes, TypeHandle::get_index(), indent(), and write_node(). |
|
Writes a single TypeRegistryNode out, along with all of its descendants.
Definition at line 669 of file typeRegistry.cxx. Referenced by get_num_child_classes(), and write(). |
|
Definition at line 120 of file typeRegistry.h. Referenced by register_dynamic_type(). |
|
Definition at line 34 of file typeRegistry.cxx. Referenced by get_child_class(), and get_parent_towards(). |
|
Definition at line 112 of file typeRegistry.h. Referenced by get_num_child_classes(), get_parent_class(), register_dynamic_type(), and reregister_types(). |
|
Definition at line 115 of file typeRegistry.h. Referenced by record_derivation(), register_dynamic_type(), and register_type(). |
|
Definition at line 118 of file typeRegistry.h. Referenced by find_type(). |