Flux.h
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
00025
00026
00027 #ifndef Flux_CLASS
00028 #define Flux_CLASS
00029 #include <vector>
00030 #include <iostream>
00031 #include <string>
00032 using namespace std;
00033 #ifndef WITHOUT_ACS
00034 #include <asdmIDLTypesC.h>
00035 using asdmIDLTypes::IDLFlux;
00036 #endif
00037 #include <StringTokenizer.h>
00038 #include <NumberFormatException.h>
00039 using asdm::StringTokenizer;
00040 using asdm::NumberFormatException;
00041 #include "EndianStream.h"
00042 using asdm::EndianOSStream;
00043 using asdm::EndianIStream;
00044 namespace asdm {
00045 class Flux;
00046 Flux operator * ( double , const Flux & );
00047 ostream & operator << ( ostream &, const Flux & );
00048 istream & operator >> ( istream &, Flux &);
00059 class Flux {
00066 friend Flux operator * ( double d, const Flux & x );
00072 friend ostream & operator << ( ostream & os, const Flux & x);
00076 friend istream & operator >> ( istream & is, Flux & x);
00077 public:
00081 Flux();
00085 Flux(const Flux &);
00093 Flux(const string &s);
00094 #ifndef WITHOUT_ACS
00095
00101 Flux(const IDLFlux & idlFlux);
00102 #endif
00103
00107 Flux(double value);
00111 virtual ~Flux();
00116 static double fromString(const string& s);
00123 static string toString(double);
00129 static Flux getFlux(StringTokenizer &st) throw(NumberFormatException);
00130
00135 void toBin(EndianOSStream& eoss);
00141 static void toBin(const vector<Flux>& angle, EndianOSStream& eoss);
00142
00148 static void toBin(const vector<vector<Flux> >& angle, EndianOSStream& eoss);
00149
00155 static void toBin(const vector<vector<vector<Flux> > >& angle, EndianOSStream& eoss);
00162 static Flux fromBin(EndianIStream& eis);
00163
00170 static vector<Flux> from1DBin(EndianIStream & eis);
00171
00178 static vector<vector<Flux> > from2DBin(EndianIStream & eis);
00179
00186 static vector<vector<vector<Flux> > > from3DBin(EndianIStream & eis);
00187
00192 Flux & operator = (const Flux & x);
00193
00198 Flux & operator = (const double d);
00203 Flux & operator += (const Flux & x);
00208 Flux & operator -= (const Flux & x);
00213 Flux & operator *= (const double x);
00218 Flux & operator /= (const double x);
00223 Flux operator + (const Flux & x) const;
00228 Flux operator - (const Flux & x) const;
00233 Flux operator * (const double x) const;
00238 Flux operator / (const double x) const;
00243 bool operator < (const Flux & x) const;
00248 bool operator > (const Flux & x) const;
00253 bool operator <= (const Flux & x) const;
00258 bool operator >= (const Flux & x) const;
00263 bool operator == (const Flux & x) const;
00268 bool equals(const Flux & x) const;
00273 bool operator != (const Flux & x) const;
00278 bool isZero() const;
00282 Flux operator - () const;
00286 Flux operator + () const;
00291 string toString() const;
00295 string toStringI() const;
00300 operator string () const;
00305 double get() const;
00306 #ifndef WITHOUT_ACS
00307
00311 IDLFlux toIDLFlux() const;
00312 #endif
00313
00317 static string unit();
00318 private:
00319 double value;
00320 };
00321
00322 inline Flux::Flux() : value(0.0) {
00323 }
00324 inline Flux::Flux(const Flux &t) : value(t.value) {
00325 }
00326 #ifndef WITHOUT_ACS
00327 inline Flux::Flux(const IDLFlux &l) : value(l.value) {
00328 }
00329 #endif
00330 inline Flux::Flux(const string &s) : value(fromString(s)) {
00331 }
00332 inline Flux::Flux(double v) : value(v) {
00333 }
00334
00335 inline Flux::~Flux() { }
00336
00337 inline Flux & Flux::operator = ( const Flux &t ) {
00338 value = t.value;
00339 return *this;
00340 }
00341
00342 inline Flux & Flux::operator = ( const double v ) {
00343 value = v;
00344 return *this;
00345 }
00346
00347 inline Flux & Flux::operator += ( const Flux & t) {
00348 value += t.value;
00349 return *this;
00350 }
00351 inline Flux & Flux::operator -= ( const Flux & t) {
00352 value -= t.value;
00353 return *this;
00354 }
00355 inline Flux & Flux::operator *= ( const double n) {
00356 value *= n;
00357 return *this;
00358 }
00359 inline Flux & Flux::operator /= ( const double n) {
00360 value /= n;
00361 return *this;
00362 }
00363
00364 inline Flux Flux::operator + ( const Flux &t2 ) const {
00365 Flux tmp;
00366 tmp.value = value + t2.value;
00367 return tmp;
00368 }
00369 inline Flux Flux::operator - ( const Flux &t2 ) const {
00370 Flux tmp;
00371 tmp.value = value - t2.value;
00372 return tmp;
00373 }
00374 inline Flux Flux::operator * ( const double n) const {
00375 Flux tmp;
00376 tmp.value = value * n;
00377 return tmp;
00378 }
00379 inline Flux Flux::operator / ( const double n) const {
00380 Flux tmp;
00381 tmp.value = value / n;
00382 return tmp;
00383 }
00384
00385 inline bool Flux::operator < (const Flux & x) const {
00386 return (value < x.value);
00387 }
00388 inline bool Flux::operator > (const Flux & x) const {
00389 return (value > x.value);
00390 }
00391 inline bool Flux::operator <= (const Flux & x) const {
00392 return (value <= x.value);
00393 }
00394 inline bool Flux::operator >= (const Flux & x) const {
00395 return (value >= x.value);
00396 }
00397 inline bool Flux::equals(const Flux & x) const {
00398 return (value == x.value);
00399 }
00400 inline bool Flux::operator == (const Flux & x) const {
00401 return (value == x.value);
00402 }
00403 inline bool Flux::operator != (const Flux & x) const {
00404 return (value != x.value);
00405 }
00406
00407 inline Flux Flux::operator - () const {
00408 Flux tmp;
00409 tmp.value = -value;
00410 return tmp;
00411 }
00412 inline Flux Flux::operator + () const {
00413 Flux tmp;
00414 tmp.value = value;
00415 return tmp;
00416 }
00417
00418 inline Flux::operator string () const {
00419 return toString();
00420 }
00421 inline string Flux::toString() const {
00422 return toString(value);
00423 }
00424 inline string Flux::toStringI() const {
00425 return toString(value);
00426 }
00427 inline double Flux::get() const {
00428 return value;
00429 }
00430 #ifndef WITHOUT_ACS
00431 inline IDLFlux Flux::toIDLFlux() const {
00432 IDLFlux tmp;
00433 tmp.value = value;
00434 return tmp;
00435 }
00436 #endif
00437
00438 inline Flux operator * ( double n, const Flux &x) {
00439 Flux tmp;
00440 tmp.value = x.value * n;
00441 return tmp;
00442 }
00443 inline ostream & operator << ( ostream &o, const Flux &x ) {
00444 o << x.value;
00445 return o;
00446 }
00447 inline istream & operator >> ( istream &i, Flux &x ) {
00448 i >> x.value;
00449 return i;
00450 }
00451 inline string Flux::unit() {
00452 return string ("jy");
00453 }
00454 }
00455 #endif