28 #ifndef ROSCPP_SUBSCRIPTION_CALLBACK_HELPER_H 29 #define ROSCPP_SUBSCRIPTION_CALLBACK_HELPER_H 42 #include <boost/type_traits/add_const.hpp> 43 #include <boost/type_traits/remove_const.hpp> 44 #include <boost/type_traits/remove_reference.hpp> 45 #include <boost/type_traits/is_base_of.hpp> 46 #include <boost/utility/enable_if.hpp> 47 #include <boost/make_shared.hpp> 75 virtual const std::type_info& getTypeInfo() = 0;
76 virtual bool isConst() = 0;
86 template<
typename P,
typename Enabled =
void>
93 typedef typename boost::add_const<NonConstType>::type
ConstType;
99 typedef boost::function<void(typename Adapter::Parameter)>
Callback;
104 : callback_(callback)
115 return message_traits::hasHeader<typename ParameterAdapter<P>::Message>();
120 namespace ser = serialization;
122 NonConstTypePtr msg = create_();
126 ROS_DEBUG(
"Allocation failed for message of type [%s]", getTypeInfo().name());
130 ser::PreDeserializeParams<NonConstType> predes_params;
131 predes_params.message = msg;
133 ser::PreDeserialize<NonConstType>::notify(predes_params);
136 ser::deserialize(stream, *msg);
143 Event event(params.
event, create_);
149 return typeid(NonConstType);
164 #endif // ROSCPP_SUBSCRIPTION_CALLBACK_HELPER_H
boost::add_const< NonConstType >::type ConstType
boost::shared_ptr< void const > VoidConstPtr
SubscriptionCallbackHelperT(const Callback &callback, const CreateFunction &create=DefaultMessageCreator< NonConstType >())
virtual void call(SubscriptionCallbackHelperCallParams ¶ms)
Abstract base class used by subscriptions to deal with concrete message types through a common interf...
ParameterAdapter< P >::Event Event
bool call(const std::string &service_name, MReq &req, MRes &res)
Invoke an RPC service.
virtual const std::type_info & getTypeInfo()
Concrete generic implementation of SubscriptionCallbackHelper for any normal message type...
virtual VoidConstPtr deserialize(const SubscriptionCallbackHelperDeserializeParams ¶ms)
boost::shared_ptr< SubscriptionCallbackHelper > SubscriptionCallbackHelperPtr
boost::remove_reference< typename boost::remove_const< M >::type >::type Message
ParameterAdapter< P >::Message NonConstType
boost::function< NonConstTypePtr()> CreateFunction
boost::shared_ptr< M_string > connection_header
boost::function< void(typename Adapter::Parameter)> Callback
Generally not for outside use. Adapts a function parameter type into the message type, event type and parameter. Allows you to retrieve a parameter type from an event type.
boost::shared_ptr< NonConstType > NonConstTypePtr
boost::shared_ptr< ConstType > ConstTypePtr
MessageEvent< void const > event
void deserialize(Stream &stream, T &t)
void setCreateFunction(const CreateFunction &create)
ParameterAdapter< P > Adapter
virtual ~SubscriptionCallbackHelper()