CommonTime.hpp

Go to the documentation of this file.
00001 #pragma ident "$Id: CommonTime.hpp 1162 2008-03-27 21:18:13Z snelsen $"
00002 
00003 
00004 
00005 #ifndef GPSTK_COMMONTIME_HPP
00006 #define GPSTK_COMMONTIME_HPP
00007 
00008 //============================================================================
00009 //
00010 //  This file is part of GPSTk, the GPS Toolkit.
00011 //
00012 //  The GPSTk is free software; you can redistribute it and/or modify
00013 //  it under the terms of the GNU Lesser General Public License as published
00014 //  by the Free Software Foundation; either version 2.1 of the License, or
00015 //  any later version.
00016 //
00017 //  The GPSTk is distributed in the hope that it will be useful,
00018 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 //  GNU Lesser General Public License for more details.
00021 //
00022 //  You should have received a copy of the GNU Lesser General Public
00023 //  License along with GPSTk; if not, write to the Free Software Foundation,
00024 //  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025 //  
00026 //  Copyright 2004, The University of Texas at Austin
00027 //
00028 //============================================================================
00029 
00030 #include "Exception.hpp"
00031 
00032 namespace gpstk
00033 {
00057    class CommonTime
00058    {
00059      public:
00064 
00065 
00066       static const long BEGIN_LIMIT_JDAY;
00069       static const long END_LIMIT_JDAY;
00071       static const CommonTime BEGINNING_OF_TIME;
00073       static const CommonTime END_OF_TIME;
00074   
00076 
00087       CommonTime( long day = 0, 
00088                   long sod = 0,
00089                   double fsod = 0.0 )
00090          throw( gpstk::InvalidParameter )
00091       { set( day, sod, fsod ); }
00092 
00097       CommonTime( long day,
00098                   double sod )
00099          throw( gpstk::InvalidParameter )
00100       { set( day, sod ); }
00101       
00106       CommonTime( double day )
00107          throw( gpstk::InvalidParameter )
00108       { set( day ); }
00109       
00114       CommonTime( const CommonTime& right )
00115          throw();
00116 
00122       CommonTime& operator=( const CommonTime& right )
00123          throw();
00124       
00126       virtual ~CommonTime()
00127          throw()
00128       {}
00130 
00140       CommonTime& set( long day, 
00141                        long sod,
00142                        double fsod = 0.0 )
00143          throw( gpstk::InvalidParameter );
00144 
00150       CommonTime& set( long day,
00151                        double sod = 0.0 )
00152          throw( gpstk::InvalidParameter );
00153       
00159       CommonTime& set( double day )
00160          throw( gpstk::InvalidParameter );
00161 
00167       CommonTime& setInternal( long day = 0,
00168                                long msod = 0,
00169                                double fsod = 0.0 )
00170          throw( gpstk::InvalidParameter );
00171 
00176       void get( long& day, 
00177                 long& sod,
00178                 double& fsod ) const
00179          throw();
00180 
00185       void get( long& day,
00186                 double& sod ) const
00187          throw();
00188       
00193       void get( double& day ) const
00194          throw();
00195       
00200       void getInternal( long& day,
00201                         long& msod,
00202                         double& fsod ) const
00203          throw()
00204       { day = m_day; msod = m_msod; fsod = m_fsod; }
00205 
00207       double getDays() const 
00208          throw();
00209 
00211       double getSecondOfDay() const
00212          throw();
00213 
00215       
00225       double operator-( const CommonTime& right ) const
00226          throw();
00227       
00234       CommonTime operator+( double seconds ) const
00235          throw( InvalidRequest );
00236       
00244       CommonTime operator-( double seconds ) const
00245          throw( InvalidRequest );
00246       
00253       CommonTime& operator+=( double seconds )
00254          throw( InvalidRequest );
00255       
00262       CommonTime& operator-=( double seconds )
00263          throw( InvalidRequest );
00264       
00272       CommonTime& addSeconds( double seconds )
00273          throw( InvalidRequest );
00274 
00281       CommonTime& addDays( long days )
00282          throw( InvalidRequest );
00283       
00290       CommonTime& addSeconds( long seconds )
00291          throw( InvalidRequest );
00292       
00299       CommonTime& addMilliseconds( long ms )
00300          throw( InvalidRequest );
00302 
00311       bool operator==( const CommonTime& right ) const
00312          throw();
00313       bool operator!=( const CommonTime& right ) const
00314          throw();
00315       bool operator<( const CommonTime& right ) const
00316          throw();
00317       bool operator>( const CommonTime& right ) const
00318          throw();
00319       bool operator<=( const CommonTime& right ) const
00320          throw();
00321       bool operator>=( const CommonTime& right ) const
00322          throw();
00324 
00325       void reset()
00326          throw()
00327       { m_day = m_msod = 0; m_fsod = 0.0; }
00328 
00329       std::string asString() const
00330          throw();
00331 
00332    protected:
00333       
00341       bool add( long days,
00342                 long msod,
00343                 double fsod )
00344          throw();
00345       
00349       bool normalize()
00350          throw();
00351       
00352       long m_day;     //< days (as a Julian Day)     0 <= val < 2^31
00353       long m_msod;    //< milliseconds-of-day        0 <= val < 86400000
00354       double m_fsod;  //< fractional seconds-of-day  0 <= val < 0.001
00355    };
00356 
00357    std::ostream& operator<<(std::ostream& o, const CommonTime& ct);
00358 
00359 } // namespace
00360 
00361 #endif // GPSTK_COMMONTIME_HPP

Generated on Wed Feb 8 03:30:58 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1