GPSWeekZcount.hpp

Go to the documentation of this file.
00001 #pragma ident "$Id: GPSWeekZcount.hpp 3140 2012-06-18 15:03:02Z susancummins $"
00002 
00003 
00004 
00005 #ifndef GPSTK_GPSWEEKZCOUNT_HPP
00006 #define GPSTK_GPSWEEKZCOUNT_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., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
00025 //  
00026 //  Copyright 2004, The University of Texas at Austin
00027 //
00028 //============================================================================
00029 
00030 //============================================================================
00031 //
00032 //This software developed by Applied Research Laboratories at the University of
00033 //Texas at Austin, under contract to an agency or agencies within the U.S. 
00034 //Department of Defense. The U.S. Government retains all rights to use,
00035 //duplicate, distribute, disclose, or release this software. 
00036 //
00037 //Pursuant to DoD Directive 523024 
00038 //
00039 // DISTRIBUTION STATEMENT A: This software has been approved for public 
00040 //                           release, distribution is unlimited.
00041 //
00042 //=============================================================================
00043 
00044 #include "GPSWeek.hpp"
00045 #include "TimeConstants.hpp"
00046 #include "TimeSystem.hpp"
00047 
00048 namespace gpstk
00049 {
00054    class GPSWeekZcount : public GPSWeek
00055    {
00056    public:
00058       static const unsigned int bits19 = 0x7FFFF;
00059 
00069       GPSWeekZcount( int w = 0,
00070                      int z = 0,
00071                      TimeSystem ts = TimeSystem::Unknown )
00072          throw()
00073             : GPSWeek( w ), zcount( z )
00074       { timeSystem = ts; }
00075       
00080       GPSWeekZcount( const GPSWeekZcount& right )
00081          throw()
00082             : GPSWeek( right.week ), zcount( right.zcount )
00083       { timeSystem = right.timeSystem; }
00084       
00092       GPSWeekZcount( const TimeTag& right )
00093          throw( gpstk::InvalidRequest )
00094       { 
00095          convertFromCommonTime( right.convertToCommonTime() ); 
00096       }
00097       
00105       GPSWeekZcount( const CommonTime& right )
00106          throw( gpstk::InvalidRequest )
00107       {
00108          convertFromCommonTime( right );
00109       }
00110 
00116       GPSWeekZcount& operator=( const GPSWeekZcount& right )
00117          throw();
00118       
00120       virtual ~GPSWeekZcount()
00121          throw()
00122       {}
00124 
00125          // The following functions are required by TimeTag.
00126       virtual CommonTime convertToCommonTime() const
00127          throw( gpstk::InvalidRequest );
00128 
00129       virtual void convertFromCommonTime( const CommonTime& ct )
00130          throw( gpstk::InvalidRequest );
00131 
00134       virtual std::string printf( const std::string& fmt ) const
00135          throw( gpstk::StringUtils::StringException );
00136 
00139       virtual std::string printError( const std::string& fmt) const
00140          throw( gpstk::StringUtils::StringException );
00141 
00148       virtual bool setFromInfo( const IdToValue& info )
00149          throw();
00150       
00153       inline virtual std::string getPrintChars() const
00154          throw()
00155       { 
00156          return GPSWeek::getPrintChars() + "wzZcC";
00157       }
00158 
00160       inline virtual std::string getDefaultFormat() const
00161          throw()
00162       {
00163          return GPSWeek::getDefaultFormat() + " %06Z %P";
00164       }
00165 
00166       virtual bool isValid() const
00167          throw()
00168       {
00169          return ( GPSWeek::isValid() &&
00170                  zcount < ZCOUNT_PER_WEEK );
00171       }
00172       
00173       inline virtual void reset()
00174          throw()
00175       {
00176          GPSWeek::reset();
00177          zcount = 0;
00178       }
00179 
00183 
00184       inline unsigned int getZcount29() const
00185       { 
00186          return (getWeek10() << 19) | zcount;
00187       }
00188       
00189       inline unsigned int getZcount32() const
00190       {
00191          return (week << 19) | zcount;
00192       }
00193       
00194       GPSWeekZcount& setZcount29(unsigned int z)
00195          throw();
00196 
00197       GPSWeekZcount& setZcount32(unsigned int z)
00198          throw();
00200 
00201       inline virtual unsigned int getDayOfWeek() const
00202          throw()
00203       {
00204          return static_cast<unsigned int>(zcount) / ZCOUNT_PER_DAY;
00205       }
00206 
00215      //
00216        inline bool operator==( const GPSWeekZcount& right ) const
00217          throw()
00218        {
00219           return ( GPSWeek::operator==(right) &&
00220                    zcount == right.zcount );
00221        }
00222    
00223        inline bool operator!=( const GPSWeekZcount& right ) const
00224          throw()
00225        {
00226           return ( !operator==( right ) );
00227        }
00228 
00229        inline bool operator<( const GPSWeekZcount& right ) const
00230          throw()
00231        {
00232          if( GPSWeek::operator<(right) )
00233          {
00234            return true;
00235          }
00236          if( GPSWeek::operator>(right) )
00237          {
00238            return false;
00239          }
00240          if( zcount < right.zcount )
00241          {
00242            return true;
00243          }
00244          return false;
00245        }
00246 
00247        inline bool operator>( const GPSWeekZcount& right ) const
00248          throw()
00249        {
00250          return ( !operator<=( right ) );
00251        }
00252 
00253        inline bool operator<=( const GPSWeekZcount& right ) const
00254          throw()
00255        {
00256          return ( operator<( right ) ||
00257                   operator==( right ) );
00258        }
00259 
00260        inline bool operator>=( const GPSWeekZcount& right ) const
00261          throw()
00262        { 
00263          return ( !operator<( right ) );
00264        }
00266 
00267       unsigned int zcount;
00268    };   
00269    
00270 } // namespace
00271 
00272 #endif // GPSTK_GPSWEEKZCOUNT_HPP

Generated on Wed Jun 19 03:31:06 2013 for GPS ToolKit Software Library by  doxygen 1.3.9.1