TypeRegistry
from panda3d.core import TypeRegistry
- class TypeRegistry
Bases:
Bases:
MemoryBaseThe 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.Inheritance diagram
- __init__(param0: TypeRegistry)
- findType(name: str) TypeHandle
Looks for a previously-registered type of the given name. Returns its
TypeHandleif it exists, orTypeHandle.none()if there is no such type.
- findTypeById(id: int) TypeHandle
Looks for a previously-registered type with the given id number (as returned by
TypeHandle.getIndex()). Returns itsTypeHandleif it exists, orTypeHandle.none()if there is no such type.
- getChildClass(child: TypeHandle, index: int) TypeHandle
Returns the nth child class of this type. The index should be in the range 0 <= index <
getNumChildClasses().
- getName(type: TypeHandle, object: TypedObject) str
Returns the name of the indicated type.
The “object” pointer is an optional pointer to the
TypedObjectclass that owns thisTypeHandle. It is only used in case theTypeHandleis inadvertantly undefined.
- getNumChildClasses(child: TypeHandle, child_object: TypedObject) int
Returns the number of child classes that the indicated type is known to have. This may then be used to index into
getChildClass().The “object” pointer is an optional pointer to the
TypedObjectclass that owns thisTypeHandle. It is only used in case theTypeHandleis inadvertantly undefined.
- getNumParentClasses(child: TypeHandle, child_object: TypedObject) int
Returns the number of parent classes that the indicated type is known to have. This may then be used to index into
getParentClass(). 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
TypedObjectclass that owns thisTypeHandle. It is only used in case theTypeHandleis inadvertantly undefined.
- getNumRootClasses() int
Returns the number of root classes–that is, classes that do not inherit from any other classes–known in the system.
- getNumTypehandles() int
Returns the total number of unique
TypeHandlesin the system.
- getParentClass(child: TypeHandle, index: int) TypeHandle
Returns the nth parent class of this type. The index should be in the range 0 <= index <
getNumParentClasses().
- getParentTowards(child: TypeHandle, base: TypeHandle, child_object: TypedObject) TypeHandle
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
TypedObjectclass that owns thisTypeHandle. It is only used in case theTypeHandleis inadvertantly undefined.
- getRootClass(n: int) TypeHandle
Returns the nth root class in the system. See
getNumRootClasses().
- getTypehandle(n: int) TypeHandle
Returns the nth
TypeHandlein the system. SeegetNumTypehandles().
- isDerivedFrom(child: TypeHandle, base: TypeHandle, child_object: TypedObject) bool
Returns true if the first type is derived from the second type, false otherwise.
The “child_object” pointer is an optional pointer to the
TypedObjectclass that owns the childTypeHandle. It is only used in case theTypeHandleis 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”.
- static ptr() TypeRegistry
Returns the pointer to the global
TypeRegistryobject.
- recordAlternateName(type: TypeHandle, name: str)
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(child: TypeHandle, parent: TypeHandle)
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.
- recordPythonType(type: TypeHandle, python_type: object)
Records the given Python type pointer in the type registry for the benefit of interrogate, which expects this to contain a Dtool_PyTypedObject.
- registerDynamicType(name: str) TypeHandle
Registers a new type on-the-fly, presumably at runtime. A new
TypeHandleis returned if the typename was not seen before; otherwise the sameTypeHandlethat was last used for this typename is returned.
- static reregisterTypes()
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.
- property root_classes Sequence[TypeHandle]
Returns the nth root class in the system. See
getNumRootClasses().
- property typehandles Sequence[TypeHandle]
Returns the nth
TypeHandlein the system. SeegetNumTypehandles().
- write(out: ostream)
Makes an attempt to format the entire
TypeRegistryin a nice way that shows the derivation tree as intelligently as possible.
