source: src/Helpers/Chronos.hpp@ 93abe8

Last change on this file since 93abe8 was 93abe8, checked in by Frederik Heber <heber@…>, 15 years ago

Added static and private object counter Info::NumberInfos.

  • Property mode set to 100644
File size: 2.0 KB
Line 
1/*
2 * Chronos.hpp
3 *
4 * Created on: Mar 14, 2011
5 * Author: heber
6 */
7
8#ifndef CHRONOS_HPP_
9#define CHRONOS_HPP_
10
11// include config.h
12#ifdef HAVE_CONFIG_H
13#include <config.h>
14#endif
15
16#include <iosfwd>
17#include <map>
18
19#include "Singleton.hpp"
20
21class ChronosTest;
22
23class Chronos : public Singleton<Chronos>{
24 //!> Singleton pattern needs private access
25 friend class Singleton<Chronos>;
26 //!> unit tests needs access to private members
27 friend class ChronosTest;
28public :
29
30 /** Returns current kept time of function \a _name.
31 *
32 * @param _name name of function
33 * @return current amount of time passed for this function, 0 if unknown, -1 if currently running
34 */
35 int getTime(const std::string _name) const;
36
37 /** Resets time counter for this function \a _name to zero.
38 *
39 * @param _name name of function
40 */
41 void resetTime(const std::string _name);
42
43 /** Starts Timing for this function \a _name.
44 *
45 * @param _name name of function
46 */
47 void startTiming(const std::string _name);
48
49 /** Finishes Timing for this function \a _name.
50 *
51 * @param _name name of function
52 */
53 void endTiming(const std::string _name);
54
55 /** Sums up total time accounted for.
56 *
57 * @return total time
58 */
59 int SumUpTotalTime() const;
60
61 /** Sums up all functions accounted.
62 *
63 * @return number of functions
64 */
65 size_t SumUpTotalFunctions() const;
66
67protected:
68 /** Do not call this constructor directly, use getInstance() instead. */
69 Chronos();
70 /** Do not call this destructor directly, use purgeInstance() instead. */
71 ~Chronos();
72
73private:
74
75 typedef std::map<const std::string, int> TimekeepingMap;
76 typedef std::map<const std::string, bool> TimerStatusMap;
77
78 TimekeepingMap AccountedTime;
79 TimerStatusMap IsTimeRunning;
80};
81
82/** Output for Chronos.
83 *
84 * @param ost output stream
85 * @param _time Chronos to print
86 * @return reference to given output stream for concatenation
87 */
88std::ostream& operator<<(std::ostream &ost, const Chronos &_time);
89
90#endif /* CHRONOS_HPP_ */
Note: See TracBrowser for help on using the repository browser.