Computer Assited Medical Intervention Tool Kit  version 4.1
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-2018 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
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;
77 
79  double getTimeInMilliseconds() const;
80 };
81 
82 #endif // TOOLS_CHRONO_H
Elapsed real-time timer.
Definition: Chrono.h:40
double accumulatedTime
Definition: Chrono.h:76
double stop()
stop chrono
Definition: Chrono.cpp:117
double startValue
Definition: Chrono.h:73
double stopValue
Definition: Chrono.h:74
void reset()
reset to zero
Definition: Chrono.cpp:135
void hold(bool)
pause the chrono if the parameter is true
Definition: Chrono.cpp:123
friend std::ostream & operator<<(std::ostream &, const Chrono)
print the value of the chrono on the stream
Definition: Chrono.cpp:164
void start()
start at zero
Definition: Chrono.cpp:104
Chrono()
default constructor
Definition: Chrono.cpp:89
double getTimeInMilliseconds() const
in milliseconds
Definition: Chrono.cpp:151
~Chrono()=default
bool running
Definition: Chrono.h:75