TimeTag.hpp

Go to the documentation of this file.
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 //  This file is part of GPSTk, the GPS Toolkit.
00011 //
00012 //  The GPSTk is free software; you can redistribute it and/or modify
00013 //  it under the terms of the GNU Lesser General Public License as published
00014 //  by the Free Software Foundation; either version 2.1 of the License, or
00015 //  any later version.
00016 //
00017 //  The GPSTk is distributed in the hope that it will be useful,
00018 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 //  GNU Lesser General Public License for more details.
00021 //
00022 //  You should have received a copy of the GNU Lesser General Public
00023 //  License along with GPSTk; if not, write to the Free Software Foundation,
00024 //  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025 //  
00026 //  Copyright 2004, The University of Texas at Austin
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 } // namespace
00157 
00158 std::ostream& operator<<( std::ostream& s,
00159                           const gpstk::TimeTag& t );
00160 
00161 #endif // GPSTK_BASETIME_HPP

Generated on Wed Feb 8 03:31:03 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1