GPSWeekZcount.hpp

Go to the documentation of this file.
00001 #pragma ident "$Id: GPSWeekZcount.hpp 1225 2008-05-06 17:53:22Z vorce $"
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., 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 "GPSWeek.hpp"
00031 #include "TimeConstants.hpp"
00032 
00033 namespace gpstk
00034 {
00039    class GPSWeekZcount : public GPSWeek
00040    {
00041    public:
00043       static const unsigned int bits19 = 0x7FFFF;
00044 
00054       GPSWeekZcount( int w = 0,
00055                      int z = 0 )
00056          throw()
00057             : GPSWeek( w ), zcount( z )
00058       {}
00059       
00064       GPSWeekZcount( const GPSWeekZcount& right )
00065          throw()
00066             : GPSWeek( right.week ), zcount( right.zcount )
00067       {}
00068       
00076       GPSWeekZcount( const TimeTag& right )
00077          throw( gpstk::InvalidRequest )
00078       { 
00079          convertFromCommonTime( right.convertToCommonTime() ); 
00080       }
00081       
00089       GPSWeekZcount( const CommonTime& right )
00090          throw( InvalidRequest )
00091       {
00092          convertFromCommonTime( right );
00093       }
00094 
00100       GPSWeekZcount& operator=( const GPSWeekZcount& right )
00101          throw();
00102       
00104       virtual ~GPSWeekZcount()
00105          throw()
00106       {}
00108 
00109          // The following functions are required by TimeTag.
00110       virtual CommonTime convertToCommonTime() const
00111          throw(InvalidRequest);
00112 
00113       virtual void convertFromCommonTime( const CommonTime& ct )
00114          throw(InvalidRequest);
00115 
00118       virtual std::string printf( const std::string& fmt ) const
00119          throw( gpstk::StringUtils::StringException );
00120 
00123       virtual std::string printError( const std::string& fmt) const
00124          throw( gpstk::StringUtils::StringException );
00125 
00132       virtual bool setFromInfo( const IdToValue& info )
00133          throw();
00134       
00137       inline virtual std::string getPrintChars() const
00138          throw()
00139       { 
00140          return GPSWeek::getPrintChars() + "wzZcC";
00141       }
00142 
00144       inline virtual std::string getDefaultFormat() const
00145          throw()
00146       {
00147          return GPSWeek::getDefaultFormat() + " %06Z";
00148       }
00149 
00150       virtual bool isValid() const
00151          throw()
00152       {
00153          return ( GPSWeek::isValid() &&
00154                  zcount < ZCOUNT_PER_WEEK );
00155       }
00156       
00157       inline virtual void reset()
00158          throw()
00159       {
00160          GPSWeek::reset();
00161          zcount = 0;
00162       }
00163 
00167 
00168       inline unsigned int getZcount29() const
00169       { 
00170          return (getWeek10() << 19) | zcount;
00171       }
00172       
00173       inline unsigned int getZcount32() const
00174       {
00175          return (week << 19) | zcount;
00176       }
00177       
00178       GPSWeekZcount& setZcount29(unsigned int z)
00179          throw();
00180 
00181       GPSWeekZcount& setZcount32(unsigned int z)
00182          throw();
00184 
00185       inline virtual unsigned int getDayOfWeek() const
00186          throw()
00187       {
00188          return static_cast<unsigned int>(zcount) / ZCOUNT_PER_DAY;
00189       }
00190 
00199      //
00200        inline bool operator==( const GPSWeekZcount& right ) const
00201          throw()
00202        {
00203           return ( GPSWeek::operator==(right) &&
00204                 zcount == right.zcount );
00205        }
00206    
00207        inline bool operator!=( const GPSWeekZcount& right ) const
00208          throw()
00209        {
00210           return ( !operator==( right ) );
00211        }
00212 
00213        inline bool operator<( const GPSWeekZcount& right ) const
00214          throw()
00215        {
00216          if( GPSWeek::operator<(right) )
00217          {
00218            return true;
00219          }
00220          if( GPSWeek::operator>(right) )
00221          {
00222            return false;
00223          }
00224          if( zcount < right.zcount )
00225          {
00226            return true;
00227          }
00228          return false;
00229        }
00230 
00231        inline bool operator>( const GPSWeekZcount& right ) const
00232          throw()
00233        {
00234          return ( !operator<=( right ) );
00235        }
00236 
00237        inline bool operator<=( const GPSWeekZcount& right ) const
00238          throw()
00239        {
00240          return ( operator<( right ) ||
00241                   operator==( right ) );
00242        }
00243 
00244        inline bool operator>=( const GPSWeekZcount& right ) const
00245          throw()
00246        { 
00247          return ( !operator<( right ) );
00248        }
00250 
00251       unsigned int zcount;
00252    };   
00253    
00254 } // namespace
00255 
00256 #endif // GPSTK_GPSWEEKZCOUNT_HPP

Generated on Tue May 22 03:30:58 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1