Jpp  master_rocky
the software that should make you happy
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
I/O manipulators.
Auxiliary class to define a range between two values.
Range of values.
Definition: JRange.hh:42
T getLowerLimit() const
Get lower limit.
Definition: JRange.hh:202
T getUpperLimit() const
Get upper limit.
Definition: JRange.hh:213
UTC time range [s].
JUTCTimeRange(const double Tmin_s, const double Tmax_s)
Constructor.
friend std::ostream & operator<<(std::ostream &out, const JUTCTimeRange &utc)
Write UTC time range to output.
const JUTCTimeRange & getUTCTimeRange() const
Get UTC time range.
JUTCTimeRange(const JRange< double > &timerange)
Constructor.
void setUTCTimeRange(const JRange< double > &timerange)
Set UTC time range.
JUTCTimeRange & getUTCTimeRange()
Get UTC time range.
JUTCTimeRange()
Default constructor.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliaries for handling universal time coordinate (UTC).
Data structure for format specifications.
Definition: JManip.hh:524
Auxiliary class to temporarily define format specifications.
Definition: JManip.hh:636