Panda3D
typedObject.I
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file typedObject.I
10  * @author drose
11  * @date 2001-05-11
12  */
13 
14 /**
15  * Returns the internal index number associated with this object's TypeHandle,
16  * a unique number for each different type. This is equivalent to
17  * get_type().get_index().
18  */
19 INLINE int TypedObject::
20 get_type_index() const {
21  return get_type().get_index();
22 }
23 
24 /**
25  * Returns true if the current object is or derives from the indicated type.
26  */
27 INLINE bool TypedObject::
28 is_of_type(TypeHandle handle) const {
29  // Shortcut for the common case where the type matches exactly.
30  TypeHandle my_type = get_type();
31  return handle == my_type || my_type.is_derived_from(handle, (TypedObject *)this);
32 }
33 
34 /**
35  * Returns true if the current object is the indicated type exactly.
36  */
37 INLINE bool TypedObject::
38 is_exact_type(TypeHandle handle) const {
39 #ifndef NDEBUG
40  // Call get_name() to force the type to look itself up if necessary.
41  get_type().get_name((TypedObject *)this);
42 #endif
43  return get_type() == handle;
44 }
45 
46 /**
47  *
48  */
49 INLINE int TypedObject::
50 get_best_parent_from_Set(const std::set<int> &inset) const {
51  return get_type().get_best_parent_from_Set(inset);
52 }
53 
54 /**
55  * Returns the object, upcast (if necessary) to a TypedObject pointer.
56  */
59  return this;
60 }
61 
62 /**
63  * Returns the object, upcast (if necessary) to a TypedObject pointer.
64  */
65 INLINE const TypedObject *TypedObject::
66 as_typed_object() const {
67  return this;
68 }
bool is_exact_type(TypeHandle handle) const
Returns true if the current object is the indicated type exactly.
Definition: typedObject.I:38
This is an abstract class that all classes which use TypeHandle, and also provide virtual functions t...
Definition: typedObject.h:88
bool is_derived_from(TypeHandle parent, TypedObject *object=nullptr) const
Returns true if this type is derived from the indicated type, false otherwise.
Definition: typeHandle.I:105
TypedObject * as_typed_object()
Returns the object, upcast (if necessary) to a TypedObject pointer.
Definition: typedObject.I:58
bool is_of_type(TypeHandle handle) const
Returns true if the current object is or derives from the indicated type.
Definition: typedObject.I:28
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
int get_type_index() const
Returns the internal index number associated with this object's TypeHandle, a unique number for each ...
Definition: typedObject.I:20