00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 INLINE TypeHandle::
00026 TypeHandle() {
00027 }
00028
00029
00030
00031
00032
00033
00034 INLINE TypeHandle::
00035 TypeHandle(const TypeHandle ©) : _index(copy._index) {
00036 }
00037
00038
00039
00040
00041
00042
00043 INLINE bool TypeHandle::
00044 operator == (const TypeHandle &other) const {
00045 return (_index == other._index);
00046 }
00047
00048
00049
00050
00051
00052
00053 INLINE bool TypeHandle::
00054 operator != (const TypeHandle &other) const {
00055 return (_index != other._index);
00056 }
00057
00058
00059
00060
00061
00062
00063 INLINE bool TypeHandle::
00064 operator < (const TypeHandle &other) const {
00065 return (_index < other._index);
00066 }
00067
00068
00069
00070
00071
00072
00073 INLINE bool TypeHandle::
00074 operator <= (const TypeHandle &other) const {
00075 return (_index <= other._index);
00076 }
00077
00078
00079
00080
00081
00082
00083 INLINE bool TypeHandle::
00084 operator > (const TypeHandle &other) const {
00085 return (_index > other._index);
00086 }
00087
00088
00089
00090
00091
00092
00093 INLINE bool TypeHandle::
00094 operator >= (const TypeHandle &other) const {
00095 return (_index >= other._index);
00096 }
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106 INLINE int TypeHandle::
00107 compare_to(const TypeHandle &other) const {
00108 return _index - other._index;
00109 }
00110
00111
00112
00113
00114
00115
00116 INLINE size_t TypeHandle::
00117 get_hash() const {
00118 return (size_t)_index;
00119 }
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131 INLINE string TypeHandle::
00132 get_name(TypedObject *object) const {
00133 if ((*this) == TypeHandle::none()) {
00134 return "none";
00135 } else {
00136 return TypeRegistry::ptr()->get_name(*this, object);
00137 }
00138 }
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151 INLINE bool TypeHandle::
00152 is_derived_from(TypeHandle parent, TypedObject *object) const {
00153 return TypeRegistry::ptr()->is_derived_from(*this, parent, object);
00154 }
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172 INLINE int TypeHandle::
00173 get_num_parent_classes(TypedObject *object) const {
00174 return TypeRegistry::ptr()->get_num_parent_classes(*this, object);
00175 }
00176
00177
00178
00179
00180
00181
00182
00183
00184 INLINE TypeHandle TypeHandle::
00185 get_parent_class(int index) const {
00186 return TypeRegistry::ptr()->get_parent_class(*this, index);
00187 }
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201 INLINE int TypeHandle::
00202 get_num_child_classes(TypedObject *object) const {
00203 return TypeRegistry::ptr()->get_num_child_classes(*this, object);
00204 }
00205
00206
00207
00208
00209
00210
00211
00212
00213 INLINE TypeHandle TypeHandle::
00214 get_child_class(int index) const {
00215 return TypeRegistry::ptr()->get_child_class(*this, index);
00216 }
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236 INLINE TypeHandle TypeHandle::
00237 get_parent_towards(TypeHandle ancestor, TypedObject *object) const {
00238 return TypeRegistry::ptr()->get_parent_towards(*this, ancestor, object);
00239 }
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252 INLINE int TypeHandle::
00253 get_index() const {
00254 return _index;
00255 }
00256
00257
00258
00259
00260
00261
00262 INLINE void TypeHandle::
00263 output(ostream &out) const {
00264 out << get_name();
00265 }
00266
00267
00268
00269
00270
00271
00272
00273 INLINE TypeHandle TypeHandle::
00274 none() {
00275 return _none;
00276 }
00277
00278
00279
00280
00281
00282
00283 INLINE int TypeHandle::get_best_parent_from_Set(const std::set< int > &legal_vals) const
00284 {
00285 if(legal_vals.find(_index) != legal_vals.end())
00286 return _index;
00287
00288 for(int pi = 0; pi < get_num_parent_classes() ; pi++)
00289 {
00290 TypeHandle ph = get_parent_class(pi);
00291 int val = ph.get_best_parent_from_Set(legal_vals);
00292 if(val > 0)
00293 return val;
00294
00295 }
00296 return -1;
00297 }
00298