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)));
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<
static type sources(std::vector< base::DataSourceBase::shared_ptr >::const_iterator front, int argnbr=1)
static data_type data(const type &seq)
bf::cons< arg_store_type, arg_store_tail_type > data_store_type
static atype assignable(std::vector< base::DataSourceBase::shared_ptr >::const_iterator args, int argnbr=0)
base::DataSourceBase::shared_ptr convert(base::DataSourceBase::shared_ptr arg) const
static data_store_type store(const data_type &in)
static data_store_type store(const data_type &in)
static void set(Seq seq, Data in)
remove_cr< arg_type >::type ds_arg_type
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.
#define ORO_THROW_OR_RETURN(x, rv)
bf::cons< ads_type > atype
AssignableDataSource< ds_arg_type >::shared_ptr ads_type
mpl::front< List >::type arg_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)
static type copy(const type &seq, std::map< const base::DataSourceBase *, base::DataSourceBase * > &alreadyCloned)
static void load(const data_store_type &in, const atype &seq)
static atype assignable(std::vector< base::DataSourceBase::shared_ptr >::const_iterator args, int argnbr=1)
static type copy(const type &seq, std::map< const base::DataSourceBase *, base::DataSourceBase * > &alreadyCloned)
static data_type data(const type &seq)
static void update(const type &seq)
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)
create_sequence< typename mpl::pop_front< List >::type > tail
static type copy(const type &seq, std::map< const base::DataSourceBase *, base::DataSourceBase * > &alreadyCloned)
static type sources(std::vector< base::DataSourceBase::shared_ptr >::const_iterator args, int argnbr=1)
static atype assignable(std::vector< base::DataSourceBase::shared_ptr >::const_iterator args, int argnbr=1)
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
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
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
static const types::TypeInfo * GetTypeInfo()
static const types::TypeInfo * getTypeInfo()
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
static const types::TypeInfo * GetTypeInfo(int i)
static const types::TypeInfo * GetTypeInfo(int i)
AStore< arg_type > arg_store_type
static const std::string & getType()
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
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
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)
static void update(const type &seq)
bf::cons< ads_type, atail_type > atype
static bool update(TaskContext *tc)