00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 template<class Type>
00018 TypeHandle EventStoreValue<Type>::_type_handle;
00019
00020
00021
00022
00023
00024
00025
00026 INLINE EventParameter::
00027 EventParameter() {
00028 }
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 INLINE EventParameter::
00044 EventParameter(const TypedWritableReferenceCount *ptr) : _ptr((TypedWritableReferenceCount *)ptr) { }
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061 INLINE EventParameter::
00062 EventParameter(const TypedReferenceCount *ptr) : _ptr(new EventStoreTypedRefCount((TypedReferenceCount *)ptr)) { }
00063
00064
00065
00066
00067
00068
00069
00070
00071 INLINE EventParameter::
00072 EventParameter(int value) : _ptr(new EventStoreInt(value)) { }
00073
00074
00075
00076
00077
00078
00079
00080
00081 INLINE EventParameter::
00082 EventParameter(double value) : _ptr(new EventStoreDouble(value)) { }
00083
00084
00085
00086
00087
00088
00089
00090 INLINE EventParameter::
00091 EventParameter(const string &value) : _ptr(new EventStoreString(value)) { }
00092
00093
00094
00095
00096
00097
00098 INLINE EventParameter::
00099 EventParameter(const wstring &value) : _ptr(new EventStoreWstring(value)) { }
00100
00101
00102
00103
00104
00105
00106
00107 INLINE EventParameter::
00108 EventParameter(const EventParameter &other) : _ptr(other._ptr) { }
00109
00110
00111
00112
00113
00114
00115
00116 INLINE EventParameter &EventParameter::
00117 operator = (const EventParameter &other) {
00118 _ptr = other._ptr;
00119 return *this;
00120 }
00121
00122
00123
00124
00125
00126
00127 INLINE EventParameter::
00128 ~EventParameter() {
00129 }
00130
00131
00132
00133
00134
00135
00136
00137 INLINE bool EventParameter::
00138 is_empty() const {
00139 return (_ptr == (TypedWritableReferenceCount *)NULL);
00140 }
00141
00142
00143
00144
00145
00146
00147
00148 INLINE bool EventParameter::
00149 is_int() const {
00150 if (is_empty()) {
00151 return false;
00152 }
00153 return _ptr->is_of_type(EventStoreInt::get_class_type());
00154 }
00155
00156
00157
00158
00159
00160
00161
00162
00163 INLINE int EventParameter::
00164 get_int_value() const {
00165 nassertr(is_int(), 0);
00166
00167
00168
00169 return ((const EventStoreInt *)_ptr.p())->get_value();
00170 }
00171
00172
00173
00174
00175
00176
00177
00178 INLINE bool EventParameter::
00179 is_double() const {
00180 if (is_empty()) {
00181 return false;
00182 }
00183 return _ptr->is_of_type(EventStoreDouble::get_class_type());
00184 }
00185
00186
00187
00188
00189
00190
00191
00192
00193 INLINE double EventParameter::
00194 get_double_value() const {
00195 nassertr(is_double(), 0.0);
00196 return ((const EventStoreDouble *)_ptr.p())->get_value();
00197 }
00198
00199
00200
00201
00202
00203
00204
00205 INLINE bool EventParameter::
00206 is_string() const {
00207 if (is_empty()) {
00208 return false;
00209 }
00210 return _ptr->is_of_type(EventStoreString::get_class_type());
00211 }
00212
00213
00214
00215
00216
00217
00218
00219
00220 INLINE string EventParameter::
00221 get_string_value() const {
00222 nassertr(is_string(), "");
00223 return ((const EventStoreString *)_ptr.p())->get_value();
00224 }
00225
00226
00227
00228
00229
00230
00231
00232 INLINE bool EventParameter::
00233 is_wstring() const {
00234 if (is_empty()) {
00235 return false;
00236 }
00237 return _ptr->is_of_type(EventStoreWstring::get_class_type());
00238 }
00239
00240
00241
00242
00243
00244
00245
00246
00247 INLINE wstring EventParameter::
00248 get_wstring_value() const {
00249 nassertr(is_wstring(), wstring());
00250 return ((const EventStoreWstring *)_ptr.p())->get_value();
00251 }
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262 INLINE bool EventParameter::
00263 is_typed_ref_count() const {
00264 if (is_empty()) {
00265 return false;
00266 }
00267 return _ptr->is_of_type(EventStoreTypedRefCount::get_class_type());
00268 }
00269
00270
00271
00272
00273
00274
00275
00276
00277 INLINE TypedReferenceCount *EventParameter::
00278 get_typed_ref_count_value() const {
00279 nassertr(is_typed_ref_count(), NULL);
00280 return ((const EventStoreTypedRefCount *)_ptr.p())->get_value();
00281 }
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292 INLINE TypedWritableReferenceCount *EventParameter::
00293 get_ptr() const {
00294 return _ptr;
00295 }
00296
00297 INLINE ostream &
00298 operator << (ostream &out, const EventParameter ¶m) {
00299 param.output(out);
00300 return out;
00301 }
00302
00303
00304
00305
00306
00307
00308
00309 INLINE EventStoreValueBase::
00310 EventStoreValueBase() {
00311 }
00312
00313
00314
00315
00316
00317
00318 INLINE EventStoreTypedRefCount::
00319 EventStoreTypedRefCount(const TypedReferenceCount *value) :
00320 _value((TypedReferenceCount *)value)
00321 {
00322 }
00323
00324
00325
00326
00327
00328
00329
00330
00331 INLINE void EventStoreTypedRefCount::
00332 set_value(const TypedReferenceCount *value) {
00333 _value = (TypedReferenceCount *)value;
00334 }
00335
00336
00337
00338
00339
00340
00341
00342 INLINE TypedReferenceCount *EventStoreTypedRefCount::
00343 get_value() const {
00344 return _value;
00345 }
00346
00347
00348
00349
00350
00351
00352 template<class Type>
00353 EventStoreValue<Type>::
00354 EventStoreValue() {
00355 }
00356
00357
00358
00359
00360
00361
00362 template<class Type>
00363 EventStoreValue<Type>::
00364 EventStoreValue(const Type &value) :
00365 _value(value)
00366 {
00367 }
00368
00369
00370
00371
00372
00373
00374 template<class Type>
00375 EventStoreValue<Type>::
00376 ~EventStoreValue() {
00377 }
00378
00379
00380
00381
00382
00383
00384
00385
00386 template<class Type>
00387 INLINE void EventStoreValue<Type>::
00388 set_value(const Type &value) {
00389 _value = value;
00390 }
00391
00392
00393
00394
00395
00396
00397
00398 template<class Type>
00399 INLINE const Type &EventStoreValue<Type>::
00400 get_value() const {
00401 return _value;
00402 }
00403
00404
00405
00406
00407
00408
00409 template<class Type>
00410 void EventStoreValue<Type>::
00411 output(ostream &out) const {
00412 out << _value;
00413 }
00414
00415
00416
00417
00418
00419
00420
00421 template<class Type>
00422 void EventStoreValue<Type>::
00423 register_with_read_factory() {
00424 BamReader::get_factory()->register_factory(get_class_type(), make_from_bam);
00425 }
00426
00427
00428
00429
00430
00431
00432
00433 template<class Type>
00434 void EventStoreValue<Type>::
00435 write_datagram(BamWriter *manager, Datagram &dg) {
00436 TypedWritable::write_datagram(manager, dg);
00437 generic_write_datagram(dg, _value);
00438 }
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448 template<class Type>
00449 TypedWritable *EventStoreValue<Type>::
00450 make_from_bam(const FactoryParams ¶ms) {
00451 EventStoreValue<Type> *esv = new EventStoreValue<Type>;
00452 DatagramIterator scan;
00453 BamReader *manager;
00454
00455 parse_params(params, scan, manager);
00456 esv->fillin(scan, manager);
00457
00458 return esv;
00459 }
00460
00461
00462
00463
00464
00465
00466
00467
00468 template<class Type>
00469 void EventStoreValue<Type>::
00470 fillin(DatagramIterator &scan, BamReader *manager) {
00471 TypedWritable::fillin(scan, manager);
00472 generic_read_datagram(_value, scan);
00473 }