LCOV - code coverage report
Current view: top level - alma/ASDM - Temperature.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 25 0.0 %
Date: 2024-10-04 18:58:15 Functions: 0 13 0.0 %

          Line data    Source code
       1             : //Temperature.h generated on 'Thu Feb 04 10:20:05 CET 2010'. Edit at your own risk.
       2             : /*
       3             :  * ALMA - Atacama Large Millimeter Array
       4             :  * (c) European Southern Observatory, 2002
       5             :  * (c) Associated Universities Inc., 2002
       6             :  * Copyright by ESO (in the framework of the ALMA collaboration),
       7             :  * Copyright by AUI (in the framework of the ALMA collaboration),
       8             :  * All rights reserved.
       9             :  * 
      10             :  * This library is free software; you can redistribute it and/or
      11             :  * modify it under the terms of the GNU Lesser General Public
      12             :  * License as published by the Free software Foundation; either
      13             :  * version 2.1 of the License, or (at your option) any later version.
      14             :  * 
      15             :  * This library is distributed in the hope that it will be useful,
      16             :  * but WITHOUT ANY WARRANTY, without even the implied warranty of
      17             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      18             :  * Lesser General Public License for more details.
      19             :  * 
      20             :  * You should have received a copy of the GNU Lesser General Public
      21             :  * License along with this library; if not, write to the Free Software
      22             :  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
      23             :  * MA 02111-1307  USA
      24             :  *
      25             :  * File Temperature.h
      26             :  */
      27             : #ifndef Temperature_CLASS
      28             : #define Temperature_CLASS
      29             : #include <vector>
      30             : #include <iostream>
      31             : #include <string>
      32             : #ifndef WITHOUT_ACS
      33             : #include <asdmIDLTypesC.h>
      34             : #endif
      35             : #include <alma/ASDM/StringTokenizer.h>
      36             : #include <alma/ASDM/NumberFormatException.h>
      37             : #include <alma/ASDM/EndianStream.h>
      38             : namespace asdm {
      39             : class Temperature;
      40             : Temperature operator * ( double , const Temperature & );
      41             : std::ostream & operator << ( std::ostream &, const Temperature & );
      42             : std::istream & operator >> ( std::istream &, Temperature &);
      43             : /**
      44             :  * The Temperature class implements a quantity of temperature in degrees Kelvin..
      45             :  * 
      46             :  * @version 1.00 Jan. 7, 2005
      47             :  * @author Allen Farris
      48             :  * 
      49             :  * @version 1.1 Aug 8, 2006
      50             :  * @author Michel Caillat 
      51             :  * added toBin/fromBin methods.
      52             :  */
      53             : class Temperature {
      54             :   /**
      55             :    * Overloading of multiplication operator.
      56             :    * @param d a value in double precision .
      57             :    * @param x a const reference to a Temperature .
      58             :    * @return a Temperature 
      59             :    */
      60             :   friend Temperature operator * ( double d, const Temperature & x );
      61             :   /**
      62             :    * Overloading of << to output the value an Temperature on an ostream.
      63             :    * @param os a reference to the ostream to be written on.
      64             :    * @param x a const reference to a Temperature.
      65             :    */
      66             :   friend std::ostream & operator << ( std::ostream & os, const Temperature & x);
      67             :   /**
      68             :    * Overloading of >> to read an Temperature from an istream.
      69             :    */
      70             :   friend std::istream & operator >> ( std::istream & is, Temperature & x);
      71             : public:
      72             :         /**
      73             :          * The nullary constructor (default).
      74             :          */
      75             :         Temperature();
      76             :         /**
      77             :          * The copy constructor.
      78             :          */
      79             :         Temperature(const Temperature &);
      80             :         /**
      81             :          * A constructor from a string representation.
      82             :          * The string passed in argument must be parsable into a double precision
      83             :          * number to express the value in radian of the angle.
      84             :          *
      85             :          * @param s a string.
      86             :          */
      87             :         Temperature(const std::string &s);
      88             : #ifndef WITHOUT_ACS
      89             :         /**
      90             :          *
      91             :          * A constructor from a CORBA/IDL representation.
      92             :          * 
      93             :          * @param idlTemperature a cons ref to an IDLTemperature.
      94             :          */
      95             :         Temperature(const asdmIDLTypes::IDLTemperature & idlTemperature);
      96             : #endif
      97             :         /**
      98             :          * A constructor from a value in double precision.
      99             :          * The value passed in argument defines the value of the Temperature in radian.
     100             :          */
     101             :         Temperature(double value);
     102             :         /**
     103             :          * The destructor.
     104             :          */
     105             :         virtual ~Temperature();
     106             :         /**
     107             :          * A static method equivalent to the constructor from a string.
     108             :          * @param s a string?.
     109             :          */
     110             :         static double fromString(const std::string& s);
     111             :         /**
     112             :          * Conversion into string.
     113             :          * The resulting string contains the representation of the value of this Temperature.
     114             :          *
     115             :          * @return string
     116             :          */
     117             :         static std::string toString(double);
     118             :         /**
     119             :          * Parse the next (string) token of a StringTokenizer into an angle.
     120             :          * @param st a reference to a StringTokenizer.
     121             :          * @return an Temperature.
     122             :          */
     123             :         static Temperature getTemperature(StringTokenizer &st);
     124             :                         
     125             :         /**
     126             :          * Write the binary representation of this to an EndianOSStream .
     127             :          * @param eoss a reference to an EndianOSStream .
     128             :          */             
     129             :         void toBin(EndianOSStream& eoss);
     130             :         /**
     131             :          * Write the binary representation of a vector of Temperature to a EndianOSStream.
     132             :          * @param angle the vector of Temperature to be written
     133             :          * @param eoss the EndianOSStream to be written to
     134             :          */
     135             :         static void toBin(const std::vector<Temperature>& angle,  EndianOSStream& eoss);
     136             :         
     137             :         /**
     138             :          * Write the binary representation of a vector of vector of Temperature to a EndianOSStream.
     139             :          * @param angle the vector of vector of Temperature to be written
     140             :          * @param eoss the EndianOSStream to be written to
     141             :          */     
     142             :         static void toBin(const std::vector<std::vector<Temperature> >& angle,  EndianOSStream& eoss);
     143             :         
     144             :         /**
     145             :          * Write the binary representation of a vector of vector of vector of Temperature to a EndianOSStream.
     146             :          * @param angle the vector of vector of vector of Temperature to be written
     147             :          * @param eoss the EndianOSStream to be written to
     148             :          */
     149             :         static void toBin(const std::vector<std::vector<std::vector<Temperature> > >& angle,  EndianOSStream& eoss);
     150             :         /**
     151             :          * Read the binary representation of an Temperature from a EndianIStream
     152             :          * and use the read value to set an  Temperature.
     153             :          * @param eis the EndianStream to be read
     154             :          * @return an Temperature
     155             :          */
     156             :         static Temperature fromBin(EndianIStream& eis);
     157             :         
     158             :         /**
     159             :          * Read the binary representation of  a vector of  Temperature from an EndianIStream
     160             :          * and use the read value to set a vector of  Temperature.
     161             :          * @param eis a reference to the EndianIStream to be read
     162             :          * @return a vector of Temperature
     163             :          */      
     164             :          static std::vector<Temperature> from1DBin(EndianIStream & eis);
     165             :          
     166             :         /**
     167             :          * Read the binary representation of  a vector of vector of Temperature from an EndianIStream
     168             :          * and use the read value to set a vector of  vector of Temperature.
     169             :          * @param eis the EndianIStream to be read
     170             :          * @return a vector of vector of Temperature
     171             :          */      
     172             :          static std::vector<std::vector<Temperature> > from2DBin(EndianIStream & eis);
     173             :          
     174             :         /**
     175             :          * Read the binary representation of  a vector of vector of vector of Temperature from an EndianIStream
     176             :          * and use the read value to set a vector of  vector of vector of Temperature.
     177             :          * @param eis the EndianIStream to be read
     178             :          * @return a vector of vector of vector of Temperature
     179             :          */      
     180             :          static std::vector<std::vector<std::vector<Temperature> > > from3DBin(EndianIStream & eis);       
     181             :          
     182             :          /**
     183             :           * An assignment operator Temperature = Temperature.
     184             :           * @param x a const reference to an Temperature.
     185             :           */
     186             :          Temperature & operator = (const Temperature & x);
     187             :          
     188             :          /**
     189             :           * An assignment operator Temperature = double.
     190             :           * @param d a value in double precision.
     191             :           */
     192             :          Temperature & operator = (const double d);
     193             :          /**
     194             :           * Operator increment and assign.
     195             :           * @param x a const reference to an Temperature.
     196             :           */
     197             :         Temperature & operator += (const Temperature & x);
     198             :         /**
     199             :          * Operator decrement and assign.
     200             :          * @param x a const reference to an Temperature.
     201             :          */
     202             :         Temperature & operator -= (const Temperature & x);
     203             :         /**
     204             :          * Operator multiply and assign.
     205             :          * @param x a value in double precision.
     206             :          */
     207             :         Temperature & operator *= (const double x);
     208             :         /**
     209             :          * Operator divide and assign.
     210             :          * @param x a valye in double precision.
     211             :          */
     212             :         Temperature & operator /= (const double x);
     213             :         /**
     214             :          * Addition operator.
     215             :          * @param x a const reference to a Temperature.
     216             :          */
     217             :         Temperature operator + (const Temperature & x) const;
     218             :         /**
     219             :          * Substraction operator.
     220             :          * @param x a const reference to a Temperature.
     221             :          */
     222             :         Temperature operator - (const Temperature & x) const;
     223             :         /**
     224             :          * Multiplication operator.
     225             :          * @param x a value in double precision.
     226             :          */
     227             :         Temperature operator * (const double x) const;
     228             :         /**
     229             :          * Division operator.
     230             :          * @param d a value in double precision.
     231             :          */
     232             :         Temperature operator / (const double x) const;
     233             :         /**
     234             :          * Comparison operator. Less-than.
     235             :          * @param x a const reference to a Temperature.
     236             :          */
     237             :         bool operator < (const Temperature & x) const;
     238             :         /**
     239             :          * Comparison operator. Greater-than.
     240             :          * @param x a const reference to a Temperature.
     241             :          */
     242             :         bool operator > (const Temperature & x) const;
     243             :         /**
     244             :          * Comparison operator. Less-than or equal.
     245             :          * @param x a const reference to a Temperature.
     246             :          */     
     247             :         bool operator <= (const Temperature & x) const;
     248             :         /**
     249             :          * Comparison operator. Greater-than or equal.
     250             :          * @param x a const reference to a Temperature.
     251             :          */
     252             :         bool operator >= (const Temperature & x) const;
     253             :         /**
     254             :          * Comparision operator. Equal-to.
     255             :          * @param x a const reference to a Temperature.
     256             :          */
     257             :         bool operator == (const Temperature & x) const;
     258             :         /** 
     259             :          * Comparison method. Equality.
     260             :          * @param x a const reference to a Temperature.
     261             :          */
     262             :         bool equals(const Temperature & x) const;
     263             :         /**
     264             :          * Comparison operator. Not-equal.
     265             :          * @param x a const reference to a Temperature.
     266             :          */
     267             :         bool operator != (const Temperature & x) const;
     268             :         /**
     269             :          * Comparison method. Test nullity.
     270             :          * @return a bool.
     271             :          */
     272             :         bool isZero() const;
     273             :         /**
     274             :          * Unary operator. Opposite.
     275             :          */
     276             :         Temperature operator - () const;
     277             :         /**
     278             :          * Unary operator. Unary plus.
     279             :          */
     280             :         Temperature operator + () const;
     281             :         /**
     282             :          * Converts into a string.
     283             :          * @return a string containing the representation of a the value in double precision.
     284             :          */
     285             :         std::string toString() const;
     286             :         /** 
     287             :          * Idem toString.
     288             :          */
     289             :         std::string toStringI() const;
     290             :         /**
     291             :          * Conversion operator.
     292             :          * Converts into a string.
     293             :          */
     294             :         operator std::string () const;
     295             :         /**
     296             :          * Return the double precision value of the Temperature.
     297             :          * @return double
     298             :          */
     299             :         double get() const;
     300             : #ifndef WITHOUT_ACS
     301             :         /**
     302             :          * Return the IDLTemperature representation of the Temperature.
     303             :          * @return IDLTemperature 
     304             :          */
     305             :     asdmIDLTypes::IDLTemperature toIDLTemperature() const;
     306             : #endif
     307             :         /**
     308             :          * Returns the abbreviated name of the unit implicitely associated to any Temperature.
     309             :          * @return string
     310             :          */
     311             :         static std::string unit();
     312             : private:
     313             :         double value;
     314             : };
     315             : // Temperature constructors
     316           0 : inline Temperature::Temperature() : value(0.0) {
     317           0 : }
     318           0 : inline Temperature::Temperature(const Temperature &t) : value(t.value) {
     319           0 : }
     320             : #ifndef WITHOUT_ACS
     321             : inline Temperature::Temperature(const asdmIDLTypes::IDLTemperature &l) : value(l.value) {
     322             : }
     323             : #endif
     324           0 : inline Temperature::Temperature(const std::string &s) : value(fromString(s)) {
     325           0 : }
     326           0 : inline Temperature::Temperature(double v) : value(v) {
     327           0 : }
     328             : // Temperature destructor
     329           0 : inline Temperature::~Temperature() { }
     330             : // assignment operator
     331           0 : inline Temperature & Temperature::operator = ( const Temperature &t ) {
     332           0 :         value = t.value;
     333           0 :         return *this;
     334             : }
     335             : // assignment operator
     336             : inline Temperature & Temperature::operator = ( const double v ) {
     337             :         value = v;
     338             :         return *this;
     339             : }
     340             : // assignment with arithmetic operators
     341             : inline Temperature & Temperature::operator += ( const Temperature & t) {
     342             :         value += t.value;
     343             :         return *this;
     344             : }
     345             : inline Temperature & Temperature::operator -= ( const Temperature & t) {
     346             :         value -= t.value;
     347             :         return *this;
     348             : }
     349             : inline Temperature & Temperature::operator *= ( const double n) {
     350             :         value *= n;
     351             :         return *this;
     352             : }
     353             : inline Temperature & Temperature::operator /= ( const double n) {
     354             :         value /= n;
     355             :         return *this;
     356             : }
     357             : // arithmetic functions
     358             : inline Temperature Temperature::operator + ( const Temperature &t2 ) const {
     359             :         Temperature tmp;
     360             :         tmp.value = value + t2.value;
     361             :         return tmp;
     362             : }
     363             : inline Temperature Temperature::operator - ( const Temperature &t2 ) const {
     364             :         Temperature tmp;
     365             :         tmp.value = value - t2.value;
     366             :         return tmp;
     367             : }
     368             : inline Temperature Temperature::operator * ( const double n) const {
     369             :         Temperature tmp;
     370             :         tmp.value = value * n;
     371             :         return tmp;
     372             : }
     373             : inline Temperature Temperature::operator / ( const double n) const {
     374             :         Temperature tmp;
     375             :         tmp.value = value / n;
     376             :         return tmp;
     377             : }
     378             : // comparison operators
     379             : inline bool Temperature::operator < (const Temperature & x) const {
     380             :         return (value < x.value);
     381             : }
     382             : inline bool Temperature::operator > (const Temperature & x) const {
     383             :         return (value > x.value);
     384             : }
     385             : inline bool Temperature::operator <= (const Temperature & x) const {
     386             :         return (value <= x.value);
     387             : }
     388             : inline bool Temperature::operator >= (const Temperature & x) const {
     389             :         return (value >= x.value);
     390             : }
     391             : inline bool Temperature::equals(const Temperature & x) const {
     392             :         return (value == x.value);
     393             : }
     394           0 : inline bool Temperature::operator == (const Temperature & x) const {
     395           0 :         return (value == x.value);
     396             : }
     397           0 : inline bool Temperature::operator != (const Temperature & x) const {
     398           0 :         return (value != x.value);
     399             : }
     400             : // unary - and + operators
     401             : inline Temperature Temperature::operator - () const {
     402             :         Temperature tmp;
     403             :         tmp.value = -value;
     404             :         return tmp;
     405             : }
     406             : inline Temperature Temperature::operator + () const {
     407             :         Temperature tmp;
     408             :     tmp.value = value;
     409             :         return tmp;
     410             : }
     411             : // Conversion functions
     412             : inline Temperature::operator std::string () const {
     413             :         return toString();
     414             : }
     415           0 : inline std::string Temperature::toString() const {
     416           0 :         return toString(value);
     417             : }
     418             : inline std::string Temperature::toStringI() const {
     419             :         return toString(value);
     420             : }
     421           0 : inline double Temperature::get() const {
     422           0 :         return value;
     423             : }
     424             : #ifndef WITHOUT_ACS
     425             : inline asdmIDLTypes::IDLTemperature Temperature::toIDLTemperature() const {
     426             :     asdmIDLTypes::IDLTemperature tmp;
     427             :         tmp.value = value;
     428             :         return tmp;
     429             : }
     430             : #endif
     431             : // Friend functions
     432             : inline Temperature operator * ( double n, const Temperature &x) {
     433             :         Temperature tmp;
     434             :         tmp.value = x.value * n;
     435             :         return tmp;
     436             : }
     437             : inline std::ostream & operator << ( std::ostream &o, const Temperature &x ) {
     438             :         o << x.value;
     439             :         return o;
     440             : }
     441           0 : inline std::istream & operator >> ( std::istream &i, Temperature &x ) {
     442           0 :         i >> x.value;
     443           0 :         return i;
     444             : }
     445           0 : inline std::string Temperature::unit() {
     446           0 :         return std::string ("K");
     447             : }
     448             : } // End namespace asdm
     449             : #endif /* Temperature_CLASS */

Generated by: LCOV version 1.16