AngularRate.h

00001 /* 00002 * ALMA - Atacama Large Millimeter Array 00003 * (c) European Southern Observatory, 2002 00004 * (c) Associated Universities Inc., 2002 00005 * Copyright by ESO (in the framework of the ALMA collaboration), 00006 * Copyright by AUI (in the framework of the ALMA collaboration), 00007 * All rights reserved. 00008 * 00009 * This library is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU Lesser General Public 00011 * License as published by the Free software Foundation; either 00012 * version 2.1 of the License, or (at your option) any later version. 00013 * 00014 * This library is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY, without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 * Lesser General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU Lesser General Public 00020 * License along with this library; if not, write to the Free Software 00021 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 00022 * MA 02111-1307 USA 00023 * 00024 * File AngularRate.h 00025 */ 00026 00027 #ifndef AngularRate_CLASS 00028 #define AngularRate_CLASS 00029 00030 #include <iostream> 00031 #include <string> 00032 #include <vector> 00033 using namespace std; 00034 00035 #ifndef WITHOUT_ACS 00036 #include <asdmIDLTypesC.h> 00037 using asdmIDLTypes::IDLAngularRate; 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 AngularRate; 00052 AngularRate operator * ( double , const AngularRate & ); 00053 ostream & operator << ( ostream &, const AngularRate & ); 00054 istream & operator >> ( istream &, AngularRate&); 00055 00066 class AngularRate { 00067 friend AngularRate operator * ( double , const AngularRate & ); 00068 friend ostream & operator << ( ostream &, const AngularRate & ); 00069 friend istream & operator >> ( istream &, AngularRate&); 00070 00071 public: 00072 AngularRate(); // default constructor 00073 AngularRate(const AngularRate &); // X const X& constructor 00074 AngularRate(const string &s); 00075 #ifndef WITHOUT_ACS 00076 AngularRate(const IDLAngularRate &); 00077 #endif 00078 AngularRate(double value); 00079 virtual ~AngularRate(); // destructor 00080 static double fromString(const string&); 00081 static string toString(double); 00082 static AngularRate getAngularRate(StringTokenizer &t) throw(NumberFormatException); 00083 00087 void toBin(EndianOSStream& eoss); 00088 00094 static void toBin(const vector<AngularRate>& angularRate, EndianOSStream& eoss); 00095 00101 static void toBin(const vector<vector<AngularRate> >& angularRate, EndianOSStream& eoss); 00102 00108 static void toBin(const vector<vector<vector<AngularRate> > >& angularRate, EndianOSStream& eoss); 00109 00116 static AngularRate fromBin(EndianISStream& eiss); 00117 00124 static vector<AngularRate> from1DBin(EndianISStream & eiss); 00125 00132 static vector<vector<AngularRate> > from2DBin(EndianISStream & eiss); 00133 00140 static vector<vector<vector<AngularRate> > > from3DBin(EndianISStream & eiss); 00141 00142 AngularRate& operator = (const AngularRate&); // assignment operator 00143 AngularRate& operator = (const double); // assignment operator 00144 00145 AngularRate& operator += (const AngularRate&); // assignment with arithmetic 00146 AngularRate& operator -= (const AngularRate&); // operators 00147 AngularRate& operator *= (const double); 00148 AngularRate& operator /= (const double); 00149 00150 AngularRate operator + (const AngularRate&) const; // arithmetic operators 00151 AngularRate operator - (const AngularRate&) const; 00152 AngularRate operator * (const double) const; 00153 AngularRate operator / (const double) const; 00154 00155 bool operator < (const AngularRate&) const; // comparison operators 00156 bool operator > (const AngularRate&) const; 00157 bool operator <= (const AngularRate&) const; 00158 bool operator >= (const AngularRate&) const; 00159 bool operator == (const AngularRate&) const; 00160 bool equals(const AngularRate&) const; 00161 bool operator != (const AngularRate&) const; 00162 00163 bool isZero() const; 00164 00165 AngularRate operator - () const; // unary minus 00166 AngularRate operator + () const; // unary plus 00167 00168 string toString() const; 00169 string toStringI() const; 00170 00171 operator string () const; 00172 double get() const; 00173 #ifndef WITHOUT_ACS 00174 IDLAngularRate toIDLAngularRate() const; 00175 #endif 00176 static string unit(); 00177 00178 private: 00179 double value; 00180 00181 }; 00182 00183 // AngularRate constructors 00184 inline AngularRate::AngularRate() : value(0.0) { 00185 } 00186 00187 inline AngularRate::AngularRate(const AngularRate &t) : value(t.value) { 00188 } 00189 00190 #ifndef WITHOUT_ACS 00191 inline AngularRate::AngularRate(const IDLAngularRate &l) : value(l.value) { 00192 } 00193 #endif 00194 00195 inline AngularRate::AngularRate(const string &s) : value(fromString(s)) { 00196 } 00197 00198 inline AngularRate::AngularRate(double v) : value(v) { 00199 } 00200 00201 // AngularRate destructor 00202 inline AngularRate::~AngularRate() { } 00203 00204 // assignment operator 00205 inline AngularRate& AngularRate::operator = ( const AngularRate &t ) { 00206 value = t.value; 00207 return *this; 00208 } 00209 00210 // assignment operator 00211 inline AngularRate& AngularRate::operator = ( const double v ) { 00212 value = v; 00213 return *this; 00214 } 00215 00216 // assignment with arithmetic operators 00217 inline AngularRate& AngularRate::operator += ( const AngularRate& t) { 00218 value += t.value; 00219 return *this; 00220 } 00221 00222 inline AngularRate& AngularRate::operator -= ( const AngularRate& t) { 00223 value -= t.value; 00224 return *this; 00225 } 00226 00227 inline AngularRate& AngularRate::operator *= ( const double n) { 00228 value *= n; 00229 return *this; 00230 } 00231 00232 inline AngularRate& AngularRate::operator /= ( const double n) { 00233 value /= n; 00234 return *this; 00235 } 00236 00237 // arithmetic functions 00238 inline AngularRate AngularRate::operator + ( const AngularRate &t2 ) const { 00239 AngularRate tmp; 00240 tmp.value = value + t2.value; 00241 return tmp; 00242 } 00243 00244 inline AngularRate AngularRate::operator - ( const AngularRate &t2 ) const { 00245 AngularRate tmp; 00246 tmp.value = value - t2.value; 00247 return tmp; 00248 } 00249 inline AngularRate AngularRate::operator * ( const double n) const { 00250 AngularRate tmp; 00251 tmp.value = value * n; 00252 return tmp; 00253 } 00254 00255 inline AngularRate AngularRate::operator / ( const double n) const { 00256 AngularRate tmp; 00257 tmp.value = value / n; 00258 return tmp; 00259 } 00260 00261 // comparison operators 00262 inline bool AngularRate::operator < (const AngularRate& x) const { 00263 return (value < x.value); 00264 } 00265 00266 inline bool AngularRate::operator > (const AngularRate& x) const { 00267 return (value > x.value); 00268 } 00269 00270 inline bool AngularRate::operator <= (const AngularRate& x) const { 00271 return (value <= x.value); 00272 } 00273 00274 inline bool AngularRate::operator >= (const AngularRate& x) const { 00275 return (value >= x.value); 00276 } 00277 00278 inline bool AngularRate::operator == (const AngularRate& x) const { 00279 return (value == x.value); 00280 } 00281 inline bool AngularRate::equals(const AngularRate& x) const { 00282 return (value == x.value); 00283 } 00284 00285 inline bool AngularRate::operator != (const AngularRate& x) const { 00286 return (value != x.value); 00287 } 00288 00289 // unary - and + operators 00290 inline AngularRate AngularRate::operator - () const { 00291 AngularRate tmp; 00292 tmp.value = -value; 00293 return tmp; 00294 } 00295 00296 inline AngularRate AngularRate::operator + () const { 00297 AngularRate tmp; 00298 tmp.value = value; 00299 return tmp; 00300 } 00301 00302 // Conversion functions 00303 inline AngularRate::operator string () const { 00304 return toString(); 00305 } 00306 00307 inline string AngularRate::toString() const { 00308 return toString(value); 00309 } 00310 00311 inline string AngularRate::toStringI() const { 00312 return toString(value); 00313 } 00314 00315 inline double AngularRate::get() const { 00316 return value; 00317 } 00318 00319 #ifndef WITHOUT_ACS 00320 inline IDLAngularRate AngularRate::toIDLAngularRate() const { 00321 IDLAngularRate tmp; 00322 tmp.value = value; 00323 return tmp; 00324 } 00325 #endif 00326 00327 // Friend functions 00328 00329 inline AngularRate operator * ( double n, const AngularRate &x) { 00330 AngularRate tmp; 00331 tmp.value = x.value * n; 00332 return tmp; 00333 } 00334 00335 inline ostream & operator << ( ostream &o, const AngularRate &x ) { 00336 o << x.value; 00337 return o; 00338 } 00339 00340 inline istream & operator >> ( istream &i, AngularRate &x ) { 00341 i >> x.value; 00342 return i; 00343 } 00344 00345 inline string AngularRate::unit() { 00346 return string ("rad/sec"); 00347 } 00348 00349 } // End namespace asdm 00350 00351 #endif /* AngularRate_CLASS */

Generated on Tue Nov 18 17:43:40 2008 for ASDM C++ Implementation by doxygen 1.3.8