Rsh API  SDK 2.1
Документация по программированию
 Указатель Классы Файлы Функции Переменные Определения типов Перечисления Элементы перечислений Друзья Макросы Страницы
RshTime.h
См. документацию.
1 
18 #ifndef RSH_TIME_H
19 #define RSH_TIME_H
20 
21 #include <RshDefChk.h>
22 
23 #include <ostream>
24 #include <string>
25 
26 #pragma pack(push, 8)
27 
46 class RshTime
47 {
48 
49  friend std::ostream& operator<< (std::ostream &out, const RshTime& obj);
50 
51 public:
52 
53  RshTime();
54 
55  RshTime(U8 hours, U8 minutes, U8 seconds = 0, U16 milliseconds = 0, U16 microseconds = 0);
56 
57  RshTime(const RshTime& obj);
58 
59  RshTime& operator=(const RshTime& obj);
60 
61  bool operator==(const RshTime& obj) const;
62  bool operator<(const RshTime& obj) const;
63 
64  bool operator!=(const RshTime& obj) const;
65 
66  bool operator>(const RshTime& obj) const;
67  bool operator<=(const RshTime& obj) const;
68  bool operator>=(const RshTime& obj) const;
69 
98  RshTime(double timeElapsed_s);
99 
124  static RshTime currentTime();
125 
160  std::string toString(const std::string& format=std::string("hh:mm:ss:zzz.uuu")) const;
161 
196  std::wstring toWString(const std::wstring& format=std::wstring(L"hh:mm:ss:zzz.uuu")) const;
197 
216  U64 toMicroSeconds() const;
217 
229  void setHMS(U8 hours, U8 minutes, U8 seconds = 0, U16 milliseconds = 0, U16 microseconds = 0);
230 
254  void setFromElapsed(double timeElapsed_s);
255 
267  U8 hours() { return h; }
268 
280  U8 minutes() { return m; }
281 
293  U8 seconds() { return s; }
294 
306  U16 milliSeconds() { return ms; }
307 
319  U16 microSeconds() { return us; }
320 
321 private:
333  U8 h;
334 
346  U8 m;
347 
359  U8 s;
360 
372  U16 ms;
373 
385  U16 us;
386 
387  //helper method to replace all substrings in string
388  static void replaceAll(std::string &s, const std::string &search, const std::string &replace);
389  static void replaceAll(std::wstring &s, const std::wstring &search, const std::wstring &replace);
390 
391  //helper method to calculate time in microseconds
392  void calculateTimeInMicroSeconds() const;
393 
394  mutable U64 m_hashedTimeInMicroSeconds;
395 };
396 
397 #pragma pack(pop)
398 #endif //RSH_TIME_H