Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JGeometry3D/JTime.hh
Go to the documentation of this file.
1 #ifndef __JTIME1__
2 #define __JTIME1__
3 
4 #include <istream>
5 #include <ostream>
6 
7 #include "JIO/JSerialisable.hh"
8 
9 
10 /**
11  * \author mdejong
12  */
13 
14 namespace JGEOMETRY3D {}
15 namespace JPP { using namespace JGEOMETRY3D; }
16 
17 namespace JGEOMETRY3D {
18 
19  using JIO::JReader;
20  using JIO::JWriter;
21 
22 
23  /**
24  * Time.
25  */
26  class JTime
27  {
28  public:
29  /**
30  * Default constructor.
31  */
32  JTime() :
33  __t(0.0)
34  {}
35 
36 
37  /**
38  * Constructor.
39  *
40  * \param t time
41  */
42  JTime(const double t) :
43  __t(t)
44  {}
45 
46 
47  /**
48  * Prefix unary minus.
49  *
50  * \return time
51  */
53  {
54  __t = -__t;
55 
56  return *this;
57  }
58 
59 
60  /**
61  * Addition operator.
62  *
63  * \param value time
64  * \return time
65  */
66  JTime& add(const JTime& value)
67  {
68  __t += value.getT();
69 
70  return *this;
71  }
72 
73 
74  /**
75  * Subtraction operator.
76  *
77  * \param value time
78  * \return time
79  */
80  JTime& sub(const JTime& value)
81  {
82  __t -= value.getT();
83 
84  return *this;
85  }
86 
87 
88  /**
89  * Multiplication operator.
90  *
91  * \param value multiplication factor
92  * \return time
93  */
94  JTime& mul(const double value)
95  {
96  __t *= value;
97 
98  return *this;
99  }
100 
101 
102  /**
103  * Division operator.
104  *
105  * \param value multiplication factor
106  * \return time
107  */
108  JTime& div(const double value)
109  {
110  __t /= value;
111 
112  return *this;
113  }
114 
115 
116  /**
117  * Get time.
118  *
119  * \return time
120  */
121  inline double getT() const
122  {
123  return __t;
124  }
125 
126 
127  /**
128  * Read time from input.
129  *
130  * \param in input stream
131  * \param time time
132  * \return input stream
133  */
134  friend inline std::istream& operator>>(std::istream& in, JTime& time)
135  {
136  in >> time.__t;
137 
138  return in;
139  }
140 
141 
142  /**
143  * Write time to output.
144  *
145  * \param out output stream
146  * \param time time
147  * \return output stream
148  */
149  friend inline std::ostream& operator<<(std::ostream& out, const JTime& time)
150  {
151  out << time.__t;
152 
153  return out;
154  }
155 
156 
157  /**
158  * Read time from input.
159  *
160  * \param in reader
161  * \param time time
162  * \return reader
163  */
164  friend inline JReader& operator>>(JReader& in, JTime& time)
165  {
166  in >> time.__t;
167 
168  return in;
169  }
170 
171 
172  /**
173  * Write time to output.
174  *
175  * \param out writer
176  * \param time time
177  * \return writer
178  */
179  friend inline JWriter& operator<<(JWriter& out, const JTime& time)
180  {
181  out << time.__t;
182 
183  return out;
184  }
185 
186 
187  protected:
188  double __t;
189  };
190 }
191 
192 #endif
Interface for binary output.
double getT() const
Get time.
JTime & sub(const JTime &value)
Subtraction operator.
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
Definition: JSirene.sh:45
JTime & div(const double value)
Division operator.
JTime & negate()
Prefix unary minus.
JTime()
Default constructor.
JTime & add(const JTime &value)
Addition operator.
JTime & mul(const double value)
Multiplication operator.
Interface for binary input.
friend JReader & operator>>(JReader &in, JTime &time)
Read time from input.
friend std::ostream & operator<<(std::ostream &out, const JTime &time)
Write time to output.
JTime(const double t)
Constructor.
friend JWriter & operator<<(JWriter &out, const JTime &time)
Write time to output.
friend std::istream & operator>>(std::istream &in, JTime &time)
Read time from input.