TimeTag.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_TIMETAG_HPP
40 #define GNSSTK_TIMETAG_HPP
41 
42 #include "CommonTime.hpp"
43 #include "TimeSystem.hpp"
44 #include "TimeSystemConverter.hpp"
45 #include "StringUtils.hpp"
46 #include <map>
47 
48 namespace gnsstk
49 {
51 
52 
58  class TimeTag
59  {
60  public:
61 
64  {}
65 
67  TimeTag( const TimeSystem& ts )
68  { timeSystem = ts; }
69 
71  virtual ~TimeTag()
72  {}
73 
76  virtual CommonTime convertToCommonTime() const = 0;
77 
80  virtual void convertFromCommonTime( const CommonTime& ct ) = 0;
81 
84  virtual std::string printf( const std::string& fmt ) const = 0;
85 
88  virtual std::string printError( const std::string& fmt ) const = 0;
89 
98  virtual void scanf( const std::string& str,
99  const std::string& fmt );
100 
103  typedef std::map< char, std::string> IdToValue;
104 
115  static void getInfo( const std::string& str,
116  const std::string& fmt,
117  IdToValue& info );
118 
125  virtual bool setFromInfo( const IdToValue& info ) = 0;
126 
129  virtual std::string getPrintChars() const = 0;
130 
132  virtual std::string getDefaultFormat() const = 0;
133 
135  virtual bool isValid() const = 0;
136 
138  virtual void reset() = 0;
139 
142  virtual std::string asString() const
143  { return printf( getDefaultFormat() ); }
144 
147  virtual operator CommonTime() const
148  { return convertToCommonTime(); }
149 
152  static inline std::string getFormatPrefixInt()
153  { return "%[ 0-]?[[:digit:]]*"; }
154 
157  static inline std::string getFormatPrefixFloat()
158  { return getFormatPrefixInt() + "(\\.[[:digit:]]+)?"; }
159 
161  static inline std::string getError()
162  { return "ErrorBadTime"; }
163 
165  void setTimeSystem( const TimeSystem& timeSys )
166  { timeSystem = timeSys; }
167 
170  { return timeSystem ; }
171 
181  bool changeTimeSystem(TimeSystem timeSys, TimeSystemConverter* conv);
182 
190  bool changeTimeSystem(TimeSystem timeSys);
191 
200  static void checkTimeSystem(TimeSystem ts1, TimeSystem ts2);
201 
202  protected:
203 
205  };
206 
208 
209 } // namespace
210 
211 std::ostream& operator<<( std::ostream& s,
212  const gnsstk::TimeTag& t );
213 
214 #endif // GNSSTK_TIMETAG_HPP
gnsstk::TimeTag::getFormatPrefixInt
static std::string getFormatPrefixInt()
Definition: TimeTag.hpp:152
TimeSystem.hpp
gnsstk::TimeTag::convertFromCommonTime
virtual void convertFromCommonTime(const CommonTime &ct)=0
gnsstk::TimeTag::setTimeSystem
void setTimeSystem(const TimeSystem &timeSys)
Set method for internal variable timeSystem (enum).
Definition: TimeTag.hpp:165
gnsstk::TimeTag::IdToValue
std::map< char, std::string > IdToValue
Definition: TimeTag.hpp:103
StringUtils.hpp
gnsstk::TimeTag::getDefaultFormat
virtual std::string getDefaultFormat() const =0
Return a string containing the default format to use in printing.
gnsstk::TimeTag::isValid
virtual bool isValid() const =0
Returns true if this object's members are valid, false otherwise.
gnsstk::TimeTag::getError
static std::string getError()
This returns the default error string for the TimeTag classes.
Definition: TimeTag.hpp:161
gnsstk::TimeTag::getPrintChars
virtual std::string getPrintChars() const =0
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
gnsstk::TimeTag::printError
virtual std::string printError(const std::string &fmt) const =0
gnsstk::TimeTag::timeSystem
TimeSystem timeSystem
time system (representation) of the data
Definition: TimeTag.hpp:204
gnsstk::TimeSystemConverter
Definition: TimeSystemConverter.hpp:58
operator<<
std::ostream & operator<<(std::ostream &s, const gnsstk::TimeTag &t)
Definition: TimeTag.cpp:221
gnsstk::TimeTag
Definition: TimeTag.hpp:58
gnsstk::TimeTag::getFormatPrefixFloat
static std::string getFormatPrefixFloat()
Definition: TimeTag.hpp:157
gnsstk::TimeTag::scanf
virtual void scanf(const std::string &str, const std::string &fmt)
Definition: TimeTag.cpp:44
TimeSystemConverter.hpp
gnsstk::TimeTag::reset
virtual void reset()=0
Reset this object to the default state.
gnsstk::CommonTime
Definition: CommonTime.hpp:84
gnsstk::TimeTag::~TimeTag
virtual ~TimeTag()
Virtual Destructor.
Definition: TimeTag.hpp:71
gnsstk::TimeSystem
TimeSystem
Definition of various time systems.
Definition: TimeSystem.hpp:51
gnsstk::TimeTag::convertToCommonTime
virtual CommonTime convertToCommonTime() const =0
gnsstk::TimeTag::TimeTag
TimeTag(const TimeSystem &ts)
Constructor.
Definition: TimeTag.hpp:67
gnsstk::TimeTag::changeTimeSystem
bool changeTimeSystem(TimeSystem timeSys, TimeSystemConverter *conv)
Definition: TimeTag.cpp:181
gnsstk::TimeTag::getInfo
static void getInfo(const std::string &str, const std::string &fmt, IdToValue &info)
Definition: TimeTag.cpp:66
CommonTime.hpp
gnsstk::TimeTag::printf
virtual std::string printf(const std::string &fmt) const =0
gnsstk::TimeTag::setFromInfo
virtual bool setFromInfo(const IdToValue &info)=0
gnsstk::TimeTag::checkTimeSystem
static void checkTimeSystem(TimeSystem ts1, TimeSystem ts2)
Definition: TimeTag.cpp:207
gnsstk::TimeTag::asString
virtual std::string asString() const
Definition: TimeTag.hpp:142
gnsstk::TimeTag::TimeTag
TimeTag()
Default constructor.
Definition: TimeTag.hpp:63
gnsstk::TimeTag::getTimeSystem
TimeSystem getTimeSystem() const
Obtain time system info (enum).
Definition: TimeTag.hpp:169


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