1 //==============================================================================
2 //
3 //  This file is part of GPSTk, the GPS Toolkit.
4 //
5 //  The GPSTk 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 GPSTk 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 GPSTk; 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-2020, 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 /**
40  * @file RinexClockBase.hpp
41  * Base class for RINEX clock data file
42  */
43 
44 #ifndef GPSTK_RINEXCLOCKBASE_HPP
45 #define GPSTK_RINEXCLOCKBASE_HPP
46 
47 #include <string>
48 #include "FFData.hpp"
49 #include "StringUtils.hpp"
50 #include "CivilTime.hpp"
51 #include "FormattedDouble.hpp"
52 
53 namespace gpstk
54 {
55       /// @ingroup FileHandling
56       //@{
57 
58    class RinexClockBase : public FFData
59    {
60    public:
61       class RCDouble : public FormattedDouble
62       {
63       public:
64             /// Constructor for a value, with all defaults for format.
RCDouble(double d)65          RCDouble(double d)
66                : FormattedDouble(d, StringUtils::FFLead::Zero, 13, 2, 19, 'E',
67                                  StringUtils::FFSign::NegOnly,
68                                  StringUtils::FFAlign::Right)
69          {}
70 
71             /// Assign a value by decoding a string using existing formatting.
operator =(const std::string & s)72          RCDouble& operator=(const std::string& s)
73          { FormattedDouble::operator=(s); return *this; }
74       };
75 
76          /// Destructor
~RinexClockBase()77       virtual ~RinexClockBase() {}
78 
79          /// RINEX clock data types
80       struct RinexClkType
81       {
82          std::string type;
83          std::string description;
RinexClkTypegpstk::RinexClockBase::RinexClkType84          RinexClkType() : type(std::string("UN")),
85                           description(std::string("Unknown or Invalid")){}
RinexClkTypegpstk::RinexClockBase::RinexClkType86          RinexClkType(std::string t, std::string d) : type(t), description(d){}
operator ==gpstk::RinexClockBase::RinexClkType87          bool operator==(const RinexClkType &other) const
88          {  return (StringUtils::upperCase(type) ==
89                     StringUtils::upperCase(other.type));
90          }
operator !=gpstk::RinexClockBase::RinexClkType91          bool operator!=(const RinexClkType &other) const
92          {  return !(*this == other); }
operator <gpstk::RinexClockBase::RinexClkType93          bool operator<(const RinexClkType &other) const
94          {  return (type < other.type); }
operator <=gpstk::RinexClockBase::RinexClkType95          bool operator<=(const RinexClkType &other) const
96          {  return (type <= other.type); }
operator >gpstk::RinexClockBase::RinexClkType97          bool operator>(const RinexClkType &other) const
98          {  return (type > other.type); }
operator >=gpstk::RinexClockBase::RinexClkType99          bool operator>=(const RinexClkType &other) const
100          {  return (type >= other.type); }
101       };
102 
103          /** @name Standard RINEX clock data types
104           */
105          //@{
106       static const RinexClkType UN;
107       static const RinexClkType AR;
108       static const RinexClkType AS;
109       static const RinexClkType CR;
110       static const RinexClkType DR;
111       static const RinexClkType MS;
112          //@}
113 
114    protected:
115 
116          /// Converts a CivilTime object into a Rinex Clock time
117          /// Format is 26 characters "yyyy mm dd hh mm ss.ssssss"
118          /// If CommonTime == BEGINNING_OF_TIME an all blank string will
119          /// be returned.
120       std::string writeTime(const CivilTime& dt) const;
121 
122          /** Converts a 26 character Rinex Clock time in the format
123           * "yyyy mm dd hh mm ss.ssssss" to a CivilTime object.
124           * If the string is blank a CommonTime::BEGINNING_OF_TIME is returned.
125           * @throw FFStreamError
126           */
127       CivilTime parseTime(const std::string& line) const;
128 
129    };  //  RinexClockBase
130       //@}
131 
132 }  // namespace
133 
134 #endif
135