Kea 2.7.6
stopwatch_impl.h
Go to the documentation of this file.
1// Copyright (C) 2015-2023 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
83 static std::string
84 logFormat(const boost::posix_time::time_duration& duration);
85
86protected:
87
99 virtual boost::posix_time::ptime getCurrentTime() const;
100
101private:
102
104 bool started_;
105
107 boost::posix_time::ptime last_start_;
108
110 boost::posix_time::ptime last_stop_;
111
114 boost::posix_time::time_duration cumulative_time_;
115
116};
117
118}
119}
120
121#endif // STOPWATCH_H
122
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.