Instrument Neutral Distributed Interface INDI  2.0.2
indielapsedtimer.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2021 by Pawel Soja <kernel32.pl@gmail.com>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Lesser General Public
6  License as published by the Free Software Foundation; either
7  version 2.1 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Lesser General Public License for more details.
13 
14  You should have received a copy of the GNU Lesser General Public
15  License along with this library; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
19 #pragma once
20 
21 #include "indimacros.h"
22 #include <cstdint>
23 #include <memory>
24 
25 namespace INDI
26 {
27 
28 class ElapsedTimerPrivate;
36 {
37  DECLARE_PRIVATE(ElapsedTimer)
38  public:
39  ElapsedTimer();
40  virtual ~ElapsedTimer();
41 
42  public:
44  void start();
45 
47  int64_t restart();
48 
49  public:
51  int64_t elapsed() const;
52 
54  int64_t nsecsElapsed() const;
55 
57  bool hasExpired(int64_t timeout) const;
58 
59  public:
61  void nsecsRewind(int64_t nsecs);
62 
63  protected:
64  std::unique_ptr<ElapsedTimerPrivate> d_ptr;
66 };
67 
68 }
The ElapsedTimer class provides a fast way to calculate elapsed times.
int64_t nsecsElapsed() const
Returns the number of nanoseconds since this ElapsedTimer was last started.
int64_t elapsed() const
Returns the number of milliseconds since this ElapsedTimer was last started.
int64_t restart()
Restarts the timer and returns the number of milliseconds elapsed since the previous start.
void nsecsRewind(int64_t nsecs)
Rewind elapsed time of nsec nanoseconds.
bool hasExpired(int64_t timeout) const
Returns true if this ElapsedTimer has already expired by timeout milliseconds.
void start()
Starts this timer. Once started, a timer value can be checked with elapsed().
std::unique_ptr< ElapsedTimerPrivate > d_ptr
Namespace to encapsulate INDI client, drivers, and mediator classes.