Computer Assited Medical Intervention Tool Kit  version 5.0
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-2021 Univ. Grenoble Alpes, CNRS, Grenoble INP, 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
Chrono::~Chrono
~Chrono()=default
Chrono::getTimeInMilliseconds
double getTimeInMilliseconds() const
in milliseconds
Definition: Chrono.cpp:151
Chrono::running
bool running
Definition: Chrono.h:98
Chrono
Elapsed real-time timer. Allows one to measure elapsed real time. You can start, stop,...
Definition: Chrono.h:40
Chrono::stopValue
double stopValue
Definition: Chrono.h:97
Chrono::operator<<
friend std::ostream & operator<<(std::ostream &, const Chrono)
print the value of the chrono on the stream
Definition: Chrono.cpp:164
Chrono.h
Chrono::accumulatedTime
double accumulatedTime
Definition: Chrono.h:99
operator<<
std::ostream & operator<<(std::ostream &o, const Chrono c)
Definition: Chrono.cpp:164
Chrono::stop
double stop()
stop chrono
Definition: Chrono.cpp:117
Chrono::startValue
double startValue
Definition: Chrono.h:96
Chrono::reset
void reset()
reset to zero
Definition: Chrono.cpp:135
Chrono::Chrono
Chrono()
default constructor
Definition: Chrono.cpp:89
Chrono::hold
void hold(bool)
pause the chrono if the parameter is true
Definition: Chrono.cpp:123
Chrono::get
double get() const
if running, get the value (start time - now) without stopping the chrono, else get (start time - stop...
Definition: Chrono.cpp:141
Chrono::start
void start()
start at zero
Definition: Chrono.cpp:104