00001 #pragma ident "$Id: TimeTag.hpp 3140 2012-06-18 15:03:02Z susancummins $"
00002
00003 #ifndef GPSTK_TIMETAG_HPP
00004 #define GPSTK_TIMETAG_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 "CommonTime.hpp"
00043 #include "TimeSystem.hpp"
00044 #include "StringUtils.hpp"
00045 #include <map>
00046
00047 namespace gpstk
00048 {
00054 class TimeTag
00055 {
00056 public:
00057
00058
00059 TimeTag()
00060 throw()
00061 {}
00062
00064 TimeTag( TimeSystem ts )
00065 throw()
00066 { timeSystem = ts; }
00067
00069 virtual ~TimeTag()
00070 throw()
00071 {}
00072
00075 virtual CommonTime convertToCommonTime() const
00076 throw( gpstk::InvalidRequest ) = 0;
00077
00080 virtual void convertFromCommonTime( const CommonTime& ct )
00081 throw( gpstk::InvalidRequest ) = 0;
00082
00085 virtual std::string printf( const std::string& fmt ) const
00086 throw( gpstk::StringUtils::StringException ) = 0;
00087
00090 virtual std::string printError( const std::string& fmt ) const
00091 throw( gpstk::StringUtils::StringException ) = 0;
00092
00101 virtual void scanf( const std::string& str,
00102 const std::string& fmt )
00103 throw( gpstk::InvalidRequest,
00104 gpstk::StringUtils::StringException );
00105
00108 typedef std::map< char, std::string> IdToValue;
00109
00120 static void getInfo( const std::string& str,
00121 const std::string& fmt,
00122 IdToValue& info )
00123 throw( gpstk::StringUtils::StringException );
00124
00131 virtual bool setFromInfo( const IdToValue& info )
00132 throw() = 0;
00133
00136 virtual std::string getPrintChars() const
00137 throw() = 0;
00138
00140 virtual std::string getDefaultFormat() const
00141 throw() = 0;
00142
00144 virtual bool isValid() const
00145 throw() = 0;
00146
00148 virtual void reset()
00149 throw() = 0;
00150
00153 virtual std::string asString() const
00154 throw( gpstk::StringUtils::StringException )
00155 { return printf( getDefaultFormat() ); }
00156
00159 virtual operator CommonTime() const
00160 throw( gpstk::InvalidRequest )
00161 { return convertToCommonTime(); }
00162
00165 static inline std::string getFormatPrefixInt()
00166 { return "%[ 0-]?[[:digit:]]*"; }
00167
00170 static inline std::string getFormatPrefixFloat()
00171 { return getFormatPrefixInt() + "(\\.[[:digit:]]+)?"; }
00172
00174 static inline std::string getError()
00175 { return "ErrorBadTime"; }
00176
00178 void setTimeSystem( const TimeSystem& timeSys )
00179 throw()
00180 { timeSystem = timeSys; }
00181
00183 TimeSystem getTimeSystem() const
00184 throw()
00185 { return timeSystem ; }
00186
00187 protected:
00188
00189 TimeSystem timeSystem;
00190 };
00191
00192 }
00193
00194 std::ostream& operator<<( std::ostream& s,
00195 const gpstk::TimeTag& t );
00196
00197 #endif // GPSTK_TIMETAG_HPP