Kea  1.9.9-git
stopwatch_impl.h
Go to the documentation of this file.
1 // Copyright (C) 2015,2017 Internet Systems Consortium, Inc. ("ISC")
2 //
3 // This Source Code Form is subject to the terms of the Mozilla Public
4 // License, v. 2.0. If a copy of the MPL was not distributed with this
5 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 
7 #ifndef STOPWATCH_IMPL_H
8 #define STOPWATCH_IMPL_H
9 
10 #include <boost/date_time/posix_time/posix_time.hpp>
11 #include <boost/scoped_ptr.hpp>
12 
13 namespace isc {
14 namespace util {
15 
29 public:
30 
35  StopwatchImpl();
36 
41  virtual ~StopwatchImpl();
42 
50  void start();
51 
60  void stop();
61 
65  void reset();
66 
70  boost::posix_time::time_duration getLastDuration() const;
71 
75  boost::posix_time::time_duration getTotalDuration() const;
76 
87  static std::string
88  logFormat(const boost::posix_time::time_duration& duration);
89 
90 protected:
91 
103  virtual boost::posix_time::ptime getCurrentTime() const;
104 
105 private:
106 
108  bool started_;
109 
111  boost::posix_time::ptime last_start_;
112 
114  boost::posix_time::ptime last_stop_;
115 
118  boost::posix_time::time_duration cumulative_time_;
119 
120 };
121 
122 }
123 }
124 
125 #endif // STOPWATCH_H
126 
virtual ~StopwatchImpl()
Virtual destructor.
boost::posix_time::time_duration getLastDuration() const
Retrieves the measured duration.
boost::posix_time::time_duration getTotalDuration() const
Retrieves the total measured duration.
void reset()
Reset the stopwatch.
void stop()
Stop the stopwatch.
Stopwatch class implementation.
void start()
Starts the stopwatch.
virtual boost::posix_time::ptime getCurrentTime() const
Returns the current time.
Defines the logger used by the top-level component of kea-dhcp-ddns.
static std::string logFormat(const boost::posix_time::time_duration &duration)
Returns the duration in the textual format which can be directly used in log messages.
StopwatchImpl()
Constructor.