TypeRegistry

from panda3d.core import TypeRegistry
class TypeRegistry

Bases: DTOOL_SUPER_BASE

The TypeRegistry class maintains all the assigned TypeHandles in 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.

Inheritance diagram

Inheritance diagram of TypeRegistry

__init__(*args, **kwargs)
findType()

C++ Interface: find_type(TypeRegistry self, str name)

/**
  • 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.

*/

findTypeById()

C++ Interface: find_type_by_id(TypeRegistry self, int id)

/**
  • Looks for a previously-registered type with the given id number (as

  • returned by TypeHandle::get_index()). Returns its TypeHandle if it exists,

  • or TypeHandle::none() if there is no such type.

*/

find_type()

C++ Interface: find_type(TypeRegistry self, str name)

/**
  • 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.

*/

find_type_by_id()

C++ Interface: find_type_by_id(TypeRegistry self, int id)

/**
  • Looks for a previously-registered type with the given id number (as

  • returned by TypeHandle::get_index()). Returns its TypeHandle if it exists,

  • or TypeHandle::none() if there is no such type.

*/

getChildClass()

C++ Interface: get_child_class(TypeRegistry self, TypeHandle child, int index)

/**
  • Returns the nth child class of this type. The index should be in the range

  • 0 <= index < get_num_child_classes().

*/

getName()

C++ Interface: get_name(TypeRegistry self, TypeHandle type, TypedObject object)

/**
  • 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.

*/

getNumChildClasses()

C++ Interface: get_num_child_classes(TypeRegistry self, TypeHandle child, TypedObject child_object)

/**
  • 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.

*/

getNumParentClasses()

C++ Interface: get_num_parent_classes(TypeRegistry self, TypeHandle child, TypedObject child_object)

/**
  • 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.

*/

getNumRootClasses()

C++ Interface: get_num_root_classes(const TypeRegistry self)

/**
  • Returns the number of root classes–that is, classes that do not inherit

  • from any other classes–known in the system.

*/

getNumTypehandles()

C++ Interface: get_num_typehandles(const TypeRegistry self)

/**
  • Returns the total number of unique TypeHandles in the system.

*/

getParentClass()

C++ Interface: get_parent_class(TypeRegistry self, TypeHandle child, int index)

/**
  • Returns the nth parent class of this type. The index should be in the

  • range 0 <= index < get_num_parent_classes().

*/

getParentTowards()

C++ Interface: get_parent_towards(const TypeRegistry self, 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.

  • 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.

*/

getRootClass()

C++ Interface: get_root_class(const TypeRegistry self, int n)

/**
  • Returns the nth root class in the system. See get_num_root_classes().

*/

getRootClasses()
getTypehandle()

C++ Interface: get_typehandle(const TypeRegistry self, int n)

/**
  • Returns the nth TypeHandle in the system. See get_num_typehandles().

*/

getTypehandles()
get_child_class()

C++ Interface: get_child_class(TypeRegistry self, TypeHandle child, int index)

/**
  • Returns the nth child class of this type. The index should be in the range

  • 0 <= index < get_num_child_classes().

*/

get_name()

C++ Interface: get_name(TypeRegistry self, TypeHandle type, TypedObject object)

/**
  • 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.

*/

get_num_child_classes()

C++ Interface: get_num_child_classes(TypeRegistry self, TypeHandle child, TypedObject child_object)

/**
  • 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.

*/

get_num_parent_classes()

C++ Interface: get_num_parent_classes(TypeRegistry self, TypeHandle child, TypedObject child_object)

/**
  • 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.

*/

get_num_root_classes()

C++ Interface: get_num_root_classes(const TypeRegistry self)

/**
  • Returns the number of root classes–that is, classes that do not inherit

  • from any other classes–known in the system.

*/

get_num_typehandles()

C++ Interface: get_num_typehandles(const TypeRegistry self)

/**
  • Returns the total number of unique TypeHandles in the system.

*/

get_parent_class()

C++ Interface: get_parent_class(TypeRegistry self, TypeHandle child, int index)

/**
  • Returns the nth parent class of this type. The index should be in the

  • range 0 <= index < get_num_parent_classes().

*/

get_parent_towards()

C++ Interface: get_parent_towards(const TypeRegistry self, 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.

  • 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.

*/

get_root_class()

C++ Interface: get_root_class(const TypeRegistry self, int n)

/**
  • Returns the nth root class in the system. See get_num_root_classes().

*/

get_root_classes()
get_typehandle()

C++ Interface: get_typehandle(const TypeRegistry self, int n)

/**
  • Returns the nth TypeHandle in the system. See get_num_typehandles().

*/

get_typehandles()
isDerivedFrom()

C++ Interface: is_derived_from(const TypeRegistry self, TypeHandle child, TypeHandle base, TypedObject child_object)

/**
  • 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”.

*/

is_derived_from()

C++ Interface: is_derived_from(const TypeRegistry self, TypeHandle child, TypeHandle base, TypedObject child_object)

/**
  • 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”.

*/

ptr()

C++ Interface: ptr()

// ptr() returns the pointer to the global TypeRegistry object.

/**
  • Returns the pointer to the global TypeRegistry object.

*/

recordAlternateName()

C++ Interface: record_alternate_name(const TypeRegistry self, TypeHandle type, str 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.

*/

recordDerivation()

C++ Interface: record_derivation(const TypeRegistry self, 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.

*/

record_alternate_name()

C++ Interface: record_alternate_name(const TypeRegistry self, TypeHandle type, str 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.

*/

record_derivation()

C++ Interface: record_derivation(const TypeRegistry self, 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.

*/

registerDynamicType()

C++ Interface: register_dynamic_type(const TypeRegistry self, str name)

/**
  • 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.

*/

register_dynamic_type()

C++ Interface: register_dynamic_type(const TypeRegistry self, str name)

/**
  • 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.

*/

reregisterTypes()

C++ Interface: reregister_types()

/**
  • 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.

*/

reregister_types()

C++ Interface: reregister_types()

/**
  • 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.

*/

root_classes
typehandles
write()

C++ Interface: write(TypeRegistry self, ostream out)

/**
  • Makes an attempt to format the entire TypeRegistry in a nice way that shows

  • the derivation tree as intelligently as possible.

*/