parameter_adapter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2010, 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_PARAMETER_ADAPTER_H
29 #define ROSCPP_PARAMETER_ADAPTER_H
30 
31 #include "ros/forwards.h"
32 #include "ros/message_event.h"
33 #include <ros/static_assert.h>
34 
35 #include <boost/type_traits/add_const.hpp>
36 #include <boost/type_traits/remove_const.hpp>
37 #include <boost/type_traits/remove_reference.hpp>
38 
39 namespace ros
40 {
41 
68 template<typename M>
70 {
71  typedef typename boost::remove_reference<typename boost::remove_const<M>::type>::type Message;
73  typedef M Parameter;
74  static const bool is_const = true;
75 
76  static Parameter getParameter(const Event& event)
77  {
78  return *event.getMessage();
79  }
80 };
81 
82 template<typename M>
83 struct ParameterAdapter<const boost::shared_ptr<M const>& >
84 {
85  typedef typename boost::remove_reference<typename boost::remove_const<M>::type>::type Message;
88  static const bool is_const = true;
89 
90  static Parameter getParameter(const Event& event)
91  {
92  return event.getMessage();
93  }
94 };
95 
96 template<typename M>
97 struct ParameterAdapter<const boost::shared_ptr<M>& >
98 {
99  typedef typename boost::remove_reference<typename boost::remove_const<M>::type>::type Message;
102  static const bool is_const = false;
103 
104  static Parameter getParameter(const Event& event)
105  {
106  return ros::MessageEvent<Message>(event).getMessage();
107  }
108 };
109 
110 template<typename M>
111 struct ParameterAdapter<const M&>
112 {
113  typedef typename boost::remove_reference<typename boost::remove_const<M>::type>::type Message;
115  typedef const M& Parameter;
116  static const bool is_const = true;
117 
118  static Parameter getParameter(const Event& event)
119  {
120  return *event.getMessage();
121  }
122 };
123 
124 template<typename M>
125 struct ParameterAdapter<boost::shared_ptr<M const> >
126 {
127  typedef typename boost::remove_reference<typename boost::remove_const<M>::type>::type Message;
130  static const bool is_const = true;
131 
132  static Parameter getParameter(const Event& event)
133  {
134  return event.getMessage();
135  }
136 };
137 
138 template<typename M>
139 struct ParameterAdapter<boost::shared_ptr<M> >
140 {
141  typedef typename boost::remove_reference<typename boost::remove_const<M>::type>::type Message;
144  static const bool is_const = false;
145 
146  static Parameter getParameter(const Event& event)
147  {
148  return ros::MessageEvent<Message>(event).getMessage();
149  }
150 };
151 
152 template<typename M>
153 struct ParameterAdapter<const ros::MessageEvent<M const>& >
154 {
155  typedef typename boost::remove_reference<typename boost::remove_const<M>::type>::type Message;
158  static const bool is_const = true;
159 
160  static Parameter getParameter(const Event& event)
161  {
162  return event;
163  }
164 };
165 
166 template<typename M>
167 struct ParameterAdapter<const ros::MessageEvent<M>& >
168 {
169  typedef typename boost::remove_reference<typename boost::remove_const<M>::type>::type Message;
172  static const bool is_const = false;
173 
174  static Parameter getParameter(const Event& event)
175  {
176  return ros::MessageEvent<Message>(event);
177  }
178 };
179 
180 }
181 
182 #endif // ROSCPP_PARAMETER_ADAPTER_H
boost::remove_reference< typename boost::remove_const< M >::type >::type Message
boost::remove_reference< typename boost::remove_const< M >::type >::type Message
static Parameter getParameter(const Event &event)
static Parameter getParameter(const Event &event)
static Parameter getParameter(const Event &event)
boost::remove_reference< typename boost::remove_const< M >::type >::type Message
const ros::MessageEvent< Message const > & Parameter
static Parameter getParameter(const Event &event)
boost::remove_reference< typename boost::remove_const< M >::type >::type Message
boost::remove_reference< typename boost::remove_const< M >::type >::type Message
boost::remove_reference< typename boost::remove_const< M >::type >::type Message
boost::remove_reference< typename boost::remove_const< M >::type >::type Message
ros::MessageEvent< Message const > Event
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.
ros::MessageEvent< Message const > Event
boost::remove_reference< typename boost::remove_const< M >::type >::type Message
static const bool is_const
ros::MessageEvent< Message const > Event


roscpp
Author(s): Morgan Quigley, Josh Faust, Brian Gerkey, Troy Straszheim, Dirk Thomas
autogenerated on Mon Nov 2 2020 03:52:26