Panda3D
 All Classes Functions Variables Enumerations
typedObject.I
1 // Filename: typedObject.I
2 // Created by: drose (11May01)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: TypedObject::Constructor
18 // Access: Public
19 // Description:
20 ////////////////////////////////////////////////////////////////////
21 INLINE TypedObject::
22 TypedObject() {
23 }
24 
25 ////////////////////////////////////////////////////////////////////
26 // Function: TypedObject::Copy Constructor
27 // Access: Public
28 // Description:
29 ////////////////////////////////////////////////////////////////////
30 INLINE TypedObject::
31 TypedObject(const TypedObject &) {
32 }
33 
34 ////////////////////////////////////////////////////////////////////
35 // Function: TypedObject::Copy Assignment Operator
36 // Access: Public
37 // Description:
38 ////////////////////////////////////////////////////////////////////
39 INLINE void TypedObject::
40 operator = (const TypedObject &) {
41 }
42 
43 ////////////////////////////////////////////////////////////////////
44 // Function: TypedObject::get_type_index
45 // Access: Published
46 // Description: Returns the internal index number associated with
47 // this object's TypeHandle, a unique number for each
48 // different type. This is equivalent to
49 // get_type().get_index().
50 ////////////////////////////////////////////////////////////////////
51 INLINE int TypedObject::
52 get_type_index() const {
53  return get_type().get_index();
54 }
55 
56 ////////////////////////////////////////////////////////////////////
57 // Function: TypedObject::is_of_type
58 // Access: Published
59 // Description: Returns true if the current object is or derives from
60 // the indicated type.
61 ////////////////////////////////////////////////////////////////////
62 INLINE bool TypedObject::
63 is_of_type(TypeHandle handle) const {
64  return get_type().is_derived_from(handle, (TypedObject *)this);
65 }
66 
67 ////////////////////////////////////////////////////////////////////
68 // Function: TypedObject::is_exact_type
69 // Access: Published
70 // Description: Returns true if the current object is the indicated
71 // type exactly.
72 ////////////////////////////////////////////////////////////////////
73 INLINE bool TypedObject::
74 is_exact_type(TypeHandle handle) const {
75 #ifndef NDEBUG
76  // Call get_name() to force the type to look itself up if necessary.
77  get_type().get_name((TypedObject *)this);
78 #endif
79  return get_type() == handle;
80 }
81 
82 ////////////////////////////////////////////////////////////////////
83 // Function: TypedObject::get_best_parent_from_Set
84 // Access: Public
85 // Description:
86 ////////////////////////////////////////////////////////////////////
87 INLINE int TypedObject::
88 get_best_parent_from_Set(const std::set<int> &inset) const {
89  return get_type().get_best_parent_from_Set(inset);
90 }
91 
92 ////////////////////////////////////////////////////////////////////
93 // Function: TypedObject::as_typed_object
94 // Access: Public
95 // Description: Returns the object, upcast (if necessary) to a
96 // TypedObject pointer.
97 ////////////////////////////////////////////////////////////////////
100  return this;
101 }
102 
103 ////////////////////////////////////////////////////////////////////
104 // Function: TypedObject::as_typed_object
105 // Access: Public
106 // Description: Returns the object, upcast (if necessary) to a
107 // TypedObject pointer.
108 ////////////////////////////////////////////////////////////////////
109 INLINE const TypedObject *TypedObject::
111  return this;
112 }
113 
bool is_derived_from(TypeHandle parent, TypedObject *object=(TypedObject *) NULL) const
Returns true if this type is derived from the indicated type, false otherwise.
Definition: typeHandle.I:152
int get_index() const
Returns the integer index associated with this TypeHandle.
Definition: typeHandle.I:253
bool is_of_type(TypeHandle handle) const
Returns true if the current object is or derives from the indicated type.
Definition: typedObject.I:63
string get_name(TypedObject *object=(TypedObject *) NULL) const
Returns the name of the type.
Definition: typeHandle.I:132
bool is_exact_type(TypeHandle handle) const
Returns true if the current object is the indicated type exactly.
Definition: typedObject.I:74
This is an abstract class that all classes which use TypeHandle, and also provide virtual functions t...
Definition: typedObject.h:98
int get_type_index() const
Returns the internal index number associated with this object&#39;s TypeHandle, a unique number for each ...
Definition: typedObject.I:52
TypedObject * as_typed_object()
Returns the object, upcast (if necessary) to a TypedObject pointer.
Definition: typedObject.I:99
int get_best_parent_from_Set(const std::set< int > &legal_vals) const
Return the Index of the BEst fit Classs from a set.
Definition: typeHandle.I:294
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85