00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef TYPEHANDLE_H
00016 #define TYPEHANDLE_H
00017
00018 #include "dtoolbase.h"
00019 #include "typeRegistry.h"
00020
00021 #include <set>
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066 class TypedObject;
00067
00068 #ifdef HAVE_PYTHON
00069 #include "Python.h"
00070 #endif
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090 class EXPCL_DTOOL TypeHandle {
00091 PUBLISHED:
00092 enum MemoryClass {
00093 MC_singleton,
00094 MC_array,
00095 MC_deleted_chain_active,
00096 MC_deleted_chain_inactive,
00097
00098 MC_limit
00099
00100 };
00101
00102 INLINE TypeHandle();
00103 INLINE TypeHandle(const TypeHandle ©);
00104
00105 #ifdef HAVE_PYTHON
00106 static PyObject *make(PyObject *classobj);
00107 #endif // HAVE_PYTHON
00108
00109 INLINE bool operator == (const TypeHandle &other) const;
00110 INLINE bool operator != (const TypeHandle &other) const;
00111 INLINE bool operator < (const TypeHandle &other) const;
00112 INLINE bool operator <= (const TypeHandle &other) const;
00113 INLINE bool operator > (const TypeHandle &other) const;
00114 INLINE bool operator >= (const TypeHandle &other) const;
00115 INLINE int compare_to(const TypeHandle &other) const;
00116 INLINE size_t get_hash() const;
00117
00118 INLINE string get_name(TypedObject *object = (TypedObject *)NULL) const;
00119 INLINE bool is_derived_from(TypeHandle parent,
00120 TypedObject *object = (TypedObject *)NULL) const;
00121
00122 INLINE int get_num_parent_classes(TypedObject *object = (TypedObject *)NULL) const;
00123 INLINE TypeHandle get_parent_class(int index) const;
00124
00125 INLINE int get_num_child_classes(TypedObject *object = (TypedObject *)NULL) const;
00126 INLINE TypeHandle get_child_class(int index) const;
00127
00128 INLINE TypeHandle get_parent_towards(TypeHandle ancestor,
00129 TypedObject *object = (TypedObject *)NULL) const;
00130
00131 INLINE int get_best_parent_from_Set(const std::set< int > &legal_vals) const;
00132
00133 #ifdef DO_MEMORY_USAGE
00134 int get_memory_usage(MemoryClass memory_class) const;
00135 void inc_memory_usage(MemoryClass memory_class, int size);
00136 void dec_memory_usage(MemoryClass memory_class, int size);
00137 #else
00138 INLINE int get_memory_usage(MemoryClass) const { return 0; }
00139 INLINE void inc_memory_usage(MemoryClass, int) { }
00140 INLINE void dec_memory_usage(MemoryClass, int) { }
00141 #endif // DO_MEMORY_USAGE
00142
00143 INLINE int get_index() const;
00144 INLINE void output(ostream &out) const;
00145 INLINE static TypeHandle none();
00146
00147 private:
00148 int _index;
00149 static TypeHandle _none;
00150
00151 friend class TypeRegistry;
00152 };
00153
00154
00155
00156
00157 INLINE ostream &operator << (ostream &out, TypeHandle type) {
00158 type.output(out);
00159 return out;
00160 }
00161
00162 EXPCL_DTOOL ostream &operator << (ostream &out, TypeHandle::MemoryClass mem_class);
00163
00164
00165
00166
00167
00168 #include "typeRegistry.h"
00169
00170 #include "typeHandle.I"
00171
00172 #endif
00173