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