/home/tetron/hack/vos/libs/vos/vos/propertylistener.hh
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _PROPERTY_LISTENER_HH_
00025 #define _PROPERTY_LISTENER_HH_
00026
00027 #include <vos/vos/vos.hh>
00028 #include <vos/vutil/refcount.hh>
00029 #include <vos/vos/property.hh>
00030
00031 namespace VOS {
00032 class Property;
00033
00034 class PropertyEvent;
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 class VOS_API PropertyListener {
00045 public:
00046 virtual ~PropertyListener() { }
00047
00048
00049
00050
00051
00052 virtual void notifyPropertyChange(const PropertyEvent& event) = 0;
00053 };
00054
00055
00056
00057
00058
00059
00060
00061 class VOS_API PropertyEvent : public VUtil::RefCounted
00062 {
00063 public:
00064 typedef enum {PropertyWrite, PropertyReplace, PropertyRead} EventType;
00065
00066 private:
00067 EventType event;
00068 std::string oldvalue;
00069 std::string newvalue;
00070 std::string olddatatype;
00071 std::string newdatatype;
00072 Vobject* initiator;
00073 Property* property;
00074 int offset;
00075 int length;
00076 bool isACcheck;
00077
00078 public:
00079 PropertyEvent(EventType et, Vobject* init, Property& property,
00080 const std::string& value,
00081 const std::string& datatype,
00082 bool isACcheck);
00083 PropertyEvent(EventType et, Vobject* init, Property& property,
00084 const std::string& value,
00085 const std::string& datatype,
00086 const std::string& oldvalue,
00087 const std::string& olddatatype,
00088 bool isACcheck);
00089 PropertyEvent(EventType et, Vobject* init, Property& property,
00090 int offset,
00091 int length,
00092 const std::string& value,
00093 const std::string& datatype,
00094 bool isACcheck);
00095 PropertyEvent(EventType et, Vobject* init, Property& property,
00096 int offset,
00097 int length,
00098 const std::string& value,
00099 const std::string& datatype,
00100 const std::string& oldvalue,
00101 const std::string& olddatatype,
00102 bool isACcheck);
00103
00104 virtual ~PropertyEvent();
00105
00106
00107 EventType getEvent() const { return event; }
00108
00109
00110
00111
00112
00113 VUtil::vRef<Vobject> getInitiator() const { return VUtil::vRef<Vobject>(initiator, true); }
00114
00115
00116
00117
00118
00119 VUtil::vRef<Property> getProperty() const;
00120
00121
00122
00123
00124
00125
00126
00127
00128 unsigned int getOffset() const { return offset; }
00129
00130
00131 unsigned int getLength() const { return length; }
00132
00133
00134
00135
00136 const std::string& getOldValue() const { return oldvalue; }
00137
00138
00139
00140
00141 const std::string& getNewValue() const { return newvalue; }
00142
00143
00144
00145
00146 const std::string& getValue() const
00147 { return (isACcheck ? oldvalue : newvalue); }
00148
00149
00150
00151
00152 void setNewValue(const std::string& v) { newvalue = v; }
00153
00154
00155
00156
00157 const std::string& getOldDataType() const { return olddatatype; }
00158
00159
00160
00161
00162 const std::string& getNewDataType() const { return newdatatype; }
00163
00164
00165
00166
00167 const std::string& getDataType() const
00168 { return (isACcheck ? olddatatype : newdatatype); }
00169
00170
00171
00172
00173 void setNewDataType(const std::string& dt) { newdatatype = dt; }
00174
00175 void deliverTo(PropertyListener* pl) { pl->notifyPropertyChange(*this); };
00176 };
00177
00178 #if 0
00179
00180
00181
00182
00183 class VOS_API ExtrapolatedPropertyListener {
00184 public:
00185 virtual void notifyBaseChange(ExtrapolatedProperty& ep,
00186 const std::vector<double>& position,
00187 const std::vector<double>& velocity,
00188 const std::vector<double>& acceleration,
00189 double t) = 0;
00190 virtual void notifyPositionChange(ExtrapolatedProperty& ep,
00191 const std::vector<double>& position,
00192 const std::vector<double>& velocity,
00193 const std::vector<double>& acceleration,
00194 double t) = 0;
00195 };
00196 #endif
00197
00198
00199
00200
00201
00202
00203
00204
00205 class VOS_API DoNothingPropertyListener : public virtual PropertyListener
00206
00207 {
00208 public:
00209 static DoNothingPropertyListener static_;
00210
00211 virtual void notifyPropertyChange(const PropertyEvent& event) {};
00212
00213
00214
00215
00216
00217
00218
00219 };
00220
00221
00222 class VOS_API RemotePropertyListener : public MetaObject, public PropertyListener
00223 {
00224 public:
00225 RemotePropertyListener(VobjectBase* superobject);
00226 virtual ~RemotePropertyListener() { }
00227
00228 virtual void notifyPropertyChange(const PropertyEvent& event);
00229 };
00230
00231 }
00232
00233 #endif