steady_timer.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017, Felix Ruess, Roboception GmbH
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  * * Redistributions of source code must retain the above copyright notice,
7  * this list of conditions and the following disclaimer.
8  * * Redistributions in binary form must reproduce the above copyright
9  * notice, this list of conditions and the following disclaimer in the
10  * documentation and/or other materials provided with the distribution.
11  * * Neither the names of Stanford University or Willow Garage, Inc. nor the names of its
12  * contributors may be used to endorse or promote products derived from
13  * this software without specific prior written permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25  * POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #ifndef ROSCPP_STEADY_TIMER_H
29 #define ROSCPP_STEADY_TIMER_H
30 
31 #include "common.h"
32 #include "forwards.h"
33 #include "steady_timer_options.h"
34 
35 namespace ros
36 {
37 
46 class ROSCPP_DECL SteadyTimer
47 {
48 public:
50  SteadyTimer(const SteadyTimer& rhs);
51  ~SteadyTimer();
52  SteadyTimer& operator=(const SteadyTimer& other) = default;
53 
57  void start();
62  void stop();
63 
67  bool hasPending();
68 
73  void setPeriod(const WallDuration& period, bool reset=true);
74 
75  bool hasStarted() const { return impl_ && impl_->hasStarted(); }
76  bool isValid() { return impl_ && impl_->isValid(); }
77  operator void*() { return isValid() ? (void *) 1 : (void *) 0; }
78 
79  bool operator<(const SteadyTimer& rhs)
80  {
81  return impl_ < rhs.impl_;
82  }
83 
84  bool operator==(const SteadyTimer& rhs)
85  {
86  return impl_ == rhs.impl_;
87  }
88 
89  bool operator!=(const SteadyTimer& rhs)
90  {
91  return impl_ != rhs.impl_;
92  }
93 
94 private:
95  SteadyTimer(const SteadyTimerOptions& ops);
96 
97  class Impl
98  {
99  public:
100  Impl();
101  ~Impl();
102 
103  bool hasStarted() const;
104  bool isValid();
105  bool hasPending();
106  void setPeriod(const WallDuration &period, bool reset=true);
107 
108  void start();
109  void stop();
110 
111  bool started_;
112  int32_t timer_handle_;
113 
119  bool oneshot_;
120  };
122  typedef boost::weak_ptr<Impl> ImplWPtr;
123 
125 
126  friend class NodeHandle;
127 };
128 
129 }
130 
131 #endif
ros::SteadyTimer::Impl::has_tracked_object_
bool has_tracked_object_
Definition: steady_timer.h:118
boost::shared_ptr< Impl >
forwards.h
ros::SteadyTimer::Impl::callback_queue_
CallbackQueueInterface * callback_queue_
Definition: steady_timer.h:116
ros::SteadyTimer::operator==
bool operator==(const SteadyTimer &rhs)
Definition: steady_timer.h:84
ros::SteadyTimer::ImplWPtr
boost::weak_ptr< Impl > ImplWPtr
Definition: steady_timer.h:122
ros::SteadyTimer::hasStarted
bool hasStarted() const
Definition: steady_timer.h:75
ros
ros::SteadyTimer::Impl::timer_handle_
int32_t timer_handle_
Definition: steady_timer.h:112
ros::SteadyTimer::isValid
bool isValid()
Definition: steady_timer.h:76
ros::SteadyTimer::Impl
Definition: steady_timer.h:97
steady_timer_options.h
ros::SteadyTimer::ImplPtr
boost::shared_ptr< Impl > ImplPtr
Definition: steady_timer.h:121
ros::SteadyTimer::operator<
bool operator<(const SteadyTimer &rhs)
Definition: steady_timer.h:79
ros::NodeHandle
roscpp's interface for creating subscribers, publishers, etc.
Definition: node_handle.h:85
ros::VoidConstWPtr
boost::weak_ptr< void const > VoidConstWPtr
Definition: forwards.h:53
ros::SteadyTimerCallback
boost::function< void(const SteadyTimerEvent &)> SteadyTimerCallback
Definition: forwards.h:187
ros::start
ROSCPP_DECL void start()
Actually starts the internals of the node (spins up threads, starts the network polling and xmlrpc lo...
Definition: init.cpp:294
ros::SteadyTimer::Impl::callback_
SteadyTimerCallback callback_
Definition: steady_timer.h:115
ros::SteadyTimerOptions
Encapsulates all options available for starting a timer.
Definition: steady_timer_options.h:40
ros::SteadyTimer::operator!=
bool operator!=(const SteadyTimer &rhs)
Definition: steady_timer.h:89
ros::SteadyTimer::SteadyTimer
SteadyTimer()
Definition: steady_timer.h:49
ros::SteadyTimer::Impl::oneshot_
bool oneshot_
Definition: steady_timer.h:119
ros::WallDuration
ros::SteadyTimer::Impl::started_
bool started_
Definition: steady_timer.h:111
ros::SteadyTimer::Impl::period_
WallDuration period_
Definition: steady_timer.h:114
ros::SteadyTimer::impl_
ImplPtr impl_
Definition: steady_timer.h:124
ros::SteadyTimer
Manages a steady-clock timer callback.
Definition: steady_timer.h:46
ros::SteadyTimer::Impl::tracked_object_
VoidConstWPtr tracked_object_
Definition: steady_timer.h:117
ros::CallbackQueueInterface
Abstract interface for a queue used to handle all callbacks within roscpp.
Definition: callback_queue_interface.h:82


roscpp
Author(s): Morgan Quigley, Josh Faust, Brian Gerkey, Troy Straszheim, Dirk Thomas , Jacob Perron
autogenerated on Sat Sep 14 2024 02:59:35