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


sick_scan_xd
Author(s): Michael Lehning , Jochen Sprickerhof , Martin Günther
autogenerated on Fri Oct 25 2024 02:47:12