00001 #pragma ident "$Id: CommonTime.hpp 3180 2012-06-29 19:37:14Z snelsen $"
00002
00003 #ifndef GPSTK_COMMONTIME_HPP
00004 #define GPSTK_COMMONTIME_HPP
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #include "Exception.hpp"
00043 #include "TimeConstants.hpp"
00044 #include "TimeSystem.hpp"
00045
00046 namespace gpstk
00047 {
00071 class CommonTime
00072 {
00073 public:
00078
00081 static const long BEGIN_LIMIT_JDAY;
00084 static const long END_LIMIT_JDAY;
00085
00087 static const CommonTime BEGINNING_OF_TIME;
00089 static const CommonTime END_OF_TIME;
00090
00092 static const double eps;
00094
00100
00106 explicit CommonTime(TimeSystem timeSystem = TimeSystem::Unknown )
00107 throw( InvalidParameter )
00108 { set( 0, 0, 0.0, timeSystem ); }
00109
00114 CommonTime( const CommonTime& right )
00115 throw();
00116
00122 CommonTime& operator=( const CommonTime& right )
00123 throw();
00124
00126 virtual ~CommonTime()
00127 throw()
00128 {}
00129
00131
00141 CommonTime& set( long day,
00142 long sod,
00143 double fsod = 0.0,
00144 TimeSystem timeSystem = TimeSystem::Unknown )
00145 throw( InvalidParameter );
00146
00152 CommonTime& set( long day,
00153 double sod = 0.0,
00154 TimeSystem timeSystem = TimeSystem::Unknown )
00155 throw( InvalidParameter );
00156
00162 CommonTime& set( double day,
00163 TimeSystem timeSys = TimeSystem::Unknown )
00164 throw( InvalidParameter );
00165
00171 CommonTime& setInternal( long day = 0,
00172 long msod = 0,
00173 double fsod = 0.0,
00174 TimeSystem timeSys = TimeSystem::Unknown )
00175 throw( InvalidParameter );
00176
00180 void setTimeSystem( const TimeSystem& timeSystem )
00181 throw()
00182 { m_timeSystem = timeSystem; }
00183
00188 void get( long& day,
00189 long& sod,
00190 double& fsod,
00191 TimeSystem& timeSystem ) const
00192 throw();
00193
00198 void get( long& day,
00199 long& sod,
00200 double& fsod ) const
00201 throw();
00202
00208 void get( long& day,
00209 double& sod,
00210 TimeSystem& timeSystem ) const
00211 throw();
00212
00217 void get( long& day,
00218 double& sod ) const
00219 throw();
00220
00225 void get( double& day,
00226 TimeSystem& timeSystem ) const
00227 throw();
00228
00233 void get( double& day ) const
00234 throw();
00235
00240 void getInternal( long& day,
00241 long& msod,
00242 double& fsod,
00243 TimeSystem& timeSystem ) const
00244 throw()
00245 { day = m_day; msod = m_msod; fsod = m_fsod; timeSystem = m_timeSystem; }
00246
00251 void getInternal( long& day,
00252 long& msod,
00253 double& fsod ) const
00254 throw()
00255 { day = m_day; msod = m_msod; fsod = m_fsod; }
00256
00258 double getDays() const
00259 throw();
00260
00262 double getSecondOfDay() const
00263 throw();
00264
00266 TimeSystem getTimeSystem() const
00267 throw();
00268
00270
00280 double operator-( const CommonTime& right ) const
00281 throw( InvalidRequest );
00282
00289 CommonTime operator+( double seconds ) const
00290 throw();
00291
00299 CommonTime operator-( double seconds ) const
00300 throw();
00301
00308 CommonTime& operator+=( double seconds )
00309 throw();
00310
00317 CommonTime& operator-=( double seconds )
00318 throw();
00319
00327 CommonTime& addSeconds( double seconds )
00328 throw();
00329
00336 CommonTime& addDays( long days )
00337 throw();
00338
00345 CommonTime& addSeconds( long seconds )
00346 throw();
00347
00354 CommonTime& addMilliseconds( long ms )
00355 throw();
00357
00366 bool operator==( const CommonTime& right ) const
00367 throw();
00368 bool operator!=( const CommonTime& right ) const
00369 throw();
00370 bool operator<( const CommonTime& right ) const
00371 throw( InvalidRequest );
00372 bool operator>( const CommonTime& right ) const
00373 throw( InvalidRequest );
00374 bool operator<=( const CommonTime& right ) const
00375 throw( InvalidRequest );
00376 bool operator>=( const CommonTime& right ) const
00377 throw( InvalidRequest );
00379
00380 void reset()
00381 throw()
00382 { m_day = m_msod = 0; m_fsod = 0.0; m_timeSystem = TimeSystem::Unknown; }
00383
00384 std::string asString() const
00385 throw();
00386
00387 protected:
00388
00389 CommonTime( long day,
00390 long sod,
00391 double fsod,
00392 TimeSystem timeSystem = TimeSystem::Unknown )
00393 throw( InvalidParameter )
00394 { set( day, sod, fsod, timeSystem ); }
00395
00403 bool add( long days,
00404 long msod,
00405 double fsod )
00406 throw();
00407
00411 bool normalize()
00412 throw();
00413
00414 long m_day;
00415 long m_msod;
00416 double m_fsod;
00417
00418 TimeSystem m_timeSystem;
00419
00420 };
00421
00422 std::ostream& operator<<(std::ostream& o, const CommonTime& ct);
00423
00424 }
00425
00426 #endif