00001 #pragma ident "$Id: TimeTag.hpp 1162 2008-03-27 21:18:13Z snelsen $"
00002
00003
00004
00005 #ifndef GPSTK_TIMETAG_HPP
00006 #define GPSTK_TIMETAG_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 "CommonTime.hpp"
00031 #include "StringUtils.hpp"
00032 #include <map>
00033
00034 namespace gpstk
00035 {
00041 class TimeTag
00042 {
00043 public:
00044
00046 virtual ~TimeTag()
00047 throw()
00048 {}
00049
00052 virtual CommonTime convertToCommonTime() const
00053 throw( gpstk::InvalidRequest ) = 0;
00054
00057 virtual void convertFromCommonTime( const CommonTime& ct )
00058 throw( gpstk::InvalidRequest ) = 0;
00059
00062 virtual std::string printf( const std::string& fmt ) const
00063 throw( gpstk::StringUtils::StringException ) = 0;
00064
00067 virtual std::string printError( const std::string& fmt ) const
00068 throw( gpstk::StringUtils::StringException ) = 0;
00069
00078 virtual void scanf( const std::string& str,
00079 const std::string& fmt )
00080 throw( gpstk::InvalidRequest,
00081 gpstk::StringUtils::StringException );
00082
00085 typedef std::map< char, std::string> IdToValue;
00086
00097 static void getInfo( const std::string& str,
00098 const std::string& fmt,
00099 IdToValue& info )
00100 throw( gpstk::StringUtils::StringException );
00101
00108 virtual bool setFromInfo( const IdToValue& info )
00109 throw() = 0;
00110
00113 virtual std::string getPrintChars() const
00114 throw() = 0;
00115
00117 virtual std::string getDefaultFormat() const
00118 throw() = 0;
00119
00121 virtual bool isValid() const
00122 throw() = 0;
00123
00125 virtual void reset()
00126 throw() = 0;
00127
00130 virtual std::string asString() const
00131 throw( gpstk::StringUtils::StringException )
00132 { return printf( getDefaultFormat() ); }
00133
00136 virtual operator CommonTime() const
00137 throw(InvalidRequest)
00138 { return convertToCommonTime(); }
00139
00142 static inline std::string getFormatPrefixInt()
00143 { return "%[ 0-]?[[:digit:]]*"; }
00144
00147 static inline std::string getFormatPrefixFloat()
00148 { return getFormatPrefixInt() + "(\\.[[:digit:]]+)?"; }
00149
00151 static inline std::string getError()
00152 { return "ErrorBadTime"; }
00153
00154 };
00155
00156 }
00157
00158 std::ostream& operator<<( std::ostream& s,
00159 const gpstk::TimeTag& t );
00160
00161 #endif // GPSTK_BASETIME_HPP