Kea 2.2.0
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
13namespace isc {
14namespace util {
15
29public:
30
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
90protected:
91
103 virtual boost::posix_time::ptime getCurrentTime() const;
104
105private:
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
Stopwatch class implementation.
void start()
Starts the stopwatch.
virtual ~StopwatchImpl()
Virtual destructor.
boost::posix_time::time_duration getTotalDuration() const
Retrieves the total measured duration.
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.
void reset()
Reset the stopwatch.
virtual boost::posix_time::ptime getCurrentTime() const
Returns the current time.
void stop()
Stop the stopwatch.
boost::posix_time::time_duration getLastDuration() const
Retrieves the measured duration.
Defines the logger used by the top-level component of kea-lfc.