TimeTag.hpp

Go to the documentation of this file.
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 //  This file is part of GPSTk, the GPS Toolkit.
00009 //
00010 //  The GPSTk is free software; you can redistribute it and/or modify
00011 //  it under the terms of the GNU Lesser General Public License as published
00012 //  by the Free Software Foundation; either version 2.1 of the License, or
00013 //  any later version.
00014 //
00015 //  The GPSTk is distributed in the hope that it will be useful,
00016 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 //  GNU Lesser General Public License for more details.
00019 //
00020 //  You should have received a copy of the GNU Lesser General Public
00021 //  License along with GPSTk; if not, write to the Free Software Foundation,
00022 //  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
00023 //  
00024 //  Copyright 2004, The University of Texas at Austin
00025 //
00026 //============================================================================
00027 
00028 //============================================================================
00029 //
00030 //This software developed by Applied Research Laboratories at the University of
00031 //Texas at Austin, under contract to an agency or agencies within the U.S. 
00032 //Department of Defense. The U.S. Government retains all rights to use,
00033 //duplicate, distribute, disclose, or release this software. 
00034 //
00035 //Pursuant to DoD Directive 523024 
00036 //
00037 // DISTRIBUTION STATEMENT A: This software has been approved for public 
00038 //                           release, distribution is unlimited.
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      // Default constructor
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; // time system (representation) of the data
00190    };
00191 
00192 } // namespace
00193 
00194 std::ostream& operator<<( std::ostream& s,
00195                           const gpstk::TimeTag& t );
00196 
00197 #endif // GPSTK_TIMETAG_HPP

Generated on Sat May 18 03:31:12 2013 for GPS ToolKit Software Library by  doxygen 1.3.9.1