casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Pressure.h
Go to the documentation of this file.
00001 //Pressure.h generated on 'Thu Feb 04 10:20:05 CET 2010'. Edit at your own risk.
00002 /*
00003  * ALMA - Atacama Large Millimeter Array
00004  * (c) European Southern Observatory, 2002
00005  * (c) Associated Universities Inc., 2002
00006  * Copyright by ESO (in the framework of the ALMA collaboration),
00007  * Copyright by AUI (in the framework of the ALMA collaboration),
00008  * All rights reserved.
00009  * 
00010  * This library is free software; you can redistribute it and/or
00011  * modify it under the terms of the GNU Lesser General Public
00012  * License as published by the Free software Foundation; either
00013  * version 2.1 of the License, or (at your option) any later version.
00014  * 
00015  * This library is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY, without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  * Lesser General Public License for more details.
00019  * 
00020  * You should have received a copy of the GNU Lesser General Public
00021  * License along with this library; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00023  * MA 02111-1307  USA
00024  *
00025  * File Pressure.h
00026  */
00027 #ifndef Pressure_CLASS
00028 #define Pressure_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::IDLPressure;
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 Pressure;
00046 Pressure operator * ( double , const Pressure & );
00047 ostream & operator << ( ostream &, const Pressure & );
00048 istream & operator >> ( istream &, Pressure &);
00059 class Pressure {
00066   friend Pressure operator * ( double d, const Pressure & x );
00072   friend ostream & operator << ( ostream & os, const Pressure & x);
00076   friend istream & operator >> ( istream & is, Pressure & x);
00077 public:
00081         Pressure();
00085         Pressure(const Pressure &);
00093         Pressure(const string &s);
00094 #ifndef WITHOUT_ACS
00095 
00101         Pressure(const IDLPressure & idlPressure);
00102 #endif
00103 
00107         Pressure(double value);
00111         virtual ~Pressure();
00116         static double fromString(const string& s);
00123         static string toString(double);
00129         static Pressure getPressure(StringTokenizer &st) throw(NumberFormatException);
00130                         
00135         void toBin(EndianOSStream& eoss);
00141         static void toBin(const vector<Pressure>& angle,  EndianOSStream& eoss);
00142         
00148         static void toBin(const vector<vector<Pressure> >& angle,  EndianOSStream& eoss);
00149         
00155         static void toBin(const vector<vector<vector<Pressure> > >& angle,  EndianOSStream& eoss);
00162         static Pressure fromBin(EndianIStream& eis);
00163         
00170          static vector<Pressure> from1DBin(EndianIStream & eis);
00171          
00178          static vector<vector<Pressure> > from2DBin(EndianIStream & eis);
00179          
00186          static vector<vector<vector<Pressure> > > from3DBin(EndianIStream & eis);       
00187          
00192          Pressure & operator = (const Pressure & x);
00193          
00198          Pressure & operator = (const double d);
00203         Pressure & operator += (const Pressure & x);
00208         Pressure & operator -= (const Pressure & x);
00213         Pressure & operator *= (const double x);
00218         Pressure & operator /= (const double x);
00223         Pressure operator + (const Pressure & x) const;
00228         Pressure operator - (const Pressure & x) const;
00233         Pressure operator * (const double x) const;
00238         Pressure operator / (const double x) const;
00243         bool operator < (const Pressure & x) const;
00248         bool operator > (const Pressure & x) const;
00253         bool operator <= (const Pressure & x) const;
00258         bool operator >= (const Pressure & x) const;
00263         bool operator == (const Pressure & x) const;
00268         bool equals(const Pressure & x) const;
00273         bool operator != (const Pressure & x) const;
00278         bool isZero() const;
00282         Pressure operator - () const;
00286         Pressure operator + () const;
00291         string toString() const;
00295         string toStringI() const;
00300         operator string () const;
00305         double get() const;
00306 #ifndef WITHOUT_ACS
00307 
00311         IDLPressure toIDLPressure() const;
00312 #endif
00313 
00317         static string unit();
00318 private:
00319         double value;
00320 };
00321 // Pressure constructors
00322 inline Pressure::Pressure() : value(0.0) {
00323 }
00324 inline Pressure::Pressure(const Pressure &t) : value(t.value) {
00325 }
00326 #ifndef WITHOUT_ACS
00327 inline Pressure::Pressure(const IDLPressure &l) : value(l.value) {
00328 }
00329 #endif
00330 inline Pressure::Pressure(const string &s) : value(fromString(s)) {
00331 }
00332 inline Pressure::Pressure(double v) : value(v) {
00333 }
00334 // Pressure destructor
00335 inline Pressure::~Pressure() { }
00336 // assignment operator
00337 inline Pressure & Pressure::operator = ( const Pressure &t ) {
00338         value = t.value;
00339         return *this;
00340 }
00341 // assignment operator
00342 inline Pressure & Pressure::operator = ( const double v ) {
00343         value = v;
00344         return *this;
00345 }
00346 // assignment with arithmetic operators
00347 inline Pressure & Pressure::operator += ( const Pressure & t) {
00348         value += t.value;
00349         return *this;
00350 }
00351 inline Pressure & Pressure::operator -= ( const Pressure & t) {
00352         value -= t.value;
00353         return *this;
00354 }
00355 inline Pressure & Pressure::operator *= ( const double n) {
00356         value *= n;
00357         return *this;
00358 }
00359 inline Pressure & Pressure::operator /= ( const double n) {
00360         value /= n;
00361         return *this;
00362 }
00363 // arithmetic functions
00364 inline Pressure Pressure::operator + ( const Pressure &t2 ) const {
00365         Pressure tmp;
00366         tmp.value = value + t2.value;
00367         return tmp;
00368 }
00369 inline Pressure Pressure::operator - ( const Pressure &t2 ) const {
00370         Pressure tmp;
00371         tmp.value = value - t2.value;
00372         return tmp;
00373 }
00374 inline Pressure Pressure::operator * ( const double n) const {
00375         Pressure tmp;
00376         tmp.value = value * n;
00377         return tmp;
00378 }
00379 inline Pressure Pressure::operator / ( const double n) const {
00380         Pressure tmp;
00381         tmp.value = value / n;
00382         return tmp;
00383 }
00384 // comparison operators
00385 inline bool Pressure::operator < (const Pressure & x) const {
00386         return (value < x.value);
00387 }
00388 inline bool Pressure::operator > (const Pressure & x) const {
00389         return (value > x.value);
00390 }
00391 inline bool Pressure::operator <= (const Pressure & x) const {
00392         return (value <= x.value);
00393 }
00394 inline bool Pressure::operator >= (const Pressure & x) const {
00395         return (value >= x.value);
00396 }
00397 inline bool Pressure::equals(const Pressure & x) const {
00398         return (value == x.value);
00399 }
00400 inline bool Pressure::operator == (const Pressure & x) const {
00401         return (value == x.value);
00402 }
00403 inline bool Pressure::operator != (const Pressure & x) const {
00404         return (value != x.value);
00405 }
00406 // unary - and + operators
00407 inline Pressure Pressure::operator - () const {
00408         Pressure tmp;
00409         tmp.value = -value;
00410         return tmp;
00411 }
00412 inline Pressure Pressure::operator + () const {
00413         Pressure tmp;
00414     tmp.value = value;
00415         return tmp;
00416 }
00417 // Conversion functions
00418 inline Pressure::operator string () const {
00419         return toString();
00420 }
00421 inline string Pressure::toString() const {
00422         return toString(value);
00423 }
00424 inline string Pressure::toStringI() const {
00425         return toString(value);
00426 }
00427 inline double Pressure::get() const {
00428         return value;
00429 }
00430 #ifndef WITHOUT_ACS
00431 inline IDLPressure Pressure::toIDLPressure() const {
00432         IDLPressure tmp;
00433         tmp.value = value;
00434         return tmp;
00435 }
00436 #endif
00437 // Friend functions
00438 inline Pressure operator * ( double n, const Pressure &x) {
00439         Pressure tmp;
00440         tmp.value = x.value * n;
00441         return tmp;
00442 }
00443 inline ostream & operator << ( ostream &o, const Pressure &x ) {
00444         o << x.value;
00445         return o;
00446 }
00447 inline istream & operator >> ( istream &i, Pressure &x ) {
00448         i >> x.value;
00449         return i;
00450 }
00451 inline string Pressure::unit() {
00452         return string ("hPa");
00453 }
00454 } // End namespace asdm
00455 #endif /* Pressure_CLASS */