39 #ifndef ORO_CREATESEQUENCE_HPP_ 40 #define ORO_CREATESEQUENCE_HPP_ 42 #include <boost/fusion/include/cons.hpp> 43 #include <boost/fusion/include/front.hpp> 44 #include <boost/fusion/include/vector.hpp> 47 #include <boost/mpl/front.hpp> 48 #include <boost/mpl/pop_front.hpp> 49 #include <boost/mpl/print.hpp> 51 #include <boost/fusion/mpl.hpp> 52 #include <boost/utility/enable_if.hpp> 56 #include "../FactoryExceptions.hpp" 65 namespace bf = boost::fusion;
66 namespace mpl = boost::mpl;
75 template<
class Seq,
class Data,
class Enable =
void >
77 Data
operator()(Seq s) { bf::front(s)->evaluate();
return Data(bf::front(s)->rvalue()); }
83 template<
class Seq,
class Data>
84 struct GetArgument<Seq, Data, typename
boost::enable_if< is_pure_reference<Data> >::type> {
85 Data
operator()(Seq s) {
return Data(bf::front(s)->
set() ); }
92 template<
class Seq,
class Data,
class Enable =
void >
94 static void set( Seq seq, Data in) { bf::front(seq)->
set( bf::front(in) ); }
97 template<
class Seq,
class Data>
98 struct AssignHelper<Seq, Data, typename
boost::enable_if< boost::is_pointer<typename mpl::front<Data>::type> >::type> {
99 static void set(Seq , Data ) {}
120 template<
class ds_arg_type,
class ds_type>
121 static ds_type
sources(std::vector<base::DataSourceBase::shared_ptr>::const_iterator front,
int argnbr, std::string
const& tname )
123 typedef typename ds_type::element_type element_type;
135 template<
class ds_arg_type,
class ads_type>
136 static ads_type
assignable(std::vector<base::DataSourceBase::shared_ptr>::const_iterator front,
int argnbr, std::string
const& tname )
147 template<
class List,
int size>
184 template<
class List,
int size>
205 typedef typename mpl::if_<typename is_pure_reference<arg_type>::type,
209 typedef typename AssignableDataSource< ds_arg_type >::shared_ptr
ads_type;
220 typedef bf::cons<ds_type, tail_type>
type;
223 typedef bf::cons<ads_type, atail_type>
atype;
240 static type
sources(std::vector<base::DataSourceBase::shared_ptr>::const_iterator args,
int argnbr = 1 )
242 std::vector<base::DataSourceBase::shared_ptr>::const_iterator next = args;
243 return bf::cons<ds_type, tail_type>
245 tail::sources( ++next, argnbr + 1));
256 static atype
assignable(std::vector<base::DataSourceBase::shared_ptr>::const_iterator args,
int argnbr = 1 )
258 std::vector<base::DataSourceBase::shared_ptr>::const_iterator next = args;
261 tail::assignable(++next, argnbr + 1));
270 static data_type
data(
const type& seq) {
280 static void set(
const data_type& in,
const atype& seq) {
282 return tail::set( bf::pop_front(in), bf::pop_front(seq) );
292 return tail::update( bf::pop_front(seq) );
302 static type
copy(
const type& seq, std::map<
305 return type( bf::front(seq)->copy(alreadyCloned), tail::copy( bf::pop_front(seq), alreadyCloned ) );
316 if ( i <= 0 || i > size)
321 return tail::GetTypeInfo(i-1);
333 if ( i <= 0 || i > size)
338 return tail::GetType(i-1);
353 typedef typename mpl::if_<typename is_pure_reference<arg_type>::type,
356 typedef typename AssignableDataSource< ds_arg_type >::shared_ptr
ads_type;
360 typedef bf::cons<ds_type>
type;
364 static type
sources(std::vector<base::DataSourceBase::shared_ptr>::const_iterator front,
int argnbr = 1)
370 static atype
assignable(std::vector<base::DataSourceBase::shared_ptr>::const_iterator args,
int argnbr = 1)
382 static data_type
data(
const type& seq) {
391 static void set(
const data_type& in,
const atype& seq) {
402 static type
copy(
const type& seq, std::map<
405 return type( bf::front(seq)->copy(alreadyCloned) );
430 static type
sources(std::vector<base::DataSourceBase::shared_ptr>::const_iterator args,
int argnbr = 0)
435 static atype
assignable(std::vector<base::DataSourceBase::shared_ptr>::const_iterator args,
int argnbr = 0)
446 static data_type
data(
const type& seq) {
454 static void set(
const data_type& in,
const atype& seq) {
466 static type
copy(
const type& seq, std::map<
DataSource is a base class representing a generic way to read data of type T.
static type sources(std::vector< base::DataSourceBase::shared_ptr >::const_iterator front, int argnbr=1)
static data_type data(const type &seq)
Returns the data contained in the data source as a Fusion Sequence.
static atype assignable(std::vector< base::DataSourceBase::shared_ptr >::const_iterator args, int argnbr=0)
This object represents the default queue implementation used by Orocos objects.
base::DataSourceBase::shared_ptr convert(base::DataSourceBase::shared_ptr arg) const
Automatic conversion: convert a internal::DataSource to this type.
static void set(Seq seq, Data in)
remove_cr< arg_type >::type ds_arg_type
The data source value type of an assignable data source is non-const, non-reference.
mpl::front< List >::type arg_type
tail::data_type arg_tail_type
The base class for all internal data representations.
This class can create three kinds of Boost Fusion Sequences.
Helper class for extracting the bare pointer from a shared_ptr data source.
#define ORO_THROW_OR_RETURN(x, rv)
bf::cons< ads_type > atype
AssignableDataSource< ds_arg_type >::shared_ptr ads_type
When Orocos is compiled without exceptions (define ORO_EMBEDDED), the functions which would throw an ...
tail::type tail_type
The type of the tail (List - head) of our sequence.
mpl::front< List >::type arg_type
The argument type.
static std::string GetType(int i)
static void update(typename DataSource< typename remove_cr< T >::type >::shared_ptr)
static std::string GetType(int i)
Returns the i'th argument type name as returned by DataSource<ArgI>::GetType(), starting from 1...
static type copy(const type &seq, std::map< const base::DataSourceBase *, base::DataSourceBase * > &alreadyCloned)
Copies a sequence of DataSource<T>::shared_ptr according to the copy/clone semantics of data sources...
static atype assignable(std::vector< base::DataSourceBase::shared_ptr >::const_iterator args, int argnbr=1)
Converts a std::vector of DataSourceBase types into a boost::fusion Sequence of AssignableDataSources...
static const types::TypeInfo * GetTypeInfo()
Return the Orocos type info.
static type copy(const type &seq, std::map< const base::DataSourceBase *, base::DataSourceBase * > &alreadyCloned)
Copies a sequence of DataSource<T>::shared_ptr according to the copy/clone semantics of data sources...
static const std::string & getType()
Return the qualified type.
Helper class for avoiding assigning a bare pointer to a shared_ptr data source.
static data_type data(const type &seq)
Returns the data contained in the data source as a Fusion Sequence.
static void update(const type &seq)
Helper to only update data sources that hold references.
static const types::TypeInfo * GetTypeInfo(int i)
static data_type data(const type &seq)
Returns the data contained in the data sources as a Fusion Sequence.
create_sequence< typename mpl::pop_front< List >::type > tail
The tail is ourselves minus the head.
static const types::TypeInfo * getTypeInfo()
Return the typeinfo object.
static type copy(const type &seq, std::map< const base::DataSourceBase *, base::DataSourceBase * > &alreadyCloned)
Copies a sequence of DataSource<T>::shared_ptr according to the copy/clone semantics of data sources...
static type sources(std::vector< base::DataSourceBase::shared_ptr >::const_iterator args, int argnbr=1)
Converts a std::vector of DataSourceBase types into a boost::fusion Sequence of DataSources of the ty...
static atype assignable(std::vector< base::DataSourceBase::shared_ptr >::const_iterator args, int argnbr=1)
A class for representing a user type, and which can build instances of that type. ...
mpl::if_< typename is_pure_reference< arg_type >::type, typename AssignableDataSource< ds_arg_type >::shared_ptr, typename DataSource< ds_arg_type >::shared_ptr >::type ds_type
The type of a single element of the vector.
static ds_type sources(std::vector< base::DataSourceBase::shared_ptr >::const_iterator front, int argnbr, std::string const &tname)
bf::cons< arg_type, arg_tail_type > data_type
The joint T data type of head and tail.
AssignableDataSource< ds_arg_type >::shared_ptr ads_type
static void update(typename DataSource< typename remove_cr< T >::type >::shared_ptr s)
boost::intrusive_ptr< DataSource< T > > shared_ptr
boost::intrusive_ptr< AssignableDataSource< T > > shared_ptr
Use this type to store a pointer to an AssignableDataSource.
Every DataSource of type T has a type info class which it can ask type information.
remove_cr< arg_type >::type ds_arg_type
bf::cons< ds_type, tail_type > type
The joint DataSource<T>::shared_ptr type of head and tail, again a fusion cons.
A DataSource which has set() methods.
static const types::TypeInfo * GetTypeInfo(int i)
Returns the i'th argument type info as returned by DataSource<ArgI>::GetTypeInfo(), starting from 1.
static const types::TypeInfo * GetTypeInfo(int i)
Exception thrown when a factory is requested to create an object, but a wrong argument type was given...
static type sources(std::vector< base::DataSourceBase::shared_ptr >::const_iterator args, int argnbr=0)
boost::remove_const< typename boost::remove_reference< T >::type >::type type
Helper to convert a single data source base to a DataSource or AssignableDataSource.
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
bf::cons< arg_type > data_type
mpl::if_< typename is_pure_reference< arg_type >::type, typename AssignableDataSource< ds_arg_type >::shared_ptr, typename DataSource< ds_arg_type >::shared_ptr >::type ds_type
The type of a single element of the vector.
static std::string GetType(int i)
static ads_type assignable(std::vector< base::DataSourceBase::shared_ptr >::const_iterator front, int argnbr, std::string const &tname)
static void update(const type &seq)
Calls the DataSourceBase::updated() function for each element in sequence seq, in case the element is...
static void update(const type &seq)
bf::cons< ads_type, atail_type > atype