00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef Speed_CLASS
00028 #define Speed_CLASS
00029
00030 #include <vector>
00031 #include <iostream>
00032 #include <string>
00033 using namespace std;
00034
00035 #ifndef WITHOUT_ACS
00036 #include <asdmIDLTypesC.h>
00037 using asdmIDLTypes::IDLSpeed;
00038 #endif
00039
00040 #include <StringTokenizer.h>
00041 #include <NumberFormatException.h>
00042 using asdm::StringTokenizer;
00043 using asdm::NumberFormatException;
00044
00045 #include "EndianStream.h"
00046 using asdm::EndianOSStream;
00047 using asdm::EndianISStream;
00048
00049 namespace asdm {
00050
00051 class Speed;
00052 Speed operator * ( double , const Speed & );
00053 ostream & operator << ( ostream &, const Speed & );
00054 istream & operator >> ( istream &, Speed&);
00055
00065 class Speed {
00066 friend Speed operator * ( double , const Speed & );
00067 friend ostream & operator << ( ostream &, const Speed & );
00068 friend istream & operator >> ( istream &, Speed&);
00069
00070 public:
00071 static double fromString(const string&);
00072 static string toString(double);
00073 static Speed getSpeed(StringTokenizer &t) throw(NumberFormatException);
00074
00078 void toBin(EndianOSStream& eoss);
00079
00085 static void toBin(const vector<Speed>& speed, EndianOSStream& eoss);
00086
00092 static void toBin(const vector<vector<Speed> >& speed, EndianOSStream& eoss);
00093
00099 static void toBin(const vector<vector<vector<Speed> > >& speed, EndianOSStream& eoss);
00100
00107 static Speed fromBin(EndianISStream& eiss);
00108
00115 static vector<Speed> from1DBin(EndianISStream & eiss);
00116
00123 static vector<vector<Speed> > from2DBin(EndianISStream & eiss);
00124
00131 static vector<vector<vector<Speed> > > from3DBin(EndianISStream & eiss);
00132
00133 Speed();
00134 Speed(const Speed &);
00135 Speed(const string &s);
00136 #ifndef WITHOUT_ACS
00137 Speed(const IDLSpeed &);
00138 #endif
00139 Speed(double value);
00140 virtual ~Speed();
00141
00142 Speed& operator = (const Speed&);
00143 Speed& operator = (const double);
00144
00145 Speed& operator += (const Speed&);
00146 Speed& operator -= (const Speed&);
00147 Speed& operator *= (const double);
00148 Speed& operator /= (const double);
00149
00150 Speed operator + (const Speed&) const;
00151 Speed operator - (const Speed&) const;
00152 Speed operator * (const double) const;
00153 Speed operator / (const double) const;
00154
00155 bool operator < (const Speed&) const;
00156 bool operator > (const Speed&) const;
00157 bool operator <= (const Speed&) const;
00158 bool operator >= (const Speed&) const;
00159 bool operator == (const Speed&) const;
00160 bool equals(const Speed&) const;
00161 bool operator != (const Speed&) const;
00162
00163 bool isZero() const;
00164
00165 Speed operator - () const;
00166 Speed operator + () const;
00167
00168 string toString() const;
00169 string toStringI() const;
00170
00171 operator string () const;
00172 double get() const;
00173 #ifndef WITHOUT_ACS
00174 IDLSpeed toIDLSpeed() const;
00175 #endif
00176 static string unit();
00177
00178 private:
00179 double value;
00180
00181 };
00182
00183
00184 inline Speed::Speed() : value(0.0) {
00185 }
00186
00187 inline Speed::Speed(const Speed &t) : value(t.value) {
00188 }
00189
00190 #ifndef WITHOUT_ACS
00191 inline Speed::Speed(const IDLSpeed &l) : value(l.value) {
00192 }
00193 #endif
00194
00195 inline Speed::Speed(const string &s) : value(fromString(s)) {
00196 }
00197
00198 inline Speed::Speed(double v) : value(v) {
00199 }
00200
00201
00202 inline Speed::~Speed() { }
00203
00204
00205 inline Speed& Speed::operator = ( const Speed &t ) {
00206 value = t.value;
00207 return *this;
00208 }
00209
00210
00211 inline Speed& Speed::operator = ( const double v ) {
00212 value = v;
00213 return *this;
00214 }
00215
00216
00217 inline Speed& Speed::operator += ( const Speed& t) {
00218 value += t.value;
00219 return *this;
00220 }
00221
00222 inline Speed& Speed::operator -= ( const Speed& t) {
00223 value -= t.value;
00224 return *this;
00225 }
00226
00227 inline Speed& Speed::operator *= ( const double n) {
00228 value *= n;
00229 return *this;
00230 }
00231
00232 inline Speed& Speed::operator /= ( const double n) {
00233 value /= n;
00234 return *this;
00235 }
00236
00237
00238 inline Speed Speed::operator + ( const Speed &t2 ) const {
00239 Speed tmp;
00240 tmp.value = value + t2.value;
00241 return tmp;
00242 }
00243
00244 inline Speed Speed::operator - ( const Speed &t2 ) const {
00245 Speed tmp;
00246 tmp.value = value - t2.value;
00247 return tmp;
00248 }
00249 inline Speed Speed::operator * ( const double n) const {
00250 Speed tmp;
00251 tmp.value = value * n;
00252 return tmp;
00253 }
00254
00255 inline Speed Speed::operator / ( const double n) const {
00256 Speed tmp;
00257 tmp.value = value / n;
00258 return tmp;
00259 }
00260
00261
00262 inline bool Speed::operator < (const Speed& x) const {
00263 return (value < x.value);
00264 }
00265
00266 inline bool Speed::operator > (const Speed& x) const {
00267 return (value > x.value);
00268 }
00269
00270 inline bool Speed::operator <= (const Speed& x) const {
00271 return (value <= x.value);
00272 }
00273
00274 inline bool Speed::operator >= (const Speed& x) const {
00275 return (value >= x.value);
00276 }
00277
00278 inline bool Speed::operator == (const Speed& x) const {
00279 return (value == x.value);
00280 }
00281 inline bool Speed::equals(const Speed& x) const {
00282 return (value == x.value);
00283 }
00284
00285 inline bool Speed::operator != (const Speed& x) const {
00286 return (value != x.value);
00287 }
00288
00289
00290 inline Speed Speed::operator - () const {
00291 Speed tmp;
00292 tmp.value = -value;
00293 return tmp;
00294 }
00295
00296 inline Speed Speed::operator + () const {
00297 Speed tmp;
00298 tmp.value = value;
00299 return tmp;
00300 }
00301
00302
00303 inline Speed::operator string () const {
00304 return toString();
00305 }
00306
00307 inline string Speed::toString() const {
00308 return toString(value);
00309 }
00310
00311 inline string Speed::toStringI() const {
00312 return toString(value);
00313 }
00314
00315 inline double Speed::get() const {
00316 return value;
00317 }
00318
00319 #ifndef WITHOUT_ACS
00320 inline IDLSpeed Speed::toIDLSpeed() const {
00321 IDLSpeed tmp;
00322 tmp.value = value;
00323 return tmp;
00324 }
00325 #endif
00326
00327
00328
00329 inline Speed operator * ( double n, const Speed &x) {
00330 Speed tmp;
00331 tmp.value = x.value * n;
00332 return tmp;
00333 }
00334
00335 inline ostream & operator << ( ostream &o, const Speed &x ) {
00336 o << x.value;
00337 return o;
00338 }
00339
00340 inline istream & operator >> ( istream &i, Speed &x ) {
00341 i >> x.value;
00342 return i;
00343 }
00344
00345 inline string Speed::unit() {
00346 return string ("m/sec");
00347 }
00348
00349 }
00350
00351 #endif