GPSWeek.hpp
Go to the documentation of this file.
1 //==============================================================================
2 //
3 // This file is part of GNSSTk, the ARL:UT GNSS Toolkit.
4 //
5 // The GNSSTk is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published
7 // by the Free Software Foundation; either version 3.0 of the License, or
8 // any later version.
9 //
10 // The GNSSTk is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with GNSSTk; if not, write to the Free Software Foundation,
17 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
18 //
19 // This software was developed by Applied Research Laboratories at the
20 // University of Texas at Austin.
21 // Copyright 2004-2022, The Board of Regents of The University of Texas System
22 //
23 //==============================================================================
24 
25 //==============================================================================
26 //
27 // This software was developed by Applied Research Laboratories at the
28 // University of Texas at Austin, under contract to an agency or agencies
29 // within the U.S. Department of Defense. The U.S. Government retains all
30 // rights to use, duplicate, distribute, disclose, or release this software.
31 //
32 // Pursuant to DoD Directive 523024
33 //
34 // DISTRIBUTION STATEMENT A: This software has been approved for public
35 // release, distribution is unlimited.
36 //
37 //==============================================================================
38 
39 #ifndef GNSSTK_GPSWEEK_HPP
40 #define GNSSTK_GPSWEEK_HPP
41 
42 #include "gnsstk_export.h"
43 #include "TimeTag.hpp"
44 
45 namespace gnsstk
46 {
48 
49 
82  class GPSWeek : public TimeTag
83  {
84  public:
87  GNSSTK_EXPORT static const int bits10 = 0x3FF;
90  GNSSTK_EXPORT static const int MAX_WEEK;
91 
93  GPSWeek( int w = 0,
95  : week(w)
96  { timeSystem = ts; }
97 
99  virtual ~GPSWeek()
100  {}
101 
103  GPSWeek& operator=(const GPSWeek& right);
104 
106 
107  inline bool operator==(const GPSWeek& right) const
108  {
110  if ((timeSystem != TimeSystem::Any &&
111  right.timeSystem != TimeSystem::Any) &&
112  timeSystem != right.timeSystem)
113  return false;
114 
115  return week == right.week;
116  }
117 
118  inline bool operator!=(const GPSWeek& right) const
119  {
121  if ((timeSystem != TimeSystem::Any &&
122  right.timeSystem != TimeSystem::Any) &&
123  timeSystem != right.timeSystem)
124  {
125  gnsstk::InvalidRequest ir("CommonTime objects not in same time system, cannot be compared");
126  GNSSTK_THROW(ir);
127  }
128 
129  return week != right.week;
130  }
131 
132  inline bool operator<(const GPSWeek& right) const
133  {
135  if ((timeSystem != TimeSystem::Any &&
136  right.timeSystem != TimeSystem::Any) &&
137  timeSystem != right.timeSystem)
138  {
139  gnsstk::InvalidRequest ir("CommonTime objects not in same time system, cannot be compared");
140  GNSSTK_THROW(ir);
141  }
142 
143  return week < right.week;
144  }
145 
146  inline bool operator<=(const GPSWeek& right) const
147  {
149  if ((timeSystem != TimeSystem::Any &&
150  right.timeSystem != TimeSystem::Any) &&
151  timeSystem != right.timeSystem)
152  {
153  gnsstk::InvalidRequest ir("CommonTime objects not in same time system, cannot be compared");
154  GNSSTK_THROW(ir);
155  }
156 
157  return week <= right.week;
158  }
159 
160  inline bool operator>(const GPSWeek& right) const
161  {
163  if ((timeSystem != TimeSystem::Any &&
164  right.timeSystem != TimeSystem::Any) &&
165  timeSystem != right.timeSystem)
166  {
167  gnsstk::InvalidRequest ir("CommonTime objects not in same time system, cannot be compared");
168  GNSSTK_THROW(ir);
169  }
170 
171  return week > right.week;
172  }
173 
174  inline bool operator>=(const GPSWeek& right) const
175  {
177  if ((timeSystem != TimeSystem::Any &&
178  right.timeSystem != TimeSystem::Any) &&
179  timeSystem != right.timeSystem)
180  {
181  gnsstk::InvalidRequest ir("CommonTime objects not in same time system, cannot be compared");
182  GNSSTK_THROW(ir);
183  }
184 
185  return week >= right.week;
186  }
188 
191 
192  inline virtual unsigned int getEpoch() const
193  {
194  return week >> 10;
195  }
196 
197  inline virtual unsigned int getWeek10() const
198  {
199  return week & bits10;
200  }
201 
202  inline virtual void getEpochWeek10(unsigned int& e,
203  unsigned int& w) const
204  {
205  e = getEpoch();
206  w = getWeek10();
207  }
208 
209  inline virtual void setEpoch(unsigned int e)
210  {
211  week &= bits10;
212  week |= e << 10;
213  }
214 
215  inline virtual void setWeek10(unsigned int w)
216  {
217  week &= ~bits10;
218  week |= w & bits10;
219  }
220 
221  inline virtual void setEpochWeek10(unsigned int e,
222  unsigned int w)
223  {
224  setEpoch(e);
225  setWeek10(w);
226  }
228 
231  virtual std::string printf( const std::string& fmt ) const;
232 
235  virtual std::string printError( const std::string& fmt ) const;
236 
243  virtual bool setFromInfo( const IdToValue& info );
244 
247  inline virtual std::string getPrintChars() const
248  {
249  return "EFGP";
250  }
251 
253  inline virtual std::string getDefaultFormat() const
254  {
255  return "%04F";
256  }
257 
258  virtual bool isValid() const
259  {
260  return (week >= 0 && week <= MAX_WEEK);
261  }
262 
263  inline virtual void reset()
264  {
265  week = 0;
266  }
267 
269  virtual unsigned int getDayOfWeek() const = 0;
270 
271  int week;
272  };
273 
275 
276 } // namespace
277 
278 #endif // GNSSTK_GPSTIME_HPP
gnsstk::GPSWeek::setFromInfo
virtual bool setFromInfo(const IdToValue &info)
Definition: GPSWeek.cpp:107
gnsstk::GPSWeek::operator=
GPSWeek & operator=(const GPSWeek &right)
Assignment Operator.
Definition: GPSWeek.cpp:48
gnsstk::GPSWeek::getDefaultFormat
virtual std::string getDefaultFormat() const
Return a string containing the default format to use in printing.
Definition: GPSWeek.hpp:253
gnsstk::TimeTag::IdToValue
std::map< char, std::string > IdToValue
Definition: TimeTag.hpp:103
gnsstk::GPSWeek::getDayOfWeek
virtual unsigned int getDayOfWeek() const =0
Force this interface on this classes descendants.
gnsstk::GPSWeek::operator<=
bool operator<=(const GPSWeek &right) const
Definition: GPSWeek.hpp:146
gnsstk::GPSWeek::getEpoch
virtual unsigned int getEpoch() const
Definition: GPSWeek.hpp:192
gnsstk::GPSWeek::setEpoch
virtual void setEpoch(unsigned int e)
Definition: GPSWeek.hpp:209
gnsstk::GPSWeek::isValid
virtual bool isValid() const
Returns true if this object's members are valid, false otherwise.
Definition: GPSWeek.hpp:258
gnsstk::GPSWeek::getEpochWeek10
virtual void getEpochWeek10(unsigned int &e, unsigned int &w) const
Definition: GPSWeek.hpp:202
gnsstk::GPSWeek::reset
virtual void reset()
Reset this object to the default state.
Definition: GPSWeek.hpp:263
gnsstk::GPSWeek::~GPSWeek
virtual ~GPSWeek()
Virtual Destructor.
Definition: GPSWeek.hpp:99
gnsstk::TimeSystem::Any
@ Any
wildcard; allows comparison with any other type
gnsstk::GPSWeek::setWeek10
virtual void setWeek10(unsigned int w)
Definition: GPSWeek.hpp:215
gnsstk::GPSWeek::getWeek10
virtual unsigned int getWeek10() const
Definition: GPSWeek.hpp:197
gnsstk::TimeSystem::Unknown
@ Unknown
unknown time frame; for legacy code compatibility
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
gnsstk::TimeTag::timeSystem
TimeSystem timeSystem
time system (representation) of the data
Definition: TimeTag.hpp:204
gnsstk::GPSWeek::week
int week
Definition: GPSWeek.hpp:271
gnsstk::TimeTag
Definition: TimeTag.hpp:58
gnsstk::GPSWeek::printError
virtual std::string printError(const std::string &fmt) const
Definition: GPSWeek.cpp:78
gnsstk::GPSWeek::operator<
bool operator<(const GPSWeek &right) const
Definition: GPSWeek.hpp:132
gnsstk::GPSWeek::MAX_WEEK
static const GNSSTK_EXPORT int MAX_WEEK
Definition: GPSWeek.hpp:90
gnsstk::TimeSystem
TimeSystem
Definition of various time systems.
Definition: TimeSystem.hpp:51
gnsstk::GPSWeek::setEpochWeek10
virtual void setEpochWeek10(unsigned int e, unsigned int w)
Definition: GPSWeek.hpp:221
TimeTag.hpp
gnsstk::GPSWeek::operator>=
bool operator>=(const GPSWeek &right) const
Definition: GPSWeek.hpp:174
gnsstk::GPSWeek::operator>
bool operator>(const GPSWeek &right) const
Definition: GPSWeek.hpp:160
gnsstk::GPSWeek::operator==
bool operator==(const GPSWeek &right) const
Definition: GPSWeek.hpp:107
gnsstk::GPSWeek::getPrintChars
virtual std::string getPrintChars() const
Definition: GPSWeek.hpp:247
gnsstk::GPSWeek::bits10
static const GNSSTK_EXPORT int bits10
Definition: GPSWeek.hpp:87
GNSSTK_THROW
#define GNSSTK_THROW(exc)
Definition: Exception.hpp:366
gnsstk::GPSWeek::GPSWeek
GPSWeek(int w=0, TimeSystem ts=TimeSystem::Unknown)
Constructor.
Definition: GPSWeek.hpp:93
gnsstk::GPSWeek::operator!=
bool operator!=(const GPSWeek &right) const
Definition: GPSWeek.hpp:118
gnsstk::GPSWeek::printf
virtual std::string printf(const std::string &fmt) const
Definition: GPSWeek.cpp:55
gnsstk::GPSWeek
Definition: GPSWeek.hpp:82


gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:39