Panda3D
|
00001 // Filename: register_type.I 00002 // Created by: drose (06Aug01) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 00016 //////////////////////////////////////////////////////////////////// 00017 // Function: register_type 00018 // Description: This inline function is just a convenient way to call 00019 // TypeRegistry::register_type(), along with zero to four 00020 // record_derivation()s. If for some reason you have a 00021 // class that has more than four base classes (you're 00022 // insane!), then you will need to call Register() and 00023 // record_derivation() yourself. 00024 //////////////////////////////////////////////////////////////////// 00025 INLINE void 00026 register_type(TypeHandle &type_handle, const string &name) { 00027 TypeRegistry::ptr()->register_type(type_handle, name); 00028 } 00029 INLINE void 00030 register_type(TypeHandle &type_handle, const string &name, 00031 TypeHandle parent1) { 00032 if (TypeRegistry::ptr()->register_type(type_handle, name)) { 00033 TypeRegistry::ptr()->record_derivation(type_handle, parent1); 00034 } 00035 } 00036 INLINE void 00037 register_type(TypeHandle &type_handle, const string &name, 00038 TypeHandle parent1, TypeHandle parent2) { 00039 if (TypeRegistry::ptr()->register_type(type_handle, name)) { 00040 TypeRegistry::ptr()->record_derivation(type_handle, parent1); 00041 TypeRegistry::ptr()->record_derivation(type_handle, parent2); 00042 } 00043 } 00044 INLINE void 00045 register_type(TypeHandle &type_handle, const string &name, 00046 TypeHandle parent1, TypeHandle parent2, 00047 TypeHandle parent3) { 00048 if (TypeRegistry::ptr()->register_type(type_handle, name)) { 00049 TypeRegistry::ptr()->record_derivation(type_handle, parent1); 00050 TypeRegistry::ptr()->record_derivation(type_handle, parent2); 00051 TypeRegistry::ptr()->record_derivation(type_handle, parent3); 00052 } 00053 } 00054 INLINE void 00055 register_type(TypeHandle &type_handle, const string &name, 00056 TypeHandle parent1, TypeHandle parent2, 00057 TypeHandle parent3, TypeHandle parent4) { 00058 if (TypeRegistry::ptr()->register_type(type_handle, name)) { 00059 TypeRegistry::ptr()->record_derivation(type_handle, parent1); 00060 TypeRegistry::ptr()->record_derivation(type_handle, parent2); 00061 TypeRegistry::ptr()->record_derivation(type_handle, parent3); 00062 TypeRegistry::ptr()->record_derivation(type_handle, parent4); 00063 } 00064 } 00065 00066 //////////////////////////////////////////////////////////////////// 00067 // Function: register_dynamic_type 00068 // Description: This is essentially similar to register_type(), 00069 // except that it doesn't store a reference to any 00070 // TypeHandle passed in and it therefore doesn't 00071 // complain if the type is registered more than once to 00072 // different TypeHandle reference. 00073 //////////////////////////////////////////////////////////////////// 00074 INLINE TypeHandle 00075 register_dynamic_type(const string &name) { 00076 return TypeRegistry::ptr()->register_dynamic_type(name); 00077 } 00078 INLINE TypeHandle 00079 register_dynamic_type(const string &name, TypeHandle parent1) { 00080 TypeHandle type_handle = 00081 TypeRegistry::ptr()->register_dynamic_type(name); 00082 TypeRegistry::ptr()->record_derivation(type_handle, parent1); 00083 return type_handle; 00084 } 00085 INLINE TypeHandle 00086 register_dynamic_type(const string &name, 00087 TypeHandle parent1, TypeHandle parent2) { 00088 TypeHandle type_handle = 00089 TypeRegistry::ptr()->register_dynamic_type(name); 00090 TypeRegistry::ptr()->record_derivation(type_handle, parent1); 00091 TypeRegistry::ptr()->record_derivation(type_handle, parent2); 00092 return type_handle; 00093 } 00094 INLINE TypeHandle 00095 register_dynamic_type(const string &name, 00096 TypeHandle parent1, TypeHandle parent2, 00097 TypeHandle parent3) { 00098 TypeHandle type_handle = 00099 TypeRegistry::ptr()->register_dynamic_type(name); 00100 TypeRegistry::ptr()->record_derivation(type_handle, parent1); 00101 TypeRegistry::ptr()->record_derivation(type_handle, parent2); 00102 TypeRegistry::ptr()->record_derivation(type_handle, parent3); 00103 return type_handle; 00104 } 00105 INLINE TypeHandle 00106 register_dynamic_type(const string &name, 00107 TypeHandle parent1, TypeHandle parent2, 00108 TypeHandle parent3, TypeHandle parent4) { 00109 TypeHandle type_handle = 00110 TypeRegistry::ptr()->register_dynamic_type(name); 00111 TypeRegistry::ptr()->record_derivation(type_handle, parent1); 00112 TypeRegistry::ptr()->record_derivation(type_handle, parent2); 00113 TypeRegistry::ptr()->record_derivation(type_handle, parent3); 00114 TypeRegistry::ptr()->record_derivation(type_handle, parent4); 00115 return type_handle; 00116 }