39 #ifndef ORO_FUSEDFUNCTORDATASOURCE_HPP_ 40 #define ORO_FUSEDFUNCTORDATASOURCE_HPP_ 44 #include "../SendStatus.hpp" 46 #include "../ExecutionEngine.hpp" 47 #include "../os/oro_allocator.hpp" 49 #include <boost/bind.hpp> 50 #include <boost/type_traits.hpp> 51 #include <boost/function.hpp> 52 #include <boost/function_types/function_type.hpp> 53 #include <boost/fusion/include/invoke.hpp> 54 #include <boost/fusion/include/invoke_procedure.hpp> 55 #include <boost/mpl/bool.hpp> 56 #include <boost/make_shared.hpp> 62 namespace bf = boost::fusion;
69 template<
typename Signature,
class Enable=
void>
72 typename remove_cr<typename boost::function_traits<Signature>::result_type>::type >
75 typedef typename boost::function_traits<Signature>::result_type
80 typename boost::function_types::parameter_types<Signature>::type>
SequenceFactory;
84 boost::function<Signature>
ff;
88 typedef boost::intrusive_ptr<FusedFunctorDataSource<Signature> >
117 typedef typename bf::result_of::invoke<call_type,arg_type>::type iret;
118 typedef iret(*IType)(
call_type, arg_type
const&);
119 IType foo = &bf::invoke<call_type,arg_type>;
144 template<
typename Signature>
145 struct FusedFunctorDataSource<Signature, typename
boost::enable_if< is_pure_reference<typename boost::function_traits<Signature>::result_type> >::type >
147 typename remove_cr<typename boost::function_traits<Signature>::result_type>::type >
150 typedef typename boost::function_traits<Signature>::result_type
160 boost::function<Signature>
ff;
164 typedef boost::intrusive_ptr<FusedFunctorDataSource<Signature> >
193 typedef typename bf::result_of::invoke<call_type,arg_type>::type iret;
194 typedef iret(*IType)(
call_type, arg_type
const&);
195 IType foo = &bf::invoke<call_type,arg_type>;
208 get(); ret.
result() = arg;
212 get();
return ret.
result();
237 template<
class Function>
240 typedef typename boost::function_types::function_type<Function>::type Signature;
242 if ( args.size() != boost::function_traits<Signature>::arity )
252 template<
typename Signature>
255 typename remove_cr<typename boost::function_traits<Signature>::result_type>::type >
257 typedef typename boost::function_traits<Signature>::result_type
268 typedef boost::intrusive_ptr<FusedMCallDataSource<Signature> >
298 typedef typename bf::result_of::invoke<call_type,arg_type>::type iret;
299 typedef iret(*IType)(
call_type, arg_type
const&);
300 IType foo = &bf::invoke<call_type,arg_type>;
334 template<
typename Signature>
348 typedef boost::intrusive_ptr<FusedMSendDataSource<Signature> >
398 template<
typename Signature>
407 typedef typename boost::function_types::parameter_types<CollectSignature>::type
arg_types;
416 typedef boost::intrusive_ptr<FusedMCollectDataSource<Signature> >
443 if (isblocking->
get())
468 template<
typename Signature>
471 typedef typename boost::function_traits<Signature>::result_type
477 boost::shared_ptr<base::ActionInterface>
mact;
485 boost::shared_ptr<FusedMSignal<Signature> >
self;
487 typedef boost::shared_ptr<FusedMSignal<Signature> >
shared_ptr;
497 const DataSourceSequence& s,
499 mact(act), args(s), subscriber(subscr), self()
514 shared_ptr sg = this->cloneRT();
518 if ( subscriber->
process( sg.get() ) ) {
boost::function_traits< Signature >::result_type result_type
DataSource is a base class representing a generic way to read data of type T.
boost::intrusive_ptr< FusedFunctorDataSource< Signature > > shared_ptr
value_t value() const
Return the result of the last evaluate() function.
boost::function_traits< Signature >::result_type result_type
virtual result_t get() const =0
Return the data as type T.
create_sequence< typename boost::function_types::parameter_types< Signature >::type > SequenceFactory
SequenceFactory::type DataSourceSequence
FusedMSignal< Signature >::shared_ptr cloneRT() const
bool evaluate() const
Force an evaluation of the DataSourceBase.
SequenceFactory::type DataSourceSequence
SequenceFactory::type DataSourceSequence
void executeAndDispose()
Execute functionality and free this object.
const_reference_t rvalue() const
Get a const reference to the value of this DataSource.
boost::function< Signature > call_type
ExecutionEngine * subscriber
virtual FusedMCallDataSource< Signature > * clone() const
Return a shallow clone of this DataSource.
DataSource< bool >::shared_ptr isblocking
The base class for all internal data representations.
This class can create three kinds of Boost Fusion Sequences.
remove_cr< result_type >::type value_t
SequenceFactory::atype DataSourceSequence
value_t value() const
Return the result of the last evaluate() function.
void exec(F f)
Stores the result of a function.
remove_cr< result_type >::type value_t
void setArguments(const DataSourceSequence &a1)
DataSource< value_t >::const_reference_t const_reference_t
base::DataSourceBase * newFunctorDataSource(Function f, const std::vector< base::DataSourceBase::shared_ptr > &args)
Creates a data source that returns the result of a given function.
FusedMSendDataSource(typename base::OperationCallerBase< Signature >::shared_ptr g, const DataSourceSequence &s=DataSourceSequence())
value_t value() const
Return the result of the last evaluate() function.
A real-time malloc allocator which allocates every block with oro_rt_malloc() and deallocates with or...
virtual FusedMSendDataSource< Signature > * copy(std::map< const base::DataSourceBase *, base::DataSourceBase * > &alreadyCloned) const
Create a deep copy of this internal::DataSource, unless it is already cloned.
A DataSource that collects the result of an asynchronous method which store its results in other data...
remove_cr< result_type >::type value_t
value_t value() const
Return the result of the last evaluate() function.
boost::intrusive_ptr< FusedMSendDataSource< Signature > > shared_ptr
SequenceFactory::data_type arg_type
bool evaluate() const
Force an evaluation of the DataSourceBase.
DataSource< value_t >::const_reference_t const_reference_t
boost::function_traits< Signature >::result_type result_type
void reportError()
Executed when the operation execution resulted in a C++ exception.
The base class for all method implementations.
SendHandle< Signature > sh
virtual FusedFunctorDataSource< Signature > * copy(std::map< const base::DataSourceBase *, base::DataSourceBase * > &alreadyCloned) const
Create a deep copy of this internal::DataSource, unless it is already cloned.
FusedFunctorDataSource(Func g, const DataSourceSequence &s=DataSourceSequence())
void setArguments(const DataSourceSequence &a1)
CollectType< Signature >::type CollectSignature
An execution engine serialises (executes one after the other) the execution of all commands...
SendStatus
Returns the status of a send() or collect() invocation.
DataSource< value_t >::const_reference_t const_reference_t
RStore< result_type > ret
DataSource< value_t >::const_reference_t const_reference_t
A DataSource that calls a method which gets its arguments from other data sources.
RStore< result_type > ret
boost::intrusive_ptr< FusedFunctorDataSource< Signature > > shared_ptr
boost::function< Signature > call_type
SequenceFactory::type DataSourceSequence
boost::shared_ptr< OperationCallerBase< F > > shared_ptr
boost::intrusive_ptr< FusedMCollectDataSource< Signature > > shared_ptr
value_t value() const
Return the result of the last evaluate() function.
static data_type data(const type &seq)
Returns the data contained in the data sources as a Fusion Sequence.
void setArguments(const DataSourceSequence &a1)
The SendHandle is used to collect the result values of an asynchronous invocation.
create_sequence< typename boost::function_types::parameter_types< Signature >::type > SequenceFactory
virtual FusedFunctorDataSource< Signature > * clone() const
Return a shallow clone of this DataSource.
RStore< result_type > ret
FusedMCallDataSource(typename base::OperationCallerBase< Signature >::shared_ptr g, const DataSourceSequence &s=DataSourceSequence())
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...
Returned when the result of the send() could not be collected.
SequenceFactory::data_type arg_type
create_sequence< typename boost::function_types::parameter_types< Signature >::type > SequenceFactory
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...
FusedMCollectDataSource(const DataSourceSequence &s, DataSource< bool >::shared_ptr blocking)
create_sequence< typename boost::function_types::parameter_types< Signature >::type > SequenceFactory
Based on the software pattern 'command', this interface allows execution of action objects...
base::OperationCallerBase< Signature >::shared_ptr ff
boost::intrusive_ptr< FusedMCallDataSource< Signature > > shared_ptr
SequenceFactory::type DataSourceSequence
result_type invoke(const typename SequenceFactory::data_type &seq) const
A Fused function that takes the arguments of the signal, puts them into the assignable data sources a...
const_reference_t rvalue() const
Get a const reference to the value of this DataSource.
virtual FusedMCollectDataSource< Signature > * clone() const
Return a shallow clone of this DataSource.
const_reference_t rvalue() const
Get a const reference to the value of this DataSource.
boost::function< Signature > ff
bf::cons< arg_type, arg_tail_type > data_type
The joint T data type of head and tail.
An object that is executable and is freed after execution.
base::OperationCallerBase< Signature >::shared_ptr ff
virtual FusedMSendDataSource< Signature > * clone() const
Return a shallow clone of this DataSource.
DataSource< SendStatus >::const_reference_t const_reference_t
const_reference_t rvalue() const
Get a const reference to the value of this DataSource.
FusedMSignal(base::ActionInterface *act, const DataSourceSequence &s, ExecutionEngine *subscr)
Create a new object which takes ownership of the action to be executed upon signal.
boost::function_types::parameter_types< CollectSignature >::type arg_types
const_reference_t rvalue() const
Get a const reference to the value of this DataSource.
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.
void setArguments(const DataSourceSequence &a1)
void setArguments(const DataSourceSequence &a1)
void dispose()
As long as dispose (or executeAndDispose() ) is not called, this object will not be destroyed...
boost::function_traits< Signature >::result_type result_type
void setArguments(const DataSourceSequence &a1)
boost::remove_const< typename boost::remove_reference< T >::type >::type type
Exception thrown when a factory is requested to create an object but the wrong number of arguments wa...
virtual FusedMCollectDataSource< Signature > * copy(std::map< const base::DataSourceBase *, base::DataSourceBase * > &alreadyCloned) const
Create a deep copy of this internal::DataSource, unless it is already cloned.
boost::function< Signature > ff
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
static void set(const data_type &in, const atype &seq)
Sets the values of a sequence of AssignableDataSource<T> data sources ot the values contained in in u...
SendHandle< Signature > result_type
virtual bool process(base::DisposableInterface *c)
Queue and execute (process) a given message.
bool evaluate() const
Force an evaluation of the DataSourceBase.
mpl::push_front< arg_types, SendHandle< Signature > & >::type handle_and_arg_types
static void update(const type &seq)
Calls the DataSourceBase::updated() function for each element in sequence seq, in case the element is...
virtual FusedFunctorDataSource< Signature > * clone() const
Return a shallow clone of this DataSource.
virtual FusedFunctorDataSource< Signature > * copy(std::map< const base::DataSourceBase *, base::DataSourceBase * > &alreadyCloned) const
Create a deep copy of this internal::DataSource, unless it is already cloned.
details::GetConstRef< T >::type const_reference_t
create_sequence< typename boost::function_types::parameter_types< Signature >::type > SequenceFactory
A Function object that reacts to a Signal by writing the arguments in data sources and calling an act...
FusedFunctorDataSource(Func g, const DataSourceSequence &s=DataSourceSequence())
create_sequence< handle_and_arg_types > SequenceFactory
bf::cons< ads_type, atail_type > atype
boost::shared_ptr< base::ActionInterface > mact
A DataSource that sends a method which gets its arguments from other data sources.
AssignableDataSource< value_t >::reference_t reference_t
virtual FusedMCallDataSource< Signature > * copy(std::map< const base::DataSourceBase *, base::DataSourceBase * > &alreadyCloned) const
Create a deep copy of this internal::DataSource, unless it is already cloned.
boost::shared_ptr< FusedMSignal< Signature > > shared_ptr
A DataSource that calls a functor of signature Signature which gets its arguments from other data sou...