Documentation of CSL
timeMonitor.h
Go to the documentation of this file.
1 // This file is part of MARTY.
2 //
3 // MARTY is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, either version 3 of the License, or
6 // (at your option) any later version.
7 //
8 // MARTY is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with MARTY. If not, see <https://www.gnu.org/licenses/>.
15 
23 #ifndef CSL_TIME_MONITOR_H_INCLUDED
24 #define CSL_TIME_MONITOR_H_INCLUDED
25 
26 #include <iostream>
27 #include <ctime>
28 
29 namespace csl {
30 
31 class TimeMonitor {
32 
33  public:
34 
35  static inline char separator = '\'';
36 
37  struct Time {
38 
39  size_t hour;
40  size_t min;
41  size_t sec;
42  };
43 
44  static void print(size_t nSec, std::ostream& out);
45  static Time processSec(size_t n_sec);
46 
47  public:
48 
49  TimeMonitor();
50 
51  void reset();
52  void print(std::ostream & out);
53 
54  size_t getHour() const {
55  return m_time.hour;
56  }
57 
58  size_t getMin() const {
59  return m_time.min;
60  }
61 
62  size_t getSec() const {
63  return m_time.sec;
64  }
65 
66  size_t getTotalSec() const {
67  return 3600 * m_time.hour + 60 * m_time.min + m_time.sec;
68  }
69 
70  protected:
71 
72  private:
73 
74  std::clock_t m_start;
75  Time m_time;
76 };
77 
78 }
79 
80 #endif
Namespace for csl library.
Definition: abreviation.h:34
Definition: timeMonitor.h:31
Definition: timeMonitor.h:37