00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef EVENTPARAMETER_H
00020 #define EVENTPARAMETER_H
00021
00022 #include "pandabase.h"
00023
00024 #include "typedef.h"
00025 #include "typedObject.h"
00026 #include "typedReferenceCount.h"
00027 #include "pointerTo.h"
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 class EXPCL_PANDAEXPRESS EventParameter {
00040 PUBLISHED:
00041 INLINE EventParameter();
00042 INLINE EventParameter(const TypedReferenceCount *ptr);
00043 INLINE EventParameter(int value);
00044 INLINE EventParameter(double value);
00045 INLINE EventParameter(const string &value);
00046
00047 INLINE EventParameter(const EventParameter ©);
00048 INLINE EventParameter &operator = (const EventParameter ©);
00049
00050
00051
00052
00053
00054
00055 INLINE bool is_empty() const;
00056 INLINE bool is_int() const;
00057 INLINE int get_int_value() const;
00058 INLINE bool is_double() const;
00059 INLINE double get_double_value() const;
00060 INLINE bool is_string() const;
00061 INLINE string get_string_value() const;
00062
00063 INLINE TypedReferenceCount *get_ptr() const;
00064
00065 void output(ostream &out) const;
00066
00067 private:
00068 PT(TypedReferenceCount) _ptr;
00069 };
00070
00071 INLINE ostream &operator << (ostream &out, const EventParameter ¶m);
00072
00073
00074
00075
00076
00077
00078
00079 class EXPCL_PANDAEXPRESS EventStoreValueBase : public TypedReferenceCount {
00080 public:
00081 virtual void output(ostream &out) const=0;
00082
00083 public:
00084 virtual TypeHandle get_type() const {
00085 return get_class_type();
00086 }
00087 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00088 static TypeHandle get_class_type() {
00089 return _type_handle;
00090 }
00091 static void init_type() {
00092 TypedReferenceCount::init_type();
00093 register_type(_type_handle, "EventStoreValueBase",
00094 TypedReferenceCount::get_class_type());
00095 }
00096
00097 private:
00098 static TypeHandle _type_handle;
00099 };
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110 template<class Type>
00111 class EventStoreValue : public EventStoreValueBase {
00112 public:
00113 EventStoreValue(const Type &value) : _value(value) { }
00114
00115 INLINE void set_value(const Type &value);
00116 INLINE const Type &get_value() const;
00117
00118 virtual void output(ostream &out) const;
00119
00120 Type _value;
00121
00122 public:
00123 static TypeHandle get_class_type() {
00124 return _type_handle;
00125 }
00126 static void init_type(const string &type_name = "UndefinedEventStoreValue") {
00127 EventStoreValueBase::init_type();
00128 _type_handle = register_dynamic_type
00129 (type_name, EventStoreValueBase::get_class_type());
00130 }
00131 virtual TypeHandle get_type() const {
00132 return get_class_type();
00133 }
00134 virtual TypeHandle force_init_type() {
00135
00136
00137 return get_class_type();
00138 }
00139
00140 private:
00141 static TypeHandle _type_handle;
00142 };
00143
00144 EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEXPRESS, EXPTP_PANDAEXPRESS, EventStoreValue<int>);
00145 EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEXPRESS, EXPTP_PANDAEXPRESS, EventStoreValue<double>);
00146 EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEXPRESS, EXPTP_PANDAEXPRESS, EventStoreValue<std::string>);
00147
00148 typedef EventStoreValue<int> EventStoreInt;
00149 typedef EventStoreValue<double> EventStoreDouble;
00150 typedef EventStoreValue<string> EventStoreString;
00151
00152 #include "eventParameter.I"
00153
00154
00155 #ifdef __GNUC__
00156 #pragma interface
00157 #endif
00158
00159 #endif
00160