00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef EVENTPARAMETER_H
00016 #define EVENTPARAMETER_H
00017
00018 #include "pandabase.h"
00019
00020 #include "typedef.h"
00021 #include "typedObject.h"
00022 #include "typedWritableReferenceCount.h"
00023 #include "pointerTo.h"
00024 #include "bamReader.h"
00025 #include "bamWriter.h"
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 class EXPCL_PANDA_EVENT EventParameter {
00039 PUBLISHED:
00040 INLINE EventParameter();
00041 INLINE EventParameter(const TypedWritableReferenceCount *ptr);
00042 INLINE EventParameter(const TypedReferenceCount *ptr);
00043 INLINE EventParameter(int value);
00044 INLINE EventParameter(double value);
00045 INLINE EventParameter(const string &value);
00046 INLINE EventParameter(const wstring &value);
00047
00048 INLINE EventParameter(const EventParameter ©);
00049 INLINE EventParameter &operator = (const EventParameter ©);
00050 INLINE ~EventParameter();
00051
00052
00053
00054
00055
00056
00057 INLINE bool is_empty() const;
00058 INLINE bool is_int() const;
00059 INLINE int get_int_value() const;
00060 INLINE bool is_double() const;
00061 INLINE double get_double_value() const;
00062 INLINE bool is_string() const;
00063 INLINE string get_string_value() const;
00064 INLINE bool is_wstring() const;
00065 INLINE wstring get_wstring_value() const;
00066
00067 INLINE bool is_typed_ref_count() const;
00068 INLINE TypedReferenceCount *get_typed_ref_count_value() const;
00069
00070 INLINE TypedWritableReferenceCount *get_ptr() const;
00071
00072 void output(ostream &out) const;
00073
00074 private:
00075 PT(TypedWritableReferenceCount) _ptr;
00076 };
00077
00078 INLINE ostream &operator << (ostream &out, const EventParameter ¶m);
00079
00080
00081
00082
00083
00084
00085
00086 class EXPCL_PANDA_EVENT EventStoreValueBase : public TypedWritableReferenceCount {
00087 public:
00088 INLINE EventStoreValueBase();
00089
00090 PUBLISHED:
00091 virtual ~EventStoreValueBase();
00092 virtual void output(ostream &out) const=0;
00093
00094 public:
00095 virtual TypeHandle get_type() const {
00096 return get_class_type();
00097 }
00098 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00099 static TypeHandle get_class_type() {
00100 return _type_handle;
00101 }
00102 static void init_type() {
00103 TypedWritableReferenceCount::init_type();
00104 register_type(_type_handle, "EventStoreValueBase",
00105 TypedWritableReferenceCount::get_class_type());
00106 }
00107
00108 private:
00109 static TypeHandle _type_handle;
00110 };
00111
00112
00113
00114
00115
00116
00117
00118 class EXPCL_PANDA_EVENT EventStoreTypedRefCount : public EventStoreValueBase {
00119 PUBLISHED:
00120 INLINE EventStoreTypedRefCount(const TypedReferenceCount *value);
00121 virtual ~EventStoreTypedRefCount();
00122
00123 INLINE void set_value(const TypedReferenceCount *value);
00124 INLINE TypedReferenceCount *get_value() const;
00125
00126 virtual void output(ostream &out) const;
00127
00128 public:
00129 PT(TypedReferenceCount) _value;
00130
00131 public:
00132 virtual TypeHandle get_type() const {
00133 return get_class_type();
00134 }
00135 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00136 static TypeHandle get_class_type() {
00137 return _type_handle;
00138 }
00139 static void init_type() {
00140 EventStoreValueBase::init_type();
00141 register_type(_type_handle, "EventStoreTypedRefCount",
00142 EventStoreValueBase::get_class_type());
00143 }
00144
00145 private:
00146 static TypeHandle _type_handle;
00147 };
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158 template<class Type>
00159 class EventStoreValue : public EventStoreValueBase {
00160 private:
00161 INLINE EventStoreValue();
00162 public:
00163 INLINE EventStoreValue(const Type &value);
00164 virtual ~EventStoreValue();
00165
00166 INLINE void set_value(const Type &value);
00167 INLINE const Type &get_value() const;
00168
00169 virtual void output(ostream &out) const;
00170
00171 Type _value;
00172
00173 public:
00174 static void register_with_read_factory();
00175 virtual void write_datagram(BamWriter *manager, Datagram &dg);
00176
00177 protected:
00178 static TypedWritable *make_from_bam(const FactoryParams ¶ms);
00179 void fillin(DatagramIterator &scan, BamReader *manager);
00180
00181 public:
00182 static TypeHandle get_class_type() {
00183 return _type_handle;
00184 }
00185 static void init_type(const string &type_name = "UndefinedEventStoreValue") {
00186 EventStoreValueBase::init_type();
00187 _type_handle = register_dynamic_type
00188 (type_name, EventStoreValueBase::get_class_type());
00189 }
00190 virtual TypeHandle get_type() const {
00191 return get_class_type();
00192 }
00193 virtual TypeHandle force_init_type() {
00194
00195
00196 return get_class_type();
00197 }
00198
00199 private:
00200 static TypeHandle _type_handle;
00201 };
00202
00203 EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_EVENT, EXPTP_PANDA_EVENT, EventStoreValue<int>);
00204 EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_EVENT, EXPTP_PANDA_EVENT, EventStoreValue<double>);
00205 EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_EVENT, EXPTP_PANDA_EVENT, EventStoreValue<std::string>);
00206 EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_EVENT, EXPTP_PANDA_EVENT, EventStoreValue<std::wstring>);
00207
00208 typedef EventStoreValue<int> EventStoreInt;
00209 typedef EventStoreValue<double> EventStoreDouble;
00210 typedef EventStoreValue<string> EventStoreString;
00211 typedef EventStoreValue<wstring> EventStoreWstring;
00212
00213 #include "eventParameter.I"
00214
00215
00216 #ifdef __GNUC__
00217 #pragma interface
00218 #endif
00219
00220 #endif
00221