The TypeRegistry class maintains all the assigned
TypeHandlesin a given system. 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.
TypeHandle find_type(std::string const &name) const
TypeHandle find_type_by_id(int id) const
TypeHandle get_child_class(TypeHandle child, int index) const
Returns the nth child class of this type. The index should be in the range 0 <= index <
std::string get_name(TypeHandle type, TypedObject *object) const
Returns the name of the indicated 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. This may then be used to index into
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. 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.
Returns the number of root classes–that is, classes that do not inherit from any other classes–known in the system.
TypeHandle get_parent_class(TypeHandle child, int index) const
Returns the nth parent class of this type. The index should be in the range 0 <= index <
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. This is useful in the presence of multiple inheritance to try to determine what properties an unknown type may have.
TypeHandle get_root_class(int n)
Returns the nth root class in the system. See
TypeHandle get_typehandle(int n)
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.
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”.
ptr() returns the pointer to the global
Returns the pointer to the global
void record_alternate_name(TypeHandle type, std::string const &name)
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.
void record_derivation(TypeHandle child, TypeHandle parent)
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.
void record_python_type(TypeHandle type, PyObject *python_type)
Records the given Python type pointer in the type registry for the benefit of interrogate, which expects this to contain a Dtool_PyTypedObject.
TypeHandle register_dynamic_type(std::string const &name)
Registers a new type on-the-fly, presumably at runtime. A new
TypeHandleis returned if the typename was not seen before; otherwise the same
TypeHandlethat was last used for this typename is returned.
static void reregister_types(void)
Walks through the
TypeRegistrytree 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.
- TypeHandle find_type(std::string const &name) const