Computer Assisted Medical Intervention Tool Kit  version 5.2
Chrono.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * $CAMITK_LICENCE_BEGIN$
3  *
4  * CamiTK - Computer Assisted Medical Intervention ToolKit
5  * (c) 2001-2024 Univ. Grenoble Alpes, CNRS, Grenoble INP - UGA, TIMC, 38000 Grenoble, France
6  *
7  * Visit http://camitk.imag.fr for more information
8  *
9  * This file is part of CamiTK.
10  *
11  * CamiTK is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * CamiTK is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Lesser General Public License version 3 for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
22  *
23  * $CAMITK_LICENCE_END$
24  ****************************************************************************/
25 
26 
27 #ifndef TOOLS_CHRONO_H
28 #define TOOLS_CHRONO_H
29 
30 #include <iostream>
40 class Chrono {
41 public:
43  Chrono();
45  Chrono(double);
46 
47  ~Chrono() = default;
48 
50  void start();
52  void start(double);
54  double stop();
55 
57  void hold(bool);
58 
60  void reset();
61 
67  double get() const;
68 
70  friend std::ostream& operator << (std::ostream&, const Chrono);
71 
72 private:
73  double startValue;
74  double stopValue;
75  bool running;
76  double accumulatedTime;
77 
79  double getTimeInMilliseconds() const;
80 };
81 
82 #endif // TOOLS_CHRONO_H
Elapsed real-time timer.
Definition: Chrono.h:40
void reset()
reset to zero
Definition: Chrono.cpp:135
double stop()
stop chrono
Definition: Chrono.cpp:117
void start()
start at zero
Definition: Chrono.cpp:104
void hold(bool)
pause the chrono if the parameter is true
Definition: Chrono.cpp:123
Chrono()
default constructor
Definition: Chrono.cpp:89
~Chrono()=default
friend std::ostream & operator<<(std::ostream &, const Chrono)
print the value of the chrono on the stream
Definition: Chrono.cpp:164
double get() const
if running, get the value (start time - now) without stopping the chrono, else get (start time - stop...
Definition: Chrono.cpp:141