This is an abstract class that all classes which use TypeHandle, and also provide virtual functions to support polymorphism, should inherit from. More...
#include "typedObject.h"
Public Member Functions | |
TypedObject (const TypedObject ©)=default | |
TypedObject * | as_typed_object () |
Returns the object, upcast (if necessary) to a TypedObject pointer. More... | |
const TypedObject * | as_typed_object () const |
Returns the object, upcast (if necessary) to a TypedObject pointer. More... | |
virtual TypeHandle | force_init_type ()=0 |
int | get_best_parent_from_Set (const std::set< int > &) const |
virtual TypeHandle | get_type () const =0 |
int | get_type_index () const |
Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. More... | |
bool | is_exact_type (TypeHandle handle) const |
Returns true if the current object is the indicated type exactly. More... | |
bool | is_of_type (TypeHandle handle) const |
Returns true if the current object is or derives from the indicated type. More... | |
TypedObject & | operator= (const TypedObject ©)=default |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static void | init_type () |
This function is declared non-inline to work around a compiler bug in g++ 2.96. More... | |
Public Attributes | |
get_type | |
This is an abstract class that all classes which use TypeHandle, and also provide virtual functions to support polymorphism, should inherit from.
Each derived class should define get_type(), which should return the specific type of the derived class. Inheriting from this automatically provides support for is_of_type() and is_exact_type().
All classes that inherit directly or indirectly from TypedObject should redefine get_type() and force_init_type(), as shown below. Some classes that do not inherit from TypedObject may still declare TypeHandles for themselves by defining methods called get_class_type() and init_type(). Classes such as these may serve as base classes, but the dynamic type identification system will be limited. Classes that do not inherit from TypedObject need not define the virtual functions get_type() and force_init_type() (or any other virtual functions).
There is a specific layout for defining the overrides from this class. Keeping the definitions formatted just like these examples will allow someone in the future to use a sed (or similar) script to make global changes, if necessary. Avoid rearranging the braces or the order of the functions unless you're ready to change them in every file all at once.
What follows are some examples that can be used in new classes that you create.
Definition at line 88 of file typedObject.h.
|
inline |
Returns the object, upcast (if necessary) to a TypedObject pointer.
Definition at line 58 of file typedObject.I.
|
inline |
Returns the object, upcast (if necessary) to a TypedObject pointer.
Definition at line 66 of file typedObject.I.
|
inline |
Returns the internal index number associated with this object's TypeHandle, a unique number for each different type.
This is equivalent to get_type().get_index().
Definition at line 20 of file typedObject.I.
|
static |
This function is declared non-inline to work around a compiler bug in g++ 2.96.
Making it inline seems to cause problems in the optimizer.
Definition at line 44 of file typedObject.cxx.
References register_type().
Referenced by init_libexpress(), and init_libputil().
|
inline |
Returns true if the current object is the indicated type exactly.
Definition at line 38 of file typedObject.I.
Referenced by PortalNode::combine_with(), GeomNode::combine_with(), Character::combine_with(), PandaNode::combine_with(), SpeedTreeNode::combine_with(), and PT().
|
inline |
Returns true if the current object is or derives from the indicated type.
Definition at line 28 of file typedObject.I.
References TypeHandle::is_derived_from().
Referenced by EggSliderData::add_back_pointer(), XFileNode::add_child(), EggGroupNode::apply_first_attribute(), EggGroupNode::apply_last_attribute(), DeferredNodeProperty::apply_to_node(), EggGroupNode::clear_connected_shading(), EggBase::convert_paths(), VirtualFileSimple::copy_file(), GeomTextGlyph::count_geom(), XFile::find_data_object(), XFile::find_template(), EggMaterialCollection::find_used_materials(), EggTextureCollection::find_used_textures(), EggGroupNode::force_filenames(), WindowFramework::get_aspect_2d(), EggGroupUniquifier::get_category(), EggPoolUniquifier::get_category(), EggGroupNode::get_connected_shading(), get_textures_by_filename(), EggGroupNode::has_absolute_pathnames(), PandaFramework::hide_collision_solids(), EggNode::parse_egg(), EggGroupNode::post_apply_flat_attribute(), EggBinner::prepare_node(), PortalClipper::prepare_portal(), PT(), EggMatrixTablePointer::quantize_channels(), ParametricCurveCollection::r_add_curves(), EggGroupNode::rebuild_vertex_pools(), EggGroupNode::remove_invalid_primitives(), EggGroupNode::remove_unused_vertices(), VirtualFileSimple::rename_file(), EggMaterialCollection::replace_materials(), EggTextureCollection::replace_textures(), EggGroupNode::reverse_vertex_ordering(), PandaFramework::show_collision_solids(), EggGroupNode::strip_normals(), DataGraphTraverser::traverse(), EggGroupNode::triangulate_polygons(), EggGroupNode::unify_attributes(), EggNameUniquifier::uniquify(), NodeCullCallbackData::upcall(), and EggToDXFLayer::write_entities().