Jpp  17.0.0
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  * Get time.
119  *
120  * \return time
121  */
122  inline double getT() const
123  {
124  return __t;
125  }
126 
127 
128  /**
129  * Read time from input.
130  *
131  * \param in input stream
132  * \param time time
133  * \return input stream
134  */
135  friend inline std::istream& operator>>(std::istream& in, JTime& time)
136  {
137  in >> time.__t;
138 
139  return in;
140  }
141 
142 
143  /**
144  * Write time to output.
145  *
146  * \param out output stream
147  * \param time time
148  * \return output stream
149  */
150  friend inline std::ostream& operator<<(std::ostream& out, const JTime& time)
151  {
152  const JFormat format(out, getFormat<JTime>(JFormat_t(9, 3, std::ios::fixed | std::ios::showpos)));
153 
154  out << time.__t;
155 
156  return out;
157  }
158 
159 
160  /**
161  * Read time from input.
162  *
163  * \param in reader
164  * \param time time
165  * \return reader
166  */
167  friend inline JReader& operator>>(JReader& in, JTime& time)
168  {
169  in >> time.__t;
170 
171  return in;
172  }
173 
174 
175  /**
176  * Write time to output.
177  *
178  * \param out writer
179  * \param time time
180  * \return writer
181  */
182  friend inline JWriter& operator<<(JWriter& out, const JTime& time)
183  {
184  out << time.__t;
185 
186  return out;
187  }
188 
189 
190  protected:
191  double __t;
192  };
193 }
194 
195 #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:632
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.
I/O manipulators.
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.
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:46
Data structure for format specifications.
Definition: JManip.hh:522