wall_timer.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2009, Willow Garage, Inc.
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_WALL_TIMER_H
29 #define ROSCPP_WALL_TIMER_H
30 
31 #include "common.h"
32 #include "forwards.h"
33 #include "wall_timer_options.h"
34 
35 namespace ros
36 {
37 
46 class ROSCPP_DECL WallTimer
47 {
48 public:
49  WallTimer() {}
50  WallTimer(const WallTimer& rhs);
51  ~WallTimer();
52 
56  void start();
61  void stop();
62 
66  bool hasPending();
67 
72  void setPeriod(const WallDuration& period, bool reset=true);
73 
74  bool isValid() { return impl_ && impl_->isValid(); }
75  operator void*() { return isValid() ? (void*)1 : (void*)0; }
76 
77  bool operator<(const WallTimer& rhs)
78  {
79  return impl_ < rhs.impl_;
80  }
81 
82  bool operator==(const WallTimer& rhs)
83  {
84  return impl_ == rhs.impl_;
85  }
86 
87  bool operator!=(const WallTimer& rhs)
88  {
89  return impl_ != rhs.impl_;
90  }
91 
92 private:
93  WallTimer(const WallTimerOptions& ops);
94 
95  class Impl
96  {
97  public:
98  Impl();
99  ~Impl();
100 
101  bool isValid();
102  bool hasPending();
103  void setPeriod(const WallDuration& period, bool reset=true);
104 
105  void start();
106  void stop();
107 
108  bool started_;
109  int32_t timer_handle_;
110 
116  bool oneshot_;
117  };
119  typedef boost::weak_ptr<Impl> ImplWPtr;
120 
121  ImplPtr impl_;
122 
123  friend class NodeHandle;
124 };
125 
126 }
127 
128 #endif
ROSCPP_DECL void start()
Actually starts the internals of the node (spins up threads, starts the network polling and xmlrpc lo...
Definition: init.cpp:293
bool isValid()
Definition: wall_timer.h:74
Encapsulates all options available for starting a timer.
ImplPtr impl_
Definition: wall_timer.h:121
Abstract interface for a queue used to handle all callbacks within roscpp.
bool operator==(const WallTimer &rhs)
Definition: wall_timer.h:82
WallDuration period_
Definition: wall_timer.h:111
boost::weak_ptr< void const > VoidConstWPtr
Definition: forwards.h:53
roscpp&#39;s interface for creating subscribers, publishers, etc.
Definition: node_handle.h:87
WallTimerCallback callback_
Definition: wall_timer.h:112
CallbackQueueInterface * callback_queue_
Definition: wall_timer.h:113
boost::shared_ptr< Impl > ImplPtr
Definition: wall_timer.h:118
bool operator!=(const WallTimer &rhs)
Definition: wall_timer.h:87
VoidConstWPtr tracked_object_
Definition: wall_timer.h:114
boost::function< void(const WallTimerEvent &)> WallTimerCallback
Definition: forwards.h:162
bool operator<(const WallTimer &rhs)
Definition: wall_timer.h:77
Manages a wall-clock timer callback.
Definition: wall_timer.h:46
boost::weak_ptr< Impl > ImplWPtr
Definition: wall_timer.h:119


roscpp
Author(s): Morgan Quigley, Josh Faust, Brian Gerkey, Troy Straszheim
autogenerated on Wed Dec 20 2017 03:58:41