Timer.hh
Go to the documentation of this file.
1/*
2 * Copyright (C) 2012 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/* Desc: A timer class
18 * Author: Nate Koenig
19 * Date: 22 Nov 2009
20 */
21
22#ifndef _TIMER_HH_
23#define _TIMER_HH_
24
26#include "gazebo/common/Time.hh"
27#include "gazebo/util/system.hh"
28
29namespace gazebo
30{
31 namespace common
32 {
35
38 class GZ_COMMON_VISIBLE Timer
39 {
41 public: Timer();
42
47 public: Timer(const Time &_maxTime, const bool _countdown = true);
48
50 public: virtual ~Timer();
51
53 public: virtual void Start();
54
56 public: virtual void Stop();
57
60 public: bool GetRunning() const;
61
64 public: Time GetElapsed() const;
65
67 public: void Reset();
68
70 public: friend std::ostream &operator<<(std::ostream &out,
71 const gazebo::common::Timer &t)
72 {
73 out << t.GetElapsed();
74 return out;
75 }
76
78 private: bool reset;
79
81 private: bool running;
82
85 private: bool countdown;
86
88 private: Time start;
89
91 private: Time stop;
92
94 private: Time maxTime;
95 };
97 }
98}
99#endif
100
101
common
Definition FuelModelDatabase.hh:37
A Time class, can be used to hold wall- or sim-time.
Definition Time.hh:48
A timer class, used to time things in real world walltime.
Definition Timer.hh:39
void Reset()
Reset the timer.
Time GetElapsed() const
Get the elapsed time.
bool GetRunning() const
Returns true if the timer is running.
Timer()
Default constructor.
virtual ~Timer()
Destructor.
friend std::ostream & operator<<(std::ostream &out, const gazebo::common::Timer &t)
Stream operator friendly.
Definition Timer.hh:70
virtual void Start()
Start the timer.
Timer(const Time &_maxTime, const bool _countdown=true)
Countdown constructor.
virtual void Stop()
Stop the timer.
Forward declarations for the common classes.
Definition Animation.hh:27