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> 57 #include "../FactoryExceptions.hpp" 66 namespace bf = boost::fusion;
67 namespace mpl = boost::mpl;
73 template<
class Seq,
class Data,
class Enable =
void >
75 Data
operator()(Seq s) { bf::front(s)->evaluate();
return Data(bf::front(s)->rvalue()); }
81 template<
class Seq,
class Data>
82 struct GetArgument<Seq, Data, typename
boost::enable_if< is_pure_reference<Data> >::type> {
83 Data
operator()(Seq s) {
return Data(bf::front(s)->
set() ); }
90 template<
class Seq,
class Data,
class Enable =
void >
92 static void set( Seq seq, Data in) { bf::front(seq)->
set( bf::front(in) ); }
95 template<
class Seq,
class Data>
96 struct AssignHelper<Seq, Data, typename
boost::enable_if< boost::is_pointer<typename mpl::front<Data>::type> >::type> {
97 static void set(Seq , Data ) {}
118 template<
class ds_arg_type,
class ds_type>
119 static ds_type
sources(std::vector<base::DataSourceBase::shared_ptr>::const_iterator front,
int argnbr, std::string
const& tname )
121 typedef typename ds_type::element_type element_type;
124 boost::dynamic_pointer_cast< element_type >( *front );
136 template<
class ds_arg_type,
class ads_type>
137 static ads_type
assignable(std::vector<base::DataSourceBase::shared_ptr>::const_iterator front,
int argnbr, std::string
const& tname )
139 typedef typename ads_type::element_type element_type;
142 boost::dynamic_pointer_cast< element_type >( *front );
150 template<
class List,
int size>
187 template<
class List,
int size>
213 typedef typename mpl::if_<typename is_pure_reference<arg_type>::type,
217 typedef typename AssignableDataSource< ds_arg_type >::shared_ptr
ads_type;
228 typedef bf::cons<ds_type, tail_type>
type;
231 typedef bf::cons<ads_type, atail_type>
atype;
254 static type
sources(std::vector<base::DataSourceBase::shared_ptr>::const_iterator args,
int argnbr = 1 )
256 std::vector<base::DataSourceBase::shared_ptr>::const_iterator next = args;
257 return bf::cons<ds_type, tail_type>
259 tail::sources( ++next, argnbr + 1));
270 static atype
assignable(std::vector<base::DataSourceBase::shared_ptr>::const_iterator args,
int argnbr = 1 )
272 std::vector<base::DataSourceBase::shared_ptr>::const_iterator next = args;
275 tail::assignable(++next, argnbr + 1));
284 static data_type
data(
const type& seq) {
294 static void set(
const data_type& in,
const atype& seq) {
296 tail::set( bf::pop_front(in), bf::pop_front(seq) );
307 static void load(
const data_store_type& in,
const atype& seq) {
309 tail::load( bf::pop_front(in), bf::pop_front(seq) );
320 static data_store_type
store(
const data_type& in ) {
321 return data_store_type(bf::front(in), tail::store(bf::pop_front(in)));
331 tail::update( bf::pop_front(seq) );
341 static type
copy(
const type& seq, std::map<
344 return type( bf::front(seq)->copy(alreadyCloned), tail::copy( bf::pop_front(seq), alreadyCloned ) );
355 if ( i <= 0 || i > size)
360 return tail::GetTypeInfo(i-1);
372 if ( i <= 0 || i > size)
377 return tail::GetType(i-1);
395 typedef typename mpl::if_<typename is_pure_reference<arg_type>::type,
398 typedef typename AssignableDataSource< ds_arg_type >::shared_ptr
ads_type;
402 typedef bf::cons<ds_type>
type;
406 static type
sources(std::vector<base::DataSourceBase::shared_ptr>::const_iterator front,
int argnbr = 1)
412 static atype
assignable(std::vector<base::DataSourceBase::shared_ptr>::const_iterator args,
int argnbr = 1)
424 static data_type
data(
const type& seq) {
432 static void set(
const data_type& in,
const atype& seq) {
436 static void load(
const data_store_type& in,
const atype& seq) {
440 static data_store_type
store(
const data_type& in ) {
441 return data_store_type( bf::front(in) );
451 static type
copy(
const type& seq, std::map<
454 return type( bf::front(seq)->copy(alreadyCloned) );
480 static type
sources(std::vector<base::DataSourceBase::shared_ptr>::const_iterator args,
int argnbr = 0)
485 static atype
assignable(std::vector<base::DataSourceBase::shared_ptr>::const_iterator args,
int argnbr = 0)
496 static data_type
data(
const type& seq) {
504 static void set(
const data_type& in,
const atype& seq) {
508 static void load(
const data_store_type& in,
const atype& seq) {
512 static data_store_type
store(
const data_type& in ) {
513 return data_store_type();
523 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.
bf::cons< arg_store_type, arg_store_tail_type > data_store_type
The joint T data storage type of head and tail.
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 data_store_type store(const data_type &in)
Stores the values of a sequence of data_type into a data_store_type sequence for later retrieval duri...
static data_store_type store(const data_type &in)
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
static void load(const data_store_type &in, const atype &seq)
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.
Store a bound argument which may be a reference, const reference or any other type.
#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)
bf::vector data_store_type
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 void load(const data_store_type &in, const atype &seq)
Sets the values of a sequence of AssignableDataSource<T> data sources ot the values contained in in u...
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)
AStore< arg_type > arg_store_type
tail::data_store_type arg_store_tail_type
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.
static data_store_type store(const data_type &in)
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
static void load(const data_store_type &in, const atype &seq)
bf::cons< ds_type, tail_type > type
The joint DataSource<T>::shared_ptr type of head and tail, again a fusion cons.
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)
AStore< arg_type > arg_store_type
The argument storage type.
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
bf::cons< arg_store_type > data_store_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