CommonTime.hpp
Go to the documentation of this file.
1 //==============================================================================
2 //
3 // This file is part of GNSSTk, the ARL:UT GNSS Toolkit.
4 //
5 // The GNSSTk is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published
7 // by the Free Software Foundation; either version 3.0 of the License, or
8 // any later version.
9 //
10 // The GNSSTk is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with GNSSTk; if not, write to the Free Software Foundation,
17 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
18 //
19 // This software was developed by Applied Research Laboratories at the
20 // University of Texas at Austin.
21 // Copyright 2004-2022, The Board of Regents of The University of Texas System
22 //
23 //==============================================================================
24 
25 //==============================================================================
26 //
27 // This software was developed by Applied Research Laboratories at the
28 // University of Texas at Austin, under contract to an agency or agencies
29 // within the U.S. Department of Defense. The U.S. Government retains all
30 // rights to use, duplicate, distribute, disclose, or release this software.
31 //
32 // Pursuant to DoD Directive 523024
33 //
34 // DISTRIBUTION STATEMENT A: This software has been approved for public
35 // release, distribution is unlimited.
36 //
37 //==============================================================================
38 
39 #ifndef GNSSTK_COMMONTIME_HPP
40 #define GNSSTK_COMMONTIME_HPP
41 
42 #include "gnsstk_export.h"
43 #include <memory>
44 #include "Exception.hpp"
45 #include "TimeConstants.hpp"
46 #include "TimeSystem.hpp"
47 #include "TimeSystemConverter.hpp"
48 
49 namespace gnsstk
50 {
52 
53 
84  class CommonTime
85  {
86  public:
91 
95  GNSSTK_EXPORT static const long BEGIN_LIMIT_JDAY;
99  GNSSTK_EXPORT static const long END_LIMIT_JDAY;
100 
102  GNSSTK_EXPORT static const CommonTime BEGINNING_OF_TIME;
104  GNSSTK_EXPORT static const CommonTime END_OF_TIME;
105 
107  GNSSTK_EXPORT static const double eps;
109 
114 
120  explicit CommonTime(TimeSystem timeSystem = TimeSystem::Unknown )
121  { set( 0, 0, 0.0, timeSystem ); }
122 
127  CommonTime( const CommonTime& right );
128 
134  CommonTime& operator=( const CommonTime& right );
135 
137  virtual ~CommonTime()
138  {}
139 
140  //FUTURE DEPRECATION
141  //ALL COMMONTIME ACCESSOR/MUTATOR METHODS ARE SET FOR FUTURE DEPRECATION (PRIVATIZATION)
142  //Accessor/Mutator methods should only be used by TimeTag classes and not made public,
143  //therefore these methods will be deprecated in a future release.
145 
155  //METHOD SET FOR FUTURE DEPRECATION (PRIVATIZATION)
156  CommonTime& set( long day,
157  long sod,
158  double fsod = 0.0,
159  TimeSystem timeSystem = TimeSystem::Unknown );
160 
166  //METHOD SET FOR FUTURE DEPRECATION (PRIVATIZATION)
167  CommonTime& set( long day,
168  double sod = 0.0,
169  TimeSystem timeSystem = TimeSystem::Unknown );
170 
176  //METHOD SET FOR FUTURE DEPRECATION (PRIVATIZATION)
177  CommonTime& set( double day,
178  TimeSystem timeSys = TimeSystem::Unknown );
179 
185  //METHOD SET FOR FUTURE DEPRECATION (PRIVATIZATION)
186  CommonTime& setInternal( long day = 0,
187  long msod = 0,
188  double fsod = 0.0,
189  TimeSystem timeSys = TimeSystem::Unknown );
190 
194  //METHOD SET FOR FUTURE DEPRECATION (PRIVATIZATION)
196  { m_timeSystem = timeSystem; return *this; }
197 
207  bool changeTimeSystem(TimeSystem timeSystem, TimeSystemConverter* conv);
208 
216  bool changeTimeSystem(TimeSystem timeSystem);
217 
222  //METHOD SET FOR FUTURE DEPRECATION (PRIVATIZATION)
223  void get( long& day,
224  long& sod,
225  double& fsod,
226  TimeSystem& timeSystem ) const;
227 
232  //METHOD SET FOR FUTURE DEPRECATION (PRIVATIZATION)
233  void get( long& day,
234  long& sod,
235  double& fsod ) const;
236 
242  //METHOD SET FOR FUTURE DEPRECATION (PRIVATIZATION)
243  void get( long& day,
244  double& sod,
245  TimeSystem& timeSystem ) const;
246 
251  //METHOD SET FOR FUTURE DEPRECATION (PRIVATIZATION)
252  void get( long& day,
253  double& sod ) const;
254 
259  //METHOD SET FOR FUTURE DEPRECATION (PRIVATIZATION)
260  void get( double& day,
261  TimeSystem& timeSystem ) const;
262 
267  //METHOD SET FOR FUTURE DEPRECATION (PRIVATIZATION)
268  void get( double& day ) const;
269 
274  //METHOD SET FOR FUTURE DEPRECATION (PRIVATIZATION)
275  void getInternal( long& day,
276  long& msod,
277  double& fsod,
278  TimeSystem& timeSystem ) const
279  { day = m_day; msod = m_msod; fsod = m_fsod; timeSystem = m_timeSystem; }
280 
285  //METHOD SET FOR FUTURE DEPRECATION (PRIVATIZATION)
286  void getInternal( long& day,
287  long& msod,
288  double& fsod ) const
289  { day = m_day; msod = m_msod; fsod = m_fsod; }
290 
292  //METHOD SET FOR FUTURE DEPRECATION (PRIVATIZATION)
293  double getDays() const;
294 
296  //METHOD SET FOR FUTURE DEPRECATION (PRIVATIZATION)
297  double getSecondOfDay() const;
298 
300  //METHOD SET FOR FUTURE DEPRECATION (PRIVATIZATION)
301  TimeSystem getTimeSystem() const;
302 
304 
314  double operator-( const CommonTime& right ) const;
315 
322  CommonTime operator+( double seconds ) const;
323 
331  CommonTime operator-( double seconds ) const;
332 
339  CommonTime& operator+=( double seconds );
340 
347  CommonTime& operator-=( double seconds );
348 
356  CommonTime& addSeconds( double seconds );
357 
364  CommonTime& addDays( long days );
365 
372  CommonTime& addSeconds( long seconds );
373 
380  CommonTime& addMilliseconds( long ms );
382 
391  bool operator==( const CommonTime& right ) const;
392  bool operator!=( const CommonTime& right ) const;
393  bool operator<( const CommonTime& right ) const;
394  bool operator>( const CommonTime& right ) const;
395  bool operator<=( const CommonTime& right ) const;
396  bool operator>=( const CommonTime& right ) const;
398 
399  void reset()
400  { m_day = m_msod = 0; m_fsod = 0.0; m_timeSystem = TimeSystem::Unknown; }
401 
402  std::string asString() const;
403 
406  GNSSTK_EXPORT static std::shared_ptr<TimeSystemConverter> tsConv;
407 
408  protected:
409 
411  long sod,
412  double fsod,
413  TimeSystem timeSystem = TimeSystem::Unknown )
414  { set( day, sod, fsod, timeSystem ); }
415 
423  bool add( long days,
424  long msod,
425  double fsod );
426 
430  bool normalize();
431 
437  long m_day;
438  long m_msod;
439  double m_fsod;
440 
442 
443  }; // end class CommonTime
444 
445  std::ostream& operator<<(std::ostream& o, const CommonTime& ct);
446 
448 
449 } // namespace
450 
451 #endif // GNSSTK_COMMONTIME_HPP
gnsstk::CommonTime::operator<
bool operator<(const CommonTime &right) const
Definition: CommonTime.cpp:396
TimeSystem.hpp
gnsstk::CommonTime::eps
static const GNSSTK_EXPORT double eps
Default tolerance for time equality in days.
Definition: CommonTime.hpp:107
TimeConstants.hpp
gnsstk::CommonTime::addSeconds
CommonTime & addSeconds(double seconds)
Definition: CommonTime.cpp:332
gnsstk::CommonTime::add
bool add(long days, long msod, double fsod)
Definition: CommonTime.cpp:455
example6.day
day
Definition: example6.py:66
gnsstk::CommonTime::setInternal
CommonTime & setInternal(long day=0, long msod=0, double fsod=0.0, TimeSystem timeSys=TimeSystem::Unknown)
Definition: CommonTime.cpp:153
gnsstk::CommonTime::CommonTime
CommonTime(long day, long sod, double fsod, TimeSystem timeSystem=TimeSystem::Unknown)
Definition: CommonTime.hpp:410
gnsstk::CommonTime::tsConv
static GNSSTK_EXPORT std::shared_ptr< TimeSystemConverter > tsConv
Definition: CommonTime.hpp:406
gnsstk::CommonTime::normalize
bool normalize()
Definition: CommonTime.cpp:466
gnsstk::CommonTime::BEGIN_LIMIT_JDAY
static const GNSSTK_EXPORT long BEGIN_LIMIT_JDAY
Definition: CommonTime.hpp:95
gnsstk::CommonTime::operator>=
bool operator>=(const CommonTime &right) const
Definition: CommonTime.cpp:437
gnsstk::CommonTime::m_msod
long m_msod
milliseconds-of-day 0 <= val < 86400000
Definition: CommonTime.hpp:438
gnsstk::CommonTime::setTimeSystem
CommonTime & setTimeSystem(TimeSystem timeSystem)
Definition: CommonTime.hpp:195
gnsstk::CommonTime::operator!=
bool operator!=(const CommonTime &right) const
Definition: CommonTime.cpp:391
gnsstk::CommonTime::BEGINNING_OF_TIME
static const GNSSTK_EXPORT CommonTime BEGINNING_OF_TIME
earliest representable CommonTime
Definition: CommonTime.hpp:102
gnsstk::CommonTime::CommonTime
CommonTime(TimeSystem timeSystem=TimeSystem::Unknown)
Definition: CommonTime.hpp:120
gnsstk::CommonTime::~CommonTime
virtual ~CommonTime()
Destructor.
Definition: CommonTime.hpp:137
gnsstk::TimeSystem::Unknown
@ Unknown
unknown time frame; for legacy code compatibility
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
gnsstk::CommonTime::operator-=
CommonTime & operator-=(double seconds)
Definition: CommonTime.cpp:326
gnsstk::CommonTime::getInternal
void getInternal(long &day, long &msod, double &fsod, TimeSystem &timeSystem) const
Definition: CommonTime.hpp:275
gnsstk::CommonTime::getSecondOfDay
double getSecondOfDay() const
Obtain the seconds of day (ignoring the day).
Definition: CommonTime.cpp:279
gnsstk::TimeSystemConverter
Definition: TimeSystemConverter.hpp:58
gnsstk::CommonTime::reset
void reset()
Definition: CommonTime.hpp:399
gnsstk::CommonTime::operator+=
CommonTime & operator+=(double seconds)
Definition: CommonTime.cpp:320
gnsstk::CommonTime::END_OF_TIME
static const GNSSTK_EXPORT CommonTime END_OF_TIME
latest representable CommonTime
Definition: CommonTime.hpp:104
gnsstk::CommonTime::operator==
bool operator==(const CommonTime &right) const
Definition: CommonTime.cpp:377
gnsstk::CommonTime::getDays
double getDays() const
Obtain the time, in days, including the fraction of a day.
Definition: CommonTime.cpp:271
TimeSystemConverter.hpp
gnsstk::CommonTime::m_day
long m_day
Definition: CommonTime.hpp:437
gnsstk::operator<<
std::ostream & operator<<(std::ostream &s, const ObsEpoch &oe) noexcept
Definition: ObsEpochMap.cpp:54
gnsstk::CommonTime
Definition: CommonTime.hpp:84
gnsstk::TimeSystem
TimeSystem
Definition of various time systems.
Definition: TimeSystem.hpp:51
gnsstk::CommonTime::operator<=
bool operator<=(const CommonTime &right) const
Definition: CommonTime.cpp:432
gnsstk::CommonTime::get
void get(long &day, long &sod, double &fsod, TimeSystem &timeSystem) const
Definition: CommonTime.cpp:213
gnsstk::CommonTime::END_LIMIT_JDAY
static const GNSSTK_EXPORT long END_LIMIT_JDAY
Definition: CommonTime.hpp:99
gnsstk::CommonTime::m_timeSystem
TimeSystem m_timeSystem
time frame (system representation) of the data
Definition: CommonTime.hpp:441
example6.sod
sod
Definition: example6.py:103
gnsstk::CommonTime::getTimeSystem
TimeSystem getTimeSystem() const
Obtain time system info (enum).
Definition: CommonTime.cpp:288
gnsstk::CommonTime::addMilliseconds
CommonTime & addMilliseconds(long ms)
Definition: CommonTime.cpp:371
Exception.hpp
gnsstk::CommonTime::m_fsod
double m_fsod
fractional seconds-of-day 0 <= val < 0.001
Definition: CommonTime.hpp:439
gnsstk::CommonTime::operator+
CommonTime operator+(double seconds) const
Definition: CommonTime.cpp:310
gnsstk::CommonTime::operator-
double operator-(const CommonTime &right) const
Definition: CommonTime.cpp:293
gnsstk::CommonTime::changeTimeSystem
bool changeTimeSystem(TimeSystem timeSystem, TimeSystemConverter *conv)
Definition: CommonTime.cpp:190
gnsstk::CommonTime::getInternal
void getInternal(long &day, long &msod, double &fsod) const
Definition: CommonTime.hpp:286
gnsstk::CommonTime::operator=
CommonTime & operator=(const CommonTime &right)
Definition: CommonTime.cpp:71
gnsstk::CommonTime::asString
std::string asString() const
Definition: CommonTime.cpp:442
gnsstk::CommonTime::addDays
CommonTime & addDays(long days)
Definition: CommonTime.cpp:365
gnsstk::CommonTime::operator>
bool operator>(const CommonTime &right) const
Definition: CommonTime.cpp:427
gnsstk::CommonTime::set
CommonTime & set(long day, long sod, double fsod=0.0, TimeSystem timeSystem=TimeSystem::Unknown)
Definition: CommonTime.cpp:87


gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:38