00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _EXTRAPOLATEDPROPERTY_HH_
00024 #define _EXTRAPOLATEDPROPERTY_HH_
00025
00026 #include <typeinfo>
00027 #include <set>
00028 #include <vector>
00029
00030 #include "property.hh"
00031
00032 #include "bufferedproperty.hh"
00033
00034 #include "propertylistener.hh"
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 class PROPERTY_API ExtrapolatedProperty : public virtual Property
00048 {
00049 protected:
00050 typedef set<ExtrapolatedPropertyListener*, ExtrapolatedListenerSiteWrapper::Cmp> ExtrapolationListenerSet;
00051 ExtrapolationListenerSet extrapolationListeners;
00052 static set<ExtrapolatedProperty*> allexps;
00053 typedef set<ExtrapolatedProperty*> AllExpSet;
00054 vector<double> x;
00055 vector<double> dx;
00056 vector<double> ddx;
00057 double lastCheckpoint;
00058 ExtrapolatedProperty(MetaObject* superobject);
00059 public:
00060 virtual ~ExtrapolatedProperty();
00061 static void registerExtenders();
00062 static void updateAll();
00063 virtual void update();
00064 virtual void set(const vector<double>& x, const vector<double>& dx, const vector<double>& ddx, double t = 0.0) = 0;
00065 static string stringifyVector(const vector<double>& x);
00066 static void stringToVector(const string& prop, vector<double>& x);
00067 void getBase(vector<double>& ax,
00068 vector<double>& adx,
00069 vector<double>& addx);
00070 void getCurrent(vector<double>& ax,
00071 vector<double>& adx,
00072 vector<double>& addx,
00073 double& t);
00074 virtual double now();
00075 virtual void calculatePosition(vector<double>& newx, vector<double>& newdx, double& t);
00076
00077 virtual void notifyObjectExcise(VOS::RefCounted *);
00078 virtual void doExcise();
00079
00080 virtual void addExtrapolationListener(ExtrapolatedPropertyListener* x);
00081 virtual void removeExtrapolationListener(ExtrapolatedPropertyListener* x);
00082 virtual const string getType();
00083
00084
00085
00086
00087
00088
00089 virtual void readRaw(string& target, int start, int length);
00090
00091
00092
00093
00094
00095
00096
00097 virtual void read(string& target, int start, int length);
00098
00099
00100
00101
00102
00103 virtual int getRawLength();
00104
00105
00106
00107
00108
00109
00110
00111 virtual int getLength();
00112
00113
00114
00115
00116 virtual void initialize();
00117
00118
00119
00120
00121
00122
00123
00124 virtual void initialize(unsigned int size, double val = 0.0);
00125
00126
00127
00128
00129 void setVelocity(const vector<double>& val);
00130
00131
00132
00133
00134 void setVelocity(const double val);
00135
00136
00137
00138
00139 void setAcceleration(const vector<double>& val);
00140
00141
00142
00143
00144 void setAcceleration(const double val);
00145
00146
00147
00148
00149 void setPosition(const vector<double>& val);
00150
00151
00152
00153
00154 void setPosition(const double val);
00155
00156
00157 void getCurrentPos(vector<double>& x);
00158
00159
00160 void getVelocity(double& v);
00161
00162
00163 void getVelocity(vector<double>& v);
00164
00165
00166 void getAcceleration(double& a);
00167
00168
00169 void getAcceleration(vector<double>& a);
00170 };
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183 class PROPERTY_API ExtrapolatedLocalProperty : public virtual ExtrapolatedProperty, public virtual BufferedLocalProperty
00184 {
00185 private:
00186 bool extrap_base_changed;
00187 public:
00188 ExtrapolatedLocalProperty(MetaObject* superobject);
00189 ExtrapolatedLocalProperty(MetaObject* superobject, const string& d, const string& dt = "?");
00190 virtual ~ExtrapolatedLocalProperty();
00191 static MetaObject* new_ExtrapolatedLocalProperty(MetaObject* superobject, const string& type);
00192
00193 virtual void set(const vector<double>& x, const vector<double>& dx, const vector<double>& ddx, double t = 0.0);
00194 virtual void write(int start, const string& newdata);
00195 virtual void replace(const string& newdata, const string& newtype = "?");
00196
00197
00198 virtual void readRaw(string& target, int start, int length) {
00199 ExtrapolatedProperty::readRaw(target, start, length);
00200 }
00201 virtual int getRawLength() {
00202 return ExtrapolatedProperty::getRawLength();
00203 }
00204 virtual int getLength() {
00205 return ExtrapolatedProperty::getLength();
00206 }
00207 virtual void read(string& target, int start, int length) {
00208 ExtrapolatedProperty::read(target, start, length);
00209 }
00210
00211
00212
00213
00214 virtual void flush();
00215
00216 virtual void sendMessage(Message* m);
00217
00218
00219
00220
00221
00222 virtual void initialize() {
00223 insertPropertyAccessControl(-1, &NoPropertyAccessControl::static_);
00224 ExtrapolatedProperty::initialize();
00225 }
00226
00227
00228
00229
00230
00231
00232
00233
00234 virtual void initialize(unsigned int size, double val = 0.0) {
00235 insertPropertyAccessControl(-1, &NoPropertyAccessControl::static_);
00236 ExtrapolatedProperty::initialize(size, val);
00237 }
00238 };
00239
00240
00241
00242
00243 class PROPERTY_API ExtrapolatedRemoteProperty : public virtual ExtrapolatedProperty, public virtual BufferedRemoteProperty
00244 {
00245 public:
00246 ExtrapolatedRemoteProperty(MetaObject* superobject);
00247 virtual ~ExtrapolatedRemoteProperty();
00248 static MetaObject* new_ExtrapolatedRemoteProperty(MetaObject* superobject, const string& type);
00249
00250 virtual void set(const vector<double>& x, const vector<double>& dx, const vector<double>& ddx, double t = 0.0);
00251 virtual void sendUpdateMessage(Message* m);
00252
00253 virtual void addExtrapolationListener(ExtrapolatedPropertyListener* x);
00254 virtual void removeExtrapolationListener(ExtrapolatedPropertyListener* x);
00255
00256
00257
00258 virtual void readRaw(string& target, int start, int length) ;
00259
00260
00261
00262 virtual int getRawLength() ;
00263
00264
00265 virtual int getLength() { return ExtrapolatedProperty::getLength(); }
00266 virtual void read(string& target, int start, int length) { ExtrapolatedProperty::read(target, start, length); }
00267
00268 };
00269
00270 #endif