36class EXPCL_DTOOL_DTOOLBASE TypeRegistry :
public MemoryBase {
41 bool register_type(TypeHandle &type_handle,
const std::string &name);
49 void record_python_type(TypeHandle type, PyObject *python_type);
52 TypeHandle
find_type(
const std::string &name)
const;
80 void write(std::ostream &out)
const;
83 static INLINE TypeRegistry *
ptr();
93 static void init_global_pointer();
97 INLINE
void freshen_derivations();
98 void rebuild_derivations();
100 void do_write(std::ostream &out)
const;
101 void write_node(std::ostream &out,
int indent_level,
104 static INLINE
void init_lock();
106 typedef std::vector<TypeRegistryNode *> HandleRegistry;
107 HandleRegistry _handle_registry;
109 typedef std::map<std::string, TypeRegistryNode *> NameRegistry;
110 NameRegistry _name_registry;
112 typedef std::vector<TypeRegistryNode *> RootClasses;
113 RootClasses _root_classes;
115 bool _derivations_fresh;
117 static MutexImpl *_lock;
118 static TypeRegistry *_global_pointer;
120 friend class TypeHandle;
This class is intended to be the base class of all objects in Panda that might be allocated and delet...
TypeHandle is the identifier used to differentiate C++ class types.
int get_best_parent_from_Set(const std::set< int > &legal_vals) const
Return the Index of the BEst fit Classs from a set.
This is a single entry in the TypeRegistry.
get_typehandle
Returns the nth TypeHandle in the system.
get_num_typehandles
Returns the total number of unique TypeHandles in the system.
void record_alternate_name(TypeHandle type, const std::string &name)
Indicates an alternate name for the same type.
TypeHandle find_type_by_id(int id) const
Looks for a previously-registered type with the given id number (as returned by TypeHandle::get_index...
TypeHandle get_parent_class(TypeHandle child, int index) const
Returns the nth parent class of this type.
void write(std::ostream &out) const
Makes an attempt to format the entire TypeRegistry in a nice way that shows the derivation tree as in...
get_num_root_classes
Returns the number of root classes–that is, classes that do not inherit from any other classes–known ...
void record_derivation(TypeHandle child, TypeHandle parent)
Records that the type referenced by child inherits directly from the type referenced by parent.
TypeHandle get_child_class(TypeHandle child, int index) const
Returns the nth child class of this type.
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.
static TypeRegistry * ptr()
Returns the pointer to the global TypeRegistry object.
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.
std::string get_name(TypeHandle type, TypedObject *object) const
Returns the name of the indicated type.
TypeHandle find_type(const std::string &name) const
Looks for a previously-registered type of the given name.
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 indica...
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.
static void reregister_types()
Walks through the TypeRegistry tree and makes sure that each type that was previously registered is *...
get_root_class
Returns the nth root class in the system.
This is an abstract class that all classes which use TypeHandle, and also provide virtual functions t...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
TypeHandle register_dynamic_type(const std::string &name)
This is essentially similar to register_type(), except that it doesn't store a reference to any TypeH...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.