TimeSystem.hpp

Go to the documentation of this file.
00001 #pragma ident "$Id: TimeSystem.hpp 3272 2012-08-11 01:53:21Z yanweignss $"
00002 
00003 #ifndef GPSTK_TIMESYSTEM_HPP
00004 #define GPSTK_TIMESYSTEM_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 <iostream>
00043 #include <string>
00044 
00045 namespace gpstk
00046 {
00049    class TimeSystem
00050    {
00051    public:
00052 
00054       enum Systems
00055       {
00056          // add new systems BEFORE count,
00057          // then add to Strings[] in TimeSystem.cpp and make parallel to this enum.
00058 
00059          // Unknown MUST BE FIRST, and must = 0
00060          Unknown = 0, 
00061          Any,         
00062          GPS,         
00063          GLO,         
00064          GAL,         
00065          COM,         
00066          UTC,         
00067          UT1,         
00068          TAI,         
00069          TT,          
00070          
00071          // count MUST BE LAST
00072          count        
00073       };
00074 
00076       TimeSystem(Systems sys = Unknown) throw()
00077       {
00078          if(sys < 0 || sys >= count)
00079             system = Unknown;
00080          else
00081             system = sys;
00082       }
00083 
00085       TimeSystem(int i) throw()
00086       {
00087          if(i < 0 || i >= count)
00088             system = Unknown;
00089          else
00090             system = static_cast<Systems>(i);
00091       }
00092 
00093       // (copy constructor and operator= are defined by compiler)
00094       
00096       void setTimeSystem(const Systems& sys) throw();
00097 
00099       Systems getTimeSystem() const throw()
00100       { return system; }
00101 
00104       std::string asString() const throw()
00105       { return Strings[system]; }
00106 
00109       void fromString(const std::string str) throw();
00110       
00112       bool operator==(const TimeSystem& right) const throw()
00113       { return system == right.system; }
00114 
00116       bool operator<(const TimeSystem& right) const throw()
00117       { return system < right.system; }
00118 
00119       // the rest follow from Boolean algebra...
00121       bool operator!=(const TimeSystem& right) const throw()
00122       { return !operator==(right); }
00123 
00125       bool operator>=(const TimeSystem& right) const throw()
00126       { return !operator<(right); }
00127 
00129       bool operator<=(const TimeSystem& right) const throw()
00130       { return (operator<(right) || operator==(right)); }
00131 
00133       bool operator>(const TimeSystem& right) const throw()
00134       { return (!operator<(right) && !operator==(right)); }
00135 
00136    private:
00137 
00139       Systems system;
00140 
00142       static const std::string Strings[];
00143 
00144    };   // end class TimeSystem
00145 
00150    std::ostream& operator<<(std::ostream& os, const TimeSystem& ts);
00151 
00152 }   // end namespace
00153 
00154 #endif // GPSTK_TIMESYSTEM_HPP

Generated on Sun May 19 03:31:14 2013 for GPS ToolKit Software Library by  doxygen 1.3.9.1