subscribe_options.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 Stanford University or 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_SUBSCRIBE_OPTIONS_H
30 #define ROSCPP_SUBSCRIBE_OPTIONS_H
31 
32 #include "ros/forwards.h"
33 #include "common.h"
34 #include "ros/transport_hints.h"
35 #include "ros/message_traits.h"
37 
38 namespace roswrap
39 {
40 
45 {
50  : queue_size(1)
51  , callback_queue(0)
52  , allow_concurrent_callbacks(false)
53  {
54  }
55 
65  SubscribeOptions(const std::string& _topic, uint32_t _queue_size, const std::string& _md5sum, const std::string& _datatype)
66  : topic(_topic)
67  , queue_size(_queue_size)
68  , md5sum(_md5sum)
69  , datatype(_datatype)
70  , callback_queue(0)
71  , allow_concurrent_callbacks(false)
72  {}
73 
82  template<class P>
83  void initByFullCallbackType(const std::string& _topic, uint32_t _queue_size,
84  const std::function<void (P)>& _callback,
85  const std::function<std::shared_ptr<typename ParameterAdapter<P>::Message>(void)>& factory_fn = DefaultMessageCreator<typename ParameterAdapter<P>::Message>())
86  {
87  typedef typename ParameterAdapter<P>::Message MessageType;
88  topic = _topic;
89  queue_size = _queue_size;
90  md5sum = message_traits::md5sum<MessageType>();
91  datatype = message_traits::datatype<MessageType>();
92  helper = std::make_shared<SubscriptionCallbackHelperT<P> >(_callback, factory_fn);
93  }
94 
103  template<class M>
104  void init(const std::string& _topic, uint32_t _queue_size,
105  const std::function<void (const std::shared_ptr<M const>&)>& _callback,
106  const std::function<std::shared_ptr<M>(void)>& factory_fn = DefaultMessageCreator<M>())
107  {
108  typedef typename ParameterAdapter<M>::Message MessageType;
109  topic = _topic;
110  queue_size = _queue_size;
111  md5sum = message_traits::md5sum<MessageType>();
112  datatype = message_traits::datatype<MessageType>();
113  helper = std::make_shared<SubscriptionCallbackHelperT<const std::shared_ptr<MessageType const>&> >(_callback, factory_fn);
114  }
115 
116  std::string topic;
117  uint32_t queue_size;
118 
119  std::string md5sum;
120  std::string datatype;
121 
123 
125 
129 
141 
143 
154  template<class M>
155  static SubscribeOptions create(const std::string& topic, uint32_t queue_size,
156  const std::function<void (const std::shared_ptr<M const>&)>& callback,
157  const VoidConstPtr& tracked_object, CallbackQueueInterface* queue)
158  {
159  SubscribeOptions ops;
160  ops.init<M>(topic, queue_size, callback);
161  ops.tracked_object = tracked_object;
162  ops.callback_queue = queue;
163  return ops;
164  }
165 };
166 
167 }
168 
169 #endif
170 
171 
roswrap::message_traits::md5sum
const char * md5sum()
returns MD5Sum<M>::value();
Definition: message_traits.h:227
roswrap::SubscribeOptions::md5sum
std::string md5sum
MD5 of the message datatype.
Definition: subscribe_options.h:119
roswrap::SubscribeOptions::initByFullCallbackType
void initByFullCallbackType(const std::string &_topic, uint32_t _queue_size, const std::function< void(P)> &_callback, const std::function< std::shared_ptr< typename ParameterAdapter< P >::Message >(void)> &factory_fn=DefaultMessageCreator< typename ParameterAdapter< P >::Message >())
Templated initialization, templated on callback parameter type. Supports any callback parameters supp...
Definition: subscribe_options.h:83
roswrap::SubscribeOptions::create
static SubscribeOptions create(const std::string &topic, uint32_t queue_size, const std::function< void(const std::shared_ptr< M const > &)> &callback, const VoidConstPtr &tracked_object, CallbackQueueInterface *queue)
Templated helper function for creating an AdvertiseServiceOptions with most of its options.
Definition: subscribe_options.h:155
roswrap::SubscribeOptions::transport_hints
TransportHints transport_hints
Hints for transport type and options.
Definition: subscribe_options.h:142
roswrap::message_traits::datatype
const char * datatype()
returns DataType<M>::value();
Definition: message_traits.h:236
subscription_callback_helper.h
roswrap::SubscribeOptions::datatype
std::string datatype
Datatype of the message we'd like to subscribe as.
Definition: subscribe_options.h:120
roswrap::SubscribeOptions::helper
SubscriptionCallbackHelperPtr helper
Helper object used to get create messages and call callbacks.
Definition: subscribe_options.h:122
roswrap::SubscribeOptions::allow_concurrent_callbacks
bool allow_concurrent_callbacks
Definition: subscribe_options.h:128
roswrap::SubscriptionCallbackHelperPtr
std::shared_ptr< SubscriptionCallbackHelper > SubscriptionCallbackHelperPtr
Definition: message_deserializer.h:43
sick_scan_xd_api_test.queue_size
queue_size
Definition: sick_scan_xd_api_test.py:353
roswrap::DefaultMessageCreator
Definition: message_event.h:50
roswrap::SubscribeOptions::topic
std::string topic
Topic to subscribe to.
Definition: subscribe_options.h:116
roswrap::CallbackQueueInterface
Abstract interface for a queue used to handle all callbacks within roscpp.
Definition: callback_queue_interface.h:83
roswrap::SubscribeOptions::init
void init(const std::string &_topic, uint32_t _queue_size, const std::function< void(const std::shared_ptr< M const > &)> &_callback, const std::function< std::shared_ptr< M >(void)> &factory_fn=DefaultMessageCreator< M >())
Templated initialization, templated on message type. Only supports "const std::shared_ptr<M const>&" ...
Definition: subscribe_options.h:104
roswrap
Definition: param_modi.cpp:41
roswrap::SubscribeOptions::queue_size
uint32_t queue_size
Number of incoming messages to queue up for processing (messages in excess of this queue capacity wil...
Definition: subscribe_options.h:117
common.h
roswrap::SubscribeOptions::callback_queue
CallbackQueueInterface * callback_queue
Queue to add callbacks to. If NULL, the global callback queue will be used.
Definition: subscribe_options.h:124
roswrap::SubscribeOptions::SubscribeOptions
SubscribeOptions()
Definition: subscribe_options.h:49
roswrap::TransportHints
Provides a way of specifying network transport hints to ros::NodeHandle::subscribe() and someday ros:...
Definition: transport_hints.h:55
sick_scan_base.h
roswrap::SubscribeOptions::SubscribeOptions
SubscribeOptions(const std::string &_topic, uint32_t _queue_size, const std::string &_md5sum, const std::string &_datatype)
Constructor.
Definition: subscribe_options.h:65
ROSCPP_DECL
#define ROSCPP_DECL
Definition: roswrap/src/cfgsimu/sick_scan/ros/common.h:63
roswrap::SubscribeOptions
Encapsulates all options available for creating a Subscriber.
Definition: subscribe_options.h:44
roswrap::SubscribeOptions::tracked_object
VoidConstPtr tracked_object
An object whose destruction will prevent the callback associated with this subscription.
Definition: subscribe_options.h:140
roswrap::ParameterAdapter::Message
std::remove_reference< typename std::remove_const< M >::type >::type Message
Definition: parameter_adapter.h:72
roswrap::VoidConstPtr
std::shared_ptr< void const > VoidConstPtr
Definition: forwards.h:54
callback
void callback(const sick_scan_xd::RadarScan::ConstPtr &oa)
Definition: radar_object_marker.cpp:157


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