Jpp  18.0.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JUTCTimeRange.hh
Go to the documentation of this file.
1 #ifndef __JUTC__JUTCTIMERANGE__
2 #define __JUTC__JUTCTIMERANGE__
3 
4 #include "JTools/JRange.hh"
5 #include "JLang/JManip.hh"
6 
7 
8 /**
9  * \author mdejong
10  */
11 
12 namespace JUTC {}
13 namespace JPP { using namespace JUTC; }
14 
15 /**
16  * Auxiliaries for handling universal time coordinate (UTC).
17  */
18 namespace JUTC {
19 
20  using JTOOLS::JRange;
21 
22  /**
23  * UTC time range [s].
24  */
25  class JUTCTimeRange :
26  public JRange<double>
27  {
28  public:
29  /**
30  * Default constructor.
31  */
33  JRange<double>(0.0, 999999999999.9)
34  {}
35 
36 
37  /**
38  * Constructor.
39  *
40  * \param timerange UTC time range
41  */
42  JUTCTimeRange(const JRange<double>& timerange) :
43  JRange<double>(timerange)
44  {}
45 
46 
47  /**
48  * Constructor.
49  *
50  * \param Tmin_s minimal UTC time [s]
51  * \param Tmax_s maximal UTC time [s]
52  */
53  JUTCTimeRange(const double Tmin_s, const double Tmax_s) :
54  JRange<double>(Tmin_s, Tmax_s)
55  {}
56 
57 
58  /**
59  * Get UTC time range.
60  *
61  * \return UTC time range
62  */
64  {
65  return static_cast<const JUTCTimeRange&>(*this);
66  }
67 
68 
69  /**
70  * Get UTC time range.
71  *
72  * \return UTC time range
73  */
75  {
76  return static_cast<JUTCTimeRange&>(*this);
77  }
78 
79 
80  /**
81  * Set UTC time range.
82  *
83  * \param timerange UTC time range
84  */
85  void setUTCTimeRange(const JRange<double>& timerange)
86  {
87  static_cast<JUTCTimeRange&>(*this) = timerange;
88  }
89 
90 
91  /**
92  * Write UTC time range to output.
93  *
94  * \param out output stream
95  * \param utc UTC time range
96  * \return output stream
97  */
98  friend inline std::ostream& operator<<(std::ostream& out, const JUTCTimeRange& utc)
99  {
100  const JFormat format(out, getFormat<JUTCTimeRange>(JFormat_t(13, 1, std::ios::fixed)));
101 
102  return out << format << utc.getLowerLimit() << ' '
103  << format << utc.getUpperLimit();
104  }
105  };
106 }
107 
108 #endif
JUTCTimeRange(const JRange< double > &timerange)
Constructor.
T getLowerLimit() const
Get lower limit.
Definition: JRange.hh:202
JUTCTimeRange()
Default constructor.
Auxiliary class to temporarily define format specifications.
Definition: JManip.hh:632
void setUTCTimeRange(const JRange< double > &timerange)
Set UTC time range.
T getUpperLimit() const
Get upper limit.
Definition: JRange.hh:213
JUTCTimeRange(const double Tmin_s, const double Tmax_s)
Constructor.
Range of values.
Definition: JRange.hh:38
I/O manipulators.
UTC time range [s].
Auxiliary class to define a range between two values.
friend std::ostream & operator<<(std::ostream &out, const JUTCTimeRange &utc)
Write UTC time range to output.
JUTCTimeRange & getUTCTimeRange()
Get UTC time range.
const JUTCTimeRange & getUTCTimeRange() const
Get UTC time range.
Data structure for format specifications.
Definition: JManip.hh:522