Jpp  18.3.1
the software that should make you happy
 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 #include "JLang/JManip.hh"
9 
10 
11 /**
12  * \author mdejong
13  */
14 
15 namespace JGEOMETRY3D {}
16 namespace JPP { using namespace JGEOMETRY3D; }
17 
18 namespace JGEOMETRY3D {
19 
20  using JIO::JReader;
21  using JIO::JWriter;
22 
23 
24  /**
25  * Time.
26  */
27  class JTime
28  {
29  public:
30  /**
31  * Default constructor.
32  */
33  JTime() :
34  __t(0.0)
35  {}
36 
37 
38  /**
39  * Constructor.
40  *
41  * \param t time
42  */
43  JTime(const double t) :
44  __t(t)
45  {}
46 
47 
48  /**
49  * Prefix unary minus.
50  *
51  * \return time
52  */
54  {
55  __t = -__t;
56 
57  return *this;
58  }
59 
60 
61  /**
62  * Addition operator.
63  *
64  * \param value time
65  * \return time
66  */
67  JTime& add(const JTime& value)
68  {
69  __t += value.getT();
70 
71  return *this;
72  }
73 
74 
75  /**
76  * Subtraction operator.
77  *
78  * \param value time
79  * \return time
80  */
81  JTime& sub(const JTime& value)
82  {
83  __t -= value.getT();
84 
85  return *this;
86  }
87 
88 
89  /**
90  * Multiplication operator.
91  *
92  * \param value multiplication factor
93  * \return time
94  */
95  JTime& mul(const double value)
96  {
97  __t *= value;
98 
99  return *this;
100  }
101 
102 
103  /**
104  * Division operator.
105  *
106  * \param value multiplication factor
107  * \return time
108  */
109  JTime& div(const double value)
110  {
111  __t /= value;
112 
113  return *this;
114  }
115 
116 
117  /**
118  * Set time.
119  *
120  * \param time
121  */
122  inline void setT(const double time)
123  {
124  __t = time;
125  }
126 
127 
128  /**
129  * Get time.
130  *
131  * \return time
132  */
133  inline double getT() const
134  {
135  return __t;
136  }
137 
138 
139  /**
140  * Read time from input.
141  *
142  * \param in input stream
143  * \param time time
144  * \return input stream
145  */
146  friend inline std::istream& operator>>(std::istream& in, JTime& time)
147  {
148  in >> time.__t;
149 
150  return in;
151  }
152 
153 
154  /**
155  * Write time to output.
156  *
157  * \param out output stream
158  * \param time time
159  * \return output stream
160  */
161  friend inline std::ostream& operator<<(std::ostream& out, const JTime& time)
162  {
163  const JFormat format(out, getFormat<JTime>(JFormat_t(9, 3, std::ios::fixed | std::ios::showpos)));
164 
165  out << time.__t;
166 
167  return out;
168  }
169 
170 
171  /**
172  * Read time from input.
173  *
174  * \param in reader
175  * \param time time
176  * \return reader
177  */
178  friend inline JReader& operator>>(JReader& in, JTime& time)
179  {
180  in >> time.__t;
181 
182  return in;
183  }
184 
185 
186  /**
187  * Write time to output.
188  *
189  * \param out writer
190  * \param time time
191  * \return writer
192  */
193  friend inline JWriter& operator<<(JWriter& out, const JTime& time)
194  {
195  out << time.__t;
196 
197  return out;
198  }
199 
200 
201  protected:
202  double __t;
203  };
204 }
205 
206 #endif
Interface for binary output.
double getT() const
Get time.
JTime & sub(const JTime &value)
Subtraction operator.
JTime & div(const double value)
Division operator.
JTime & negate()
Prefix unary minus.
JTime()
Default constructor.
Auxiliary class to temporarily define format specifications.
Definition: JManip.hh:634
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.
void setT(const double time)
Set time.
I/O manipulators.
friend std::ostream & operator<<(std::ostream &out, const JTime &time)
Write time to output.
JTime(const double t)
Constructor.
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:48
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.
Data structure for format specifications.
Definition: JManip.hh:524