All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Timer.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2014 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 
25 #include "gazebo/common/Console.hh"
26 #include "gazebo/common/Time.hh"
27 #include "gazebo/util/system.hh"
28 
29 namespace gazebo
30 {
31  namespace common
32  {
35 
39  {
41  public: Timer();
42 
44  public: virtual ~Timer();
45 
47  public: virtual void Start();
48 
50  public: virtual void Stop();
51 
54  public: bool GetRunning() const;
55 
58  public: Time GetElapsed() const;
59 
61  public: friend std::ostream &operator<<(std::ostream &out,
62  const gazebo::common::Timer &t)
63  {
64  out << t.GetElapsed();
65  return out;
66  }
67 
69  private: Time start;
70 
72  private: Time stop;
73 
75  private: bool running;
76  };
78  }
79 }
80 #endif
81 
82 
Time GetElapsed() const
Get the elapsed time.
A timer class, used to time things in real world walltime.
Definition: Timer.hh:38
GAZEBO_VISIBLE void stop()
friend std::ostream & operator<<(std::ostream &out, const gazebo::common::Timer &t)
Stream operator friendly.
Definition: Timer.hh:61
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:48
A Time class, can be used to hold wall- or sim-time.
Definition: Time.hh:43