SequenceConstructor.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: Peter Soetens Fri Oct 1 14:48:38 2010 +0200 SequenceConstructor.hpp
3 
4  SequenceConstructor.hpp - description
5  -------------------
6  begin : Fri Oct 1 2010
7  copyright : (C) 2010 Peter Soetens
8  email : peter@thesourceworks.com
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  * 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 SEQUENCECONSTRUCTOR_HPP_
40 #define SEQUENCECONSTRUCTOR_HPP_
41 
42 #include "TypeConstructor.hpp"
43 #include "../internal/DataSources.hpp"
44 #include <vector>
45 
46 namespace RTT
47 {
48  namespace types
49  {
53  template<class T>
54  struct sequence_ctor: public std::unary_function<int, const T& >
55  {
56  typedef const T& ( Signature)(int);
57  mutable boost::shared_ptr<T> ptr;
59  ptr(new T())
60  {
61  }
62  const T& operator()(int size) const
63  {
64  ptr->resize(size);
65  return *(ptr);
66  }
67  };
68 
73  template<class T>
75  {
76  typedef const std::vector<T>& result_type;
77  typedef T argument_type;
78  result_type operator()(const std::vector<T>& args) const
79  {
80  return args;
81  }
82  };
83 
88  template<class T>
91  };
92 
97  template<class T>
99  {
100  typedef typename T::value_type value_type;
101  virtual base::DataSourceBase::shared_ptr build(const std::vector<
103  {
104  if (args.size() == 0)
107  for (unsigned int i = 0; i != args.size(); ++i)
108  {
110  boost::dynamic_pointer_cast<internal::DataSource<value_type> >(
111  args[i]);
112  if (dsd)
113  vds->add(dsd);
114  else
116  }
117  return vds;
118  }
119 
120  };
121 
127  template<class T>
128  struct sequence_ctor2: public std::binary_function<int, typename T::value_type,
129  const T&>
130  {
131  typedef const T& ( Signature)(int, typename T::value_type);
132  mutable boost::shared_ptr<T> ptr;
134  ptr(new T() )
135  {
136  }
137  const T& operator()(int size, typename T::value_type value) const
138  {
139  ptr->resize(size);
140  ptr->assign(size, value);
141  return *(ptr);
142  }
143  };
144 
145  }
146 }
147 
148 #endif /* SEQUENCECONSTRUCTOR_HPP_ */
result_type operator()(const std::vector< T > &args) const
internal::NArityDataSource< sequence_varargs_ctor< T > > type
const T & operator()(int size, typename T::value_type value) const
const T &( Signature)(int, typename T::value_type)
boost::intrusive_ptr< NArityDataSource< function > > shared_ptr
const std::vector< T > & result_type
const T & operator()(int size) const
virtual base::DataSourceBase::shared_ptr build(const std::vector< base::DataSourceBase::shared_ptr > &args) const
boost::intrusive_ptr< DataSource< T > > shared_ptr
Definition: DataSource.hpp:115
boost::intrusive_ptr< DataSourceBase > shared_ptr
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:53
boost::shared_ptr< T > ptr


rtt
Author(s): RTT Developers
autogenerated on Fri Oct 25 2019 03:59:35