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
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
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;
00353 long m_msod;
00354 double m_fsod;
00355 };
00356
00357 std::ostream& operator<<(std::ostream& o, const CommonTime& ct);
00358
00359 }
00360
00361 #endif