sttcl  v0.9c
STTCL C++ template state machine framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SttclTime.h
Go to the documentation of this file.
1 
25 #ifndef STTCLTIME_H_
26 #define STTCLTIME_H_
27 
28 #ifndef STTCL_DEFAULT_TIMEDURATIONIMPL
29 #if defined(STTCL_POSIX_TIME) or defined(STTCL_POSIX_IMPL)
30 #include "../PosixTime/SttclPosixTime.h"
31 #define STTCL_DEFAULT_TIMEDURATIONIMPL sttcl::internal::posix_impl::SttclPosixTimeDuration
32 #elif defined(STTCL_BOOST_TIME) or defined(STTCL_BOOST_IMPL)
33 #include "../BoostTime/SttclBoostTime.h"
34 #define STTCL_DEFAULT_TIMEDURATIONIMPL sttcl::internal::boost_impl::SttclBoostTimeDuration
35 #elif defined(STTCL_CX11_TIME) or defined(STTCL_CX11_IMPL)
36 #include "../C++11Time/SttclCx11Time.h"
37 #define STTCL_DEFAULT_TIMEDURATIONIMPL sttcl::internal::cx11_impl::SttclCx11TimeDuration
38 #endif
39 
40 #ifndef STTCL_DEFAULT_TIMEDURATIONIMPL
41 #error "You need to define a default time duration implementation for sttcl"
42 #endif
43 #endif
44 
45 namespace sttcl
46 {
47 
54 template<class Implementation = STTCL_DEFAULT_TIMEDURATIONIMPL>
56 : public Implementation
57 {
58 public:
62  typedef typename Implementation::NativeTimeDuration NativeTimeDuration;
63 
68 
78  TimeDuration(unsigned int argHours = 0, unsigned int argMinutes = 0, unsigned int argSeconds = 0, unsigned int argMilliSeconds = 0, unsigned long argMicroSeconds = 0, unsigned long argNanoSeconds = 0)
79  : Implementation(argHours,argMinutes,argSeconds,argMilliSeconds,argMicroSeconds,argNanoSeconds)
80  {
81  }
82 
88  : Implementation(static_cast<const Implementation&>(rhs))
89  {
90  }
95  TimeDuration(const NativeTimeDuration& nativeTimeDuration)
96  : Implementation(nativeTimeDuration)
97  {
98  }
103  {
104  }
105 
112  {
113  Implementation::operator=(static_cast<const Implementation&>(rhs));
114  return *this;
115  }
116 
123  {
124  Implementation::operator=(static_cast<const Implementation&>(nativeTimeDuration));
125  return *this;
126  }
127 
134  {
135  return Implementation::operator==(static_cast<const Implementation&>(rhs));
136  }
143  {
144  return Implementation::operator!=(static_cast<const Implementation&>(rhs));
145  }
151  bool operator<(const TimeDuration<Implementation>& rhs) const
152  {
153  return Implementation::operator<(static_cast<const Implementation&>(rhs));
154  }
160  bool operator<=(const TimeDuration<Implementation>& rhs) const
161  {
162  return Implementation::operator<=(static_cast<const Implementation&>(rhs));
163  }
170  {
171  return Implementation::operator>(static_cast<const Implementation&>(rhs));
172  }
179  {
180  return Implementation::operator>=(static_cast<const Implementation&>(rhs));
181  }
182 
189  {
190  Implementation::operator+=(static_cast<const Implementation&>(rhs));
191  return *this;
192  }
193 
200  {
201  Implementation::operator-=(static_cast<const Implementation&>(rhs));
202  return *this;
203  }
204 
211  {
213  return *this;
214  }
215 
222  {
224  return *this;
225  }
226 
230  long hours() const
231  {
232  return Implementation::hours();
233  }
237  long minutes() const
238  {
239  return Implementation::minutes();
240  }
244  long seconds() const
245  {
246  return Implementation::seconds();
247  }
251  long milliseconds() const
252  {
254  }
258  long microseconds() const
259  {
261  }
265  long nanoseconds() const
266  {
268  }
269 
273  void hours(int newHours)
274  {
275  Implementation::hours(newHours);
276  }
280  void minutes(int newMinutes)
281  {
282  Implementation::minutes(newMinutes);
283  }
287  void seconds(int newSeconds)
288  {
289  Implementation::seconds(newSeconds);
290  }
291 
298  /*
299  void milliseconds(int newMilliSeconds)
300  {
301  Implementation::milliseconds(newMilliSeconds);
302  }
303  */
307  /*
308  void microseconds(int newMicroSeconds)
309  {
310  Implementation::microseconds(newMicroSeconds);
311  }
312  */
316  /*
317  void nanoseconds(long newNanoSeconds)
318  {
319  Implementation::nanoseconds(newNanoSeconds);
320  }
321  */
322 
328  {
330  }
331 };
332 
333 
334 }
335 
336 template<class Implementation>
338 {
340  return result += op2;
341 }
342 
343 template<class Implementation>
345 {
347  return result -= op2;
348 }
349 template<class Implementation>
351 {
353  return result *= op2;
354 }
355 template<class Implementation>
357 {
359  return result /= op2;
360 }
361 
362 template<class Implementation>
364 #endif /* STTCLTIME_H_ */