TypeHandle

from panda3d.core import TypeHandle
class TypeHandle

Bases:

TypeHandle is the identifier used to differentiate C++ class types. 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.

Inheritance diagram

Inheritance diagram of TypeHandle

enum MemoryClass
enumerator MC_singleton = 0
enumerator MC_array = 1
enumerator MC_deleted_chain_active = 2
enumerator MC_deleted_chain_inactive = 3
enumerator MC_limit = 4

Not a real value, just a placeholder for the maximum enum value.

__eq__(other: TypeHandle) bool
__ge__(other: TypeHandle) bool
__gt__(other: TypeHandle) bool
__init__()
__init__(param0: TypeHandle)
__le__(other: TypeHandle) bool
__lt__(other: TypeHandle) bool
__ne__(other: TypeHandle) bool
property child_classes Sequence[TypeHandle]

Returns the nth child class of this type. The index should be in the range 0 <= index < getNumChildClasses().

compareTo(other: TypeHandle) int

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.

decMemoryUsage(memory_class: MemoryClass, size: int)

Subtracts the indicated amount from the record for the total allocated memory for objects of this type.

getBestParentFromSet(legal_vals: set_int) int

Return the Index of the BEst fit Classs from a set

getChildClass(index: int) TypeHandle

Returns the nth child class of this type. The index should be in the range 0 <= index < getNumChildClasses().

getHash() int

Returns a hash code suitable for phash_map.

getIndex() int

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.

getMemoryUsage(memory_class: MemoryClass) int

Returns the total allocated memory used by objects of this type, for the indicated memory class. This is only updated if track-memory-usage is set true in your Config.prc file.

getName(object: TypedObject) str

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.

getNumChildClasses(object: TypedObject) int

Returns the number of child classes that this type is known to have. This may then be used to index into getChildClass().

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(object: TypedObject) int

Returns the number of parent classes that this 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 TypedObject class that owns this TypeHandle. It is only used in case the TypeHandle is inadvertantly undefined.

getParentClass(index: int) TypeHandle

Returns the nth parent class of this type. The index should be in the range 0 <= index < getNumParentClasses().

getParentTowards(ancestor: TypeHandle, object: TypedObject) TypeHandle

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.

incMemoryUsage(memory_class: MemoryClass, size: int)

Adds the indicated amount to the record for the total allocated memory for objects of this type.

property index int

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.

isDerivedFrom(parent: TypeHandle, object: TypedObject) bool

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.

static make(classobj: PyTypeObject) TypeHandle
property name string

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.

static none() TypeHandle
output(out: ostream)
property parent_classes Sequence[TypeHandle]

Returns the nth parent class of this type. The index should be in the range 0 <= index < getNumParentClasses().