Panda3D

Loading...
Searching...
No Matches
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 */
21INLINE void
22 register_type(TypeHandle &type_handle, const std::string &name) {
23 TypeRegistry::ptr()->register_type(type_handle, name);
24}
25INLINE void
26 register_type(TypeHandle &type_handle, const std::string &name,
27 TypeHandle parent1) {
28 TypeRegistry *registry = TypeRegistry::ptr();
29 if (registry->register_type(type_handle, name)) {
30 registry->record_derivation(type_handle, parent1);
31 }
32}
33INLINE void
34 register_type(TypeHandle &type_handle, const std::string &name,
35 TypeHandle parent1, TypeHandle parent2) {
36 TypeRegistry *registry = TypeRegistry::ptr();
37 if (registry->register_type(type_handle, name)) {
38 registry->record_derivation(type_handle, parent1);
39 registry->record_derivation(type_handle, parent2);
40 }
41}
42INLINE void
43 register_type(TypeHandle &type_handle, const std::string &name,
44 TypeHandle parent1, TypeHandle parent2,
45 TypeHandle parent3) {
46 TypeRegistry *registry = TypeRegistry::ptr();
47 if (registry->register_type(type_handle, name)) {
48 registry->record_derivation(type_handle, parent1);
49 registry->record_derivation(type_handle, parent2);
50 registry->record_derivation(type_handle, parent3);
51 }
52}
53INLINE void
54 register_type(TypeHandle &type_handle, const std::string &name,
55 TypeHandle parent1, TypeHandle parent2,
56 TypeHandle parent3, TypeHandle parent4) {
57 TypeRegistry *registry = TypeRegistry::ptr();
58 if (registry->register_type(type_handle, name)) {
59 registry->record_derivation(type_handle, parent1);
60 registry->record_derivation(type_handle, parent2);
61 registry->record_derivation(type_handle, parent3);
62 registry->record_derivation(type_handle, parent4);
63 }
64}
65
66/**
67 * This is essentially similar to register_type(), except that it doesn't
68 * store a reference to any TypeHandle passed in and it therefore doesn't
69 * complain if the type is registered more than once to different TypeHandle
70 * reference.
71 */
72INLINE TypeHandle
73 register_dynamic_type(const std::string &name) {
74 return TypeRegistry::ptr()->register_dynamic_type(name);
75}
76INLINE TypeHandle
77 register_dynamic_type(const std::string &name, TypeHandle parent1) {
78 TypeRegistry *registry = TypeRegistry::ptr();
79 TypeHandle type_handle = registry->register_dynamic_type(name);
80 registry->record_derivation(type_handle, parent1);
81 return type_handle;
82}
83INLINE TypeHandle
84 register_dynamic_type(const std::string &name,
85 TypeHandle parent1, TypeHandle parent2) {
86 TypeRegistry *registry = TypeRegistry::ptr();
87 TypeHandle type_handle = registry->register_dynamic_type(name);
88 registry->record_derivation(type_handle, parent1);
89 registry->record_derivation(type_handle, parent2);
90 return type_handle;
91}
92INLINE TypeHandle
93 register_dynamic_type(const std::string &name,
94 TypeHandle parent1, TypeHandle parent2,
95 TypeHandle parent3) {
96 TypeRegistry *registry = TypeRegistry::ptr();
97 TypeHandle type_handle = registry->register_dynamic_type(name);
98 registry->record_derivation(type_handle, parent1);
99 registry->record_derivation(type_handle, parent2);
100 registry->record_derivation(type_handle, parent3);
101 return type_handle;
102}
103INLINE TypeHandle
104 register_dynamic_type(const std::string &name,
105 TypeHandle parent1, TypeHandle parent2,
106 TypeHandle parent3, TypeHandle parent4) {
107 TypeRegistry *registry = TypeRegistry::ptr();
108 TypeHandle type_handle = registry->register_dynamic_type(name);
109 registry->record_derivation(type_handle, parent1);
110 registry->record_derivation(type_handle, parent2);
111 registry->record_derivation(type_handle, parent3);
112 registry->record_derivation(type_handle, parent4);
113 return type_handle;
114}
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
TypeRegistry
The TypeRegistry class maintains all the assigned TypeHandles in a given system.
Definition typeRegistry.h:36
TypeRegistry::register_dynamic_type
TypeHandle register_dynamic_type(const std::string &name)
Registers a new type on-the-fly, presumably at runtime.
Definition typeRegistry.cxx:121
TypeRegistry::record_derivation
void record_derivation(TypeHandle child, TypeHandle parent)
Records that the type referenced by child inherits directly from the type referenced by parent.
Definition typeRegistry.cxx:159
TypeRegistry::ptr
static TypeRegistry * ptr()
Returns the pointer to the global TypeRegistry object.
Definition typeRegistry.I:30
TypeRegistry::register_type
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.
Definition typeRegistry.cxx:39
register_type
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
register_dynamic_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...
Definition register_type.I:73