GPSWeek.hpp

Go to the documentation of this file.
00001 #pragma ident "$Id: GPSWeek.hpp 1225 2008-05-06 17:53:22Z vorce $"
00002 
00003 #ifndef GPSTK_GPSWEEK_HPP
00004 #define GPSTK_GPSWEEK_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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023 //  
00024 //  Copyright 2004, The University of Texas at Austin
00025 //
00026 //============================================================================
00027 
00028 #include "TimeTag.hpp"
00029 
00030 namespace gpstk
00031 {
00064    class GPSWeek : public TimeTag
00065    {
00066    public:
00069       static const int bits10 = 0x3FF;
00072       static const int MAX_WEEK;
00073 
00075       GPSWeek( int w = 0 )
00076          throw()
00077             : week(w) 
00078       {}
00079       
00081       virtual ~GPSWeek()
00082          throw()
00083       {}
00084       
00086       GPSWeek& operator=(const GPSWeek& right)
00087          throw();
00088       
00090 
00091       inline bool operator==(const GPSWeek& right) const
00092          throw()
00093       {
00094          return week == right.week;
00095       }
00096       
00097       inline bool operator!=(const GPSWeek& right) const
00098          throw()
00099       {
00100          return week != right.week;
00101       }
00102       
00103       inline bool operator<(const GPSWeek& right) const
00104          throw()
00105       {
00106          return week < right.week;
00107       }
00108       
00109       inline bool operator<=(const GPSWeek& right) const
00110          throw()
00111       {
00112          return week <= right.week;
00113       }
00114       
00115       inline bool operator>(const GPSWeek& right) const
00116          throw()
00117       {
00118          return week > right.week;
00119       }
00120       
00121       inline bool operator>=(const GPSWeek& right) const
00122          throw()
00123       {
00124          return week >= right.week;
00125       }
00127 
00130 
00131       inline virtual unsigned int getEpoch() const
00132          throw()
00133       {
00134          return week >> 10;
00135       }
00136       
00137       inline virtual unsigned int getWeek10() const
00138          throw()
00139       {
00140          return week & bits10;
00141       }
00142       
00143       inline virtual void getEpochWeek10(unsigned int& e, 
00144                                          unsigned int& w) const
00145          throw()
00146       {
00147          e = getEpoch(); 
00148          w = getWeek10();
00149       }
00150       
00151       inline virtual void setEpoch(unsigned int e)
00152          throw()
00153       {
00154          week &= bits10;
00155          week |= e << 10;
00156       }
00157 
00158       inline virtual void setWeek10(unsigned int w)
00159          throw()
00160       { 
00161          week &= ~bits10; 
00162          week |= w & bits10;
00163       }
00164       
00165       inline virtual void setEpochWeek10(unsigned int e,
00166                                          unsigned int w)
00167          throw()
00168       {
00169          setEpoch(e);
00170          setWeek10(w);
00171       }
00173       
00176       virtual std::string printf( const std::string& fmt ) const
00177          throw( gpstk::StringUtils::StringException );
00178       
00181       virtual std::string printError( const std::string& fmt ) const
00182          throw( gpstk::StringUtils::StringException );
00183 
00190       virtual bool setFromInfo( const IdToValue& info )
00191          throw();
00192 
00195       inline virtual std::string getPrintChars() const
00196          throw()
00197       { 
00198          return "EFG";
00199       }
00200          
00202       inline virtual std::string getDefaultFormat() const
00203          throw()
00204       {
00205          return "%04F";
00206       }
00207 
00208       virtual bool isValid() const
00209          throw()
00210       {
00211          return (week >= 0 && week <= MAX_WEEK);
00212       }
00213       
00214       inline virtual void reset()
00215          throw()
00216       {
00217          week = 0;
00218       }
00219       
00221       virtual unsigned int getDayOfWeek() const
00222          throw() = 0;
00223 
00224       int week;
00225    };
00226 
00227 } // namespace
00228 
00229 #endif // GPSTK_GPSTIME_HPP

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