Panda3D

- Main Page
- Packages
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Static Public Member Functions

# TypeHandle Class Reference

TypeHandle is the identifier used to differentiate C++ class types. More...

List of all members.

## Public Types
enum | MemoryClass { MCSingleton = 0, MCArray = 1, MCDeletedChainActive = 2, MCDeletedChainInactive = 3, MCLimit = 4 }
## Public Member Functions
| TypeHandle ()
| The default constructor must do nothing, because we can't guarantee ordering of static initializers.
| TypeHandle (TypeHandle const copy)
int | compareTo (TypeHandle const other)
| Sorts TypeHandles arbitrarily (according to <, >, etc.).
| decMemoryUsage (MemoryClass memory_class, int size)
int | getBestParentFromSet (setint const legal_vals)
| Return the Index of the BEst fit Classs from a set.
TypeHandle | getChildClass (int index)
| Returns the nth child class of this type.
unsigned int | getHash ()
| Returns a hash code suitable for phash_map.
int | getIndex ()
| Returns the integer index associated with this TypeHandle.
int | getMemoryUsage (MemoryClass memory_class)
string | getName ()
| Returns the name of the type.
string | getName (TypedObject object)
| Returns the name of the type.
int | getNumChildClasses (TypedObject object)
| Returns the number of child classes that this type is known to have.
int | getNumChildClasses ()
| Returns the number of child classes that this type is known to have.
int | getNumParentClasses ()
| Returns the number of parent classes that this type is known to have.
int | getNumParentClasses (TypedObject object)
| Returns the number of parent classes that this type is known to have.
TypeHandle | getParentClass (int index)
| Returns the nth parent class of this type.
TypeHandle | getParentTowards (TypeHandle ancestor, TypedObject object)
| Returns the parent class that is in a direct line of inheritance to the indicated ancestor class.
TypeHandle | getParentTowards (TypeHandle ancestor)
| Returns the parent class that is in a direct line of inheritance to the indicated ancestor class.
| incMemoryUsage (MemoryClass memory_class, int size)
bool | isDerivedFrom (TypeHandle parent)
| Returns true if this type is derived from the indicated type, false otherwise.
bool | isDerivedFrom (TypeHandle parent, TypedObject object)
| Returns true if this type is derived from the indicated type, false otherwise.
bool | operator!= (TypeHandle const other)
bool | operator< (TypeHandle const other)
bool | operator<= (TypeHandle const other)
bool | operator== (TypeHandle const other)
bool | operator> (TypeHandle const other)
bool | operator>= (TypeHandle const other)
| output (ostream out)
## Static Public Member Functions
static PyObject | make (PyObject classobj)
static TypeHandle | none ()
| Returns a special zero-valued TypeHandle that is used to indicate no type.

## Detailed Description

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.

## Member Enumeration Documentation

enum MemoryClass

Enumerator:

  MCSingleton |
  MCArray |
  MCDeletedChainActive |
  MCDeletedChainInactive |
  MCLimit |

## Constructor & Destructor Documentation

TypeHandle | ( |  | ) |

The default constructor must do nothing, because we can't guarantee ordering of static initializers.

If the constructor tried to initialize its value, it might happen after the value had already been set previously by another static initializer!

TypeHandle | ( | TypeHandle const | copy | ) |

## Member Function Documentation

int compareTo | ( | TypeHandle const | other | ) |

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 | ( | MemoryClass | memory_class,
|  | int | size
| ) |  |

int getBestParentFromSet | ( | setint const | legal_vals | ) |

Return the Index of the BEst fit Classs from a set.

TypeHandle getChildClass | ( | int | index | ) |

Returns the nth child class of this type.

The index should be in the range 0 <= index < get_num_child_classes().

unsigned int getHash | ( |  | ) |

Returns a hash code suitable for phash_map.

int getIndex | ( |  | ) |

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.

int getMemoryUsage | ( | MemoryClass | memory_class | ) |

string getName | ( |  | ) |

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.

string getName | ( | TypedObject | object | ) |

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.

int getNumChildClasses | ( | TypedObject | object | ) |

Returns the number of child classes that this 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.

int getNumChildClasses | ( |  | ) |

Returns the number of child classes that this 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.

int getNumParentClasses | ( | TypedObject | object | ) |

Returns the number of parent classes that this 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.

int getNumParentClasses | ( |  | ) |

Returns the number of parent classes that this 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.

TypeHandle getParentClass | ( | int | index | ) |

Returns the nth parent class of this type.

The index should be in the range 0 <= index < get_num_parent_classes().

TypeHandle getParentTowards | ( | TypeHandle | ancestor,
|  | TypedObject | object
| ) |  |

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.

TypeHandle getParentTowards | ( | TypeHandle | ancestor | ) |

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 | ( | MemoryClass | memory_class,
|  | int | size
| ) |  |

bool isDerivedFrom | ( | TypeHandle | parent | ) |

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.

bool isDerivedFrom | ( | TypeHandle | parent,
|  | TypedObject | object
| ) |  |

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 PyObject make | ( | PyObject | classobj | ) | `[static]`

static TypeHandle none | ( |  | ) | `[static]`

Returns a special zero-valued TypeHandle that is used to indicate no type.

bool operator!= | ( | TypeHandle const | other | ) |

bool operator< | ( | TypeHandle const | other | ) |

bool operator<= | ( | TypeHandle const | other | ) |

bool operator== | ( | TypeHandle const | other | ) |

bool operator> | ( | TypeHandle const | other | ) |

bool operator>= | ( | TypeHandle const | other | ) |

output | ( | ostream | out | ) |

All Classes Namespaces Functions Variables Enumerations Enumerator Properties