Panda3D
register_type.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 register_type.I
10  * @author drose
11  * @date 2001-08-06
12  */
13 
14 /**
15  * This inline function is just a convenient way to call
16  * TypeRegistry::register_type(), along with zero to four
17  * record_derivation()s. If for some reason you have a class that has more
18  * than four base classes (you're insane!), then you will need to call
19  * Register() and record_derivation() yourself.
20  */
21 INLINE void
22 register_type(TypeHandle &type_handle, const std::string &name) {
23  TypeRegistry::ptr()->register_type(type_handle, name);
24 }
25 INLINE void
26 register_type(TypeHandle &type_handle, const std::string &name,
27  TypeHandle parent1) {
28  if (TypeRegistry::ptr()->register_type(type_handle, name)) {
29  TypeRegistry::ptr()->record_derivation(type_handle, parent1);
30  }
31 }
32 INLINE void
33 register_type(TypeHandle &type_handle, const std::string &name,
34  TypeHandle parent1, TypeHandle parent2) {
35  if (TypeRegistry::ptr()->register_type(type_handle, name)) {
36  TypeRegistry::ptr()->record_derivation(type_handle, parent1);
37  TypeRegistry::ptr()->record_derivation(type_handle, parent2);
38  }
39 }
40 INLINE void
41 register_type(TypeHandle &type_handle, const std::string &name,
42  TypeHandle parent1, TypeHandle parent2,
43  TypeHandle parent3) {
44  if (TypeRegistry::ptr()->register_type(type_handle, name)) {
45  TypeRegistry::ptr()->record_derivation(type_handle, parent1);
46  TypeRegistry::ptr()->record_derivation(type_handle, parent2);
47  TypeRegistry::ptr()->record_derivation(type_handle, parent3);
48  }
49 }
50 INLINE void
51 register_type(TypeHandle &type_handle, const std::string &name,
52  TypeHandle parent1, TypeHandle parent2,
53  TypeHandle parent3, TypeHandle parent4) {
54  if (TypeRegistry::ptr()->register_type(type_handle, name)) {
55  TypeRegistry::ptr()->record_derivation(type_handle, parent1);
56  TypeRegistry::ptr()->record_derivation(type_handle, parent2);
57  TypeRegistry::ptr()->record_derivation(type_handle, parent3);
58  TypeRegistry::ptr()->record_derivation(type_handle, parent4);
59  }
60 }
61 
62 /**
63  * This is essentially similar to register_type(), except that it doesn't
64  * store a reference to any TypeHandle passed in and it therefore doesn't
65  * complain if the type is registered more than once to different TypeHandle
66  * reference.
67  */
68 INLINE TypeHandle
69 register_dynamic_type(const std::string &name) {
71 }
72 INLINE TypeHandle
73 register_dynamic_type(const std::string &name, TypeHandle parent1) {
74  TypeHandle type_handle =
76  TypeRegistry::ptr()->record_derivation(type_handle, parent1);
77  return type_handle;
78 }
79 INLINE TypeHandle
80 register_dynamic_type(const std::string &name,
81  TypeHandle parent1, TypeHandle parent2) {
82  TypeHandle type_handle =
84  TypeRegistry::ptr()->record_derivation(type_handle, parent1);
85  TypeRegistry::ptr()->record_derivation(type_handle, parent2);
86  return type_handle;
87 }
88 INLINE TypeHandle
89 register_dynamic_type(const std::string &name,
90  TypeHandle parent1, TypeHandle parent2,
91  TypeHandle parent3) {
92  TypeHandle type_handle =
94  TypeRegistry::ptr()->record_derivation(type_handle, parent1);
95  TypeRegistry::ptr()->record_derivation(type_handle, parent2);
96  TypeRegistry::ptr()->record_derivation(type_handle, parent3);
97  return type_handle;
98 }
99 INLINE TypeHandle
100 register_dynamic_type(const std::string &name,
101  TypeHandle parent1, TypeHandle parent2,
102  TypeHandle parent3, TypeHandle parent4) {
103  TypeHandle type_handle =
105  TypeRegistry::ptr()->record_derivation(type_handle, parent1);
106  TypeRegistry::ptr()->record_derivation(type_handle, parent2);
107  TypeRegistry::ptr()->record_derivation(type_handle, parent3);
108  TypeRegistry::ptr()->record_derivation(type_handle, parent4);
109  return type_handle;
110 }
TypeHandle register_dynamic_type(const std::string &name)
Registers a new type on-the-fly, presumably at runtime.
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...
Definition: register_type.I:69
bool register_type(TypeHandle &type_handle, const std::string &name)
Creates a new Type of the given name and assigns a unique value to the type_handle.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22
static TypeRegistry * ptr()
Returns the pointer to the global TypeRegistry object.
Definition: typeRegistry.I:30
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
void record_derivation(TypeHandle child, TypeHandle parent)
Records that the type referenced by child inherits directly from the type referenced by parent.