Orocos Real-Time Toolkit  2.9.0
DataSourceGenerator.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: Peter Soetens Wed Jan 18 14:11:40 CET 2006 DataSourceGenerator.hpp
3 
4  DataSourceGenerator.hpp - description
5  -------------------
6  begin : Wed January 18 2006
7  copyright : (C) 2006 Peter Soetens
8  email : peter.soetens@mech.kuleuven.be
9 
10  ***************************************************************************
11  * This library is free software; you can redistribute it and/or *
12  * modify it under the terms of the GNU General Public *
13  * License as published by the Free Software Foundation; *
14  * version 2 of the License. *
15  * *
16  * As a special exception, you may use this file as part of a free *
17  * software library without restriction. Specifically, if other files *
18  * instantiate templates or use macros or inline functions from this *
19  * file, or you compile this file and link it with other files to *
20  * produce an executable, this file does not by itself cause the *
21  * resulting executable to be covered by the GNU General Public *
22  * License. This exception does not however invalidate any other *
23  * reasons why the executable file might be covered by the GNU General *
24  * Public License. *
25  * *
26  * This library is distributed in the hope that it will be useful, *
27  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
28  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
29  * Lesser General Public License for more details. *
30  * *
31  * You should have received a copy of the GNU General Public *
32  * License along with this library; if not, write to the Free Software *
33  * Foundation, Inc., 59 Temple Place, *
34  * Suite 330, Boston, MA 02111-1307 USA *
35  * *
36  ***************************************************************************/
37 
38 
39 #ifndef ORO_EXECUTION_DATASOURCE_GENERATOR_HPP
40 #define ORO_EXECUTION_DATASOURCE_GENERATOR_HPP
41 
42 #include "DataSources.hpp"
43 #include <boost/utility/enable_if.hpp>
44 #include <boost/ref.hpp>
45 #include <boost/type_traits/is_base_of.hpp>
46 #include <boost/type_traits/remove_pointer.hpp>
47 
48 namespace RTT
49 {
50  namespace internal
51  {
52  template<class T, class Enable = void >
53  struct DSWrap {
55  }; // normal type
56 
57  template<class T>
58  struct DSWrap<T, typename boost::enable_if< boost::is_base_of<base::DataSourceBase, typename boost::remove_pointer<T>::type > >::type > {
60  }; // datasource type
61 
62  template<class T>
63  struct DSWrap<T, typename boost::enable_if< boost::is_reference<T> >::type > {
65  }; // reference type
66 
67  template<class T>
68  struct DSWrap<T, typename boost::enable_if< boost::is_reference_wrapper<T> >::type > {
69  typedef typename boost::unwrap_reference<T>::type RT;
71  }; // reference type
72 
73  template<class T>
74  struct DSWrap<boost::intrusive_ptr<T>, typename boost::enable_if< boost::is_base_of<base::DataSourceBase, typename boost::remove_pointer<T>::type > >::type >
75  : public DSWrap<T> {
76  }; // datasource shared_ptr type
77 
78  using boost::ref;
79 
96  {
97  template<class A1>
98  std::vector<base::DataSourceBase::shared_ptr> operator()(A1 a1)
99  {
100  std::vector<base::DataSourceBase::shared_ptr> res;
101  res.push_back( DSWrap<A1>()(a1));
102  return res;
103  }
104 
105  template<class A1, class A2>
106  std::vector<base::DataSourceBase::shared_ptr> operator()(A1 a1, A2 a2 )
107  {
108  std::vector<base::DataSourceBase::shared_ptr> res = operator()(a1);
109  res.push_back( DSWrap<A2>()(a2));
110  return res;
111  }
112 
113  template<class A1, class A2, class A3>
114  std::vector<base::DataSourceBase::shared_ptr> operator()(A1 a1, A2 a2, A3 a3 )
115  {
116  std::vector<base::DataSourceBase::shared_ptr> res = operator()(a1,a2);
117  res.push_back( DSWrap<A3>()(a3));
118  return res;
119  }
120 
121  template<class A1, class A2, class A3, class A4>
122  std::vector<base::DataSourceBase::shared_ptr> operator()(A1 a1, A2 a2, A3 a3, A4 a4 )
123  {
124  std::vector<base::DataSourceBase::shared_ptr> res = operator()(a1,a2,a3);
125  res.push_back( DSWrap<A4>()(a4));
126  return res;
127  }
128 
129  template<class A1, class A2, class A3, class A4, class A5, class A6>
130  std::vector<base::DataSourceBase::shared_ptr> operator()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6 )
131  {
132  std::vector<base::DataSourceBase::shared_ptr> res = operator()(a1,a2,a3,a4,a5);
133  res.push_back( DSWrap<A6>()(a6));
134  return res;
135  }
136 
137  template<class A1, class A2, class A3, class A4, class A5, class A6, class A7>
138  std::vector<base::DataSourceBase::shared_ptr> operator()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7 )
139  {
140  std::vector<base::DataSourceBase::shared_ptr> res = operator()(a1,a2,a3,a4,a5,a6);
141  res.push_back( DSWrap<A7>()(a7));
142  return res;
143  }
144 
145  template<class A1, class A2, class A3, class A4, class A5>
146  std::vector<base::DataSourceBase::shared_ptr> operator()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5 )
147  {
148  std::vector<base::DataSourceBase::shared_ptr> res = operator()(a1,a2,a3,a4);
149  res.push_back( DSWrap<A5>()(a5));
150  return res;
151  }
152  };
153 }}
154 
155 #endif
std::vector< base::DataSourceBase::shared_ptr > operator()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
A function object which returns a vector of DataSources.
A DataSource which is used to manipulate a reference to an external value.
std::vector< base::DataSourceBase::shared_ptr > operator()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7)
std::vector< base::DataSourceBase::shared_ptr > operator()(A1 a1, A2 a2, A3 a3, A4 a4)
std::vector< base::DataSourceBase::shared_ptr > operator()(A1 a1, A2 a2)
std::vector< base::DataSourceBase::shared_ptr > operator()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6)
A DataSource which holds a constant value and returns it in its get() method.
std::vector< base::DataSourceBase::shared_ptr > operator()(A1 a1)
base::DataSourceBase::shared_ptr operator()(T t)
boost::intrusive_ptr< DataSourceBase > shared_ptr
Use this type to store a pointer to a DataSourceBase.
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:52
std::vector< base::DataSourceBase::shared_ptr > operator()(A1 a1, A2 a2, A3 a3)