Gazebo Common

API Reference

4.7.0
gz/common/Timer.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef IGNITION_COMMON_TIMER_HH_
18 #define IGNITION_COMMON_TIMER_HH_
19 
20 #include <gz/common/config.hh>
21 #include <gz/common/Time.hh>
22 #include <gz/common/Export.hh>
23 
24 namespace ignition
25 {
26  namespace common
27  {
30  class IGNITION_COMMON_VISIBLE Timer
31  {
33  public: Timer();
34 
36  public: virtual ~Timer();
37 
39  public: virtual void Start();
40 
42  public: virtual void Stop();
43 
46  public: bool Running() const;
47 
50  public: Time IGN_DEPRECATED(4) Elapsed() const;
51 
54  public: std::chrono::duration<double> ElapsedTime() const;
55 
57  public: friend std::ostream &operator<<(std::ostream &out,
58  const ignition::common::Timer &t)
59  {
60  out << t.ElapsedTime().count();
61  return out;
62  }
63 
66  private: std::chrono::steady_clock::time_point start;
67 
69  private: std::chrono::steady_clock::time_point stop;
71 
73  private: bool running;
74  };
75  }
76 }
77 #endif
Forward declarations for the common classes.
virtual void Start()
Start the timer.
A Time class, can be used to hold wall- or sim-time. stored as sec and nano-sec.
Definition: gz/common/Time.hh:34
#define IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
Microsoft Visual Studio does not automatically export the interface information for member variables ...
Definition: gz/common/SuppressWarning.hh:65
std::chrono::duration< double > ElapsedTime() const
Get the elapsed time.
bool Running() const
Returns true if the timer is running.
STL class.
virtual ~Timer()
Destructor.
virtual void Stop()
Stop the timer.
A timer class, used to time things in real world walltime.
Definition: gz/common/Timer.hh:30
#define IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING
Definition: gz/common/SuppressWarning.hh:68
friend std::ostream & operator<<(std::ostream &out, const ignition::common::Timer &t)
Stream operator friendly.
Definition: gz/common/Timer.hh:57
Time Elapsed() const
Get the elapsed time.