39 #ifndef ORO_CORELIB_DATASOURCES_HPP 40 #define ORO_CORELIB_DATASOURCES_HPP 72 typedef boost::intrusive_ptr<ValueDataSource<T> >
shared_ptr;
102 virtual ValueDataSource<T>*
copy( std::map<const base::DataSourceBase*, base::DataSourceBase*>& replace )
const;
118 typename boost::add_const<typename DataSource<T>::value_t>::type
mdata;
126 typedef boost::intrusive_ptr< ConstantDataSource<T> >
shared_ptr;
147 virtual ConstantDataSource<T>*
copy( std::map<const base::DataSourceBase*, base::DataSourceBase*>& alreadyCloned )
const;
167 typedef boost::intrusive_ptr<ConstReferenceDataSource<T> >
shared_ptr;
209 typedef boost::intrusive_ptr<ReferenceDataSource<T> >
shared_ptr;
215 mptr =
static_cast<T*
>(
ref);
268 typedef boost::intrusive_ptr<AliasDataSource<T> >
shared_ptr;
287 return alias->
value();
325 typedef boost::intrusive_ptr<ArrayDataSource<T> >
shared_ptr;
347 void newArray( std::size_t size );
373 virtual ArrayDataSource<T>*
copy( std::map<const base::DataSourceBase*, base::DataSourceBase*>& replace )
const;
392 typedef boost::intrusive_ptr<LateReferenceDataSource<T> >
shared_ptr;
459 typedef boost::intrusive_ptr<LateConstReferenceDataSource<T> >
shared_ptr;
510 typedef boost::intrusive_ptr<ActionAliasDataSource<T> >
shared_ptr;
513 : action(act), alias(ds)
537 return alias->
value();
568 typedef boost::intrusive_ptr<ActionAliasDataSource<T> >
shared_ptr;
571 : action(act), alias(ds)
595 return alias->
value();
636 template<
typename BoundType>
641 typedef typename BoundType::result_t
T;
642 typedef boost::intrusive_ptr< UnboundDataSource<BoundType> >
shared_ptr;
652 return BoundType::clone();
670 template<
typename function>
672 :
public DataSource< typename remove_cr<typename function::result_type>::type >
680 mutable value_t
mdata;
682 typedef boost::intrusive_ptr<BinaryDataSource<function> >
shared_ptr;
691 : mdsa( a ), mdsb( b ), fun( f )
695 virtual value_t
get()
const 697 first_arg_t a = mdsa->
get();
698 second_arg_t b = mdsb->
get();
699 return mdata = fun( a, b );
733 template <
typename function>
735 :
public DataSource<typename remove_cr<typename function::result_type>::type>
741 mutable value_t
mdata;
743 typedef boost::intrusive_ptr<UnaryDataSource<function> >
shared_ptr;
750 : mdsa( a ), fun( f )
754 virtual value_t
get()
const 756 return mdata = fun( mdsa->
get() );
792 template<
typename function>
794 :
public DataSource<typename remove_cr<typename function::result_type>::type>
798 mutable std::vector<arg_t> margs;
799 std::vector<typename DataSource<arg_t>::shared_ptr > mdsargs;
801 mutable value_t
mdata;
803 typedef boost::intrusive_ptr<NArityDataSource<function> >
shared_ptr;
819 : margs( dsargs.size() ), mdsargs(dsargs), fun( f )
824 mdsargs.push_back(ds);
825 margs.push_back( ds->
value() );
828 virtual value_t
get()
const 830 assert( mdsargs.size() == margs.size() );
831 for(
unsigned int i=0; i !=mdsargs.size(); ++i)
832 margs[i] = mdsargs[i]->
get();
833 return mdata = fun( margs );
848 for(
unsigned int i=0; i !=mdsargs.size(); ++i)
858 std::vector<typename DataSource<arg_t>::shared_ptr > newargs( mdsargs.size() );
859 for(
unsigned int i=0; i !=mdsargs.size(); ++i)
860 newargs[i] = mdsargs[i]->
copy(alreadyCloned);
void setPointer(typename AssignableDataSource< T >::value_t *ptr)
DataSource< T >::result_t value() const
Return the result of the last evaluate() function.
bool evaluate() const
Force an evaluation of the DataSourceBase.
DataSource is a base class representing a generic way to read data of type T.
A DataSource which returns the return value of a unary function.
BinaryDataSource(typename DataSource< first_arg_t >::shared_ptr a, typename DataSource< second_arg_t >::shared_ptr b, function f)
Create a DataSource which returns the return value of a function f which is given argument a and b...
NArityDataSource(function f=function())
Create a DataSource which returns the return value of a function f.
virtual LateReferenceDataSource< T > * clone() const
Return a shallow clone of this DataSource.
DataSource< T >::value_t mdata
DataSource< T >::result_t value() const
Return the result of the last evaluate() function.
DataSource< T >::result_t value() const
Return the result of the last evaluate() function.
virtual result_t get() const =0
Return the data as type T.
LateReferenceDataSource(typename AssignableDataSource< T >::value_t *ptr=0)
bool evaluate() const
Force an evaluation of the DataSourceBase.
boost::intrusive_ptr< ActionAliasDataSource< T > > shared_ptr
virtual NArityDataSource< function > * clone() const
Return a shallow clone of this DataSource.
boost::intrusive_ptr< UnboundDataSource< BoundType > > shared_ptr
virtual LateReferenceDataSource< T > * copy(std::map< const base::DataSourceBase *, base::DataSourceBase * > &) const
Create a deep copy of this internal::DataSource, unless it is already cloned.
virtual UnaryDataSource< function > * copy(std::map< const base::DataSourceBase *, base::DataSourceBase * > &alreadyCloned) const
Create a deep copy of this internal::DataSource, unless it is already cloned.
boost::intrusive_ptr< UnaryDataSource< function > > shared_ptr
A DataSource which is used to manipulate a reference to an external value, by means of a pointer...
boost::call_traits< value_t >::reference reference_t
virtual void reset()
Reset this action.
virtual ValueDataSource< T > * copy(std::map< const base::DataSourceBase *, base::DataSourceBase * > &replace) const
Create a deep copy of this internal::DataSource, unless it is already cloned.
DataSource< T >::result_t value() const
Return the result of the last evaluate() function.
boost::intrusive_ptr< ArrayDataSource< T > > shared_ptr
void setReference(void *ref)
Sets the reference to a given pointer.
virtual void reset()
Reset the data to initial values.
boost::intrusive_ptr< LateConstReferenceDataSource< T > > shared_ptr
virtual void set(param_t t)=0
Set this DataSource with a value.
boost::intrusive_ptr< ConstantDataSource< T > > shared_ptr
virtual value_t value() const
Return the result of the last evaluate() function.
virtual void readArguments()=0
This is invoked some time before execute() at a time when the action may read its function arguments...
void add(typename DataSource< arg_t >::shared_ptr ds)
bool setReference(base::DataSourceBase::shared_ptr dsb)
Sets the reference to the data contained in the data source.
T value_t
The bare type of T is extracted into value_t.
AliasDataSource(DataSource< T > *ds)
boost::intrusive_ptr< ConstReferenceDataSource< T > > shared_ptr
DataSource< T >::result_t value() const
Return the result of the last evaluate() function.
bool evaluate() const
Force an evaluation of the DataSourceBase.
DataSource< T >::const_reference_t rvalue() const
Get a const reference to the value of this DataSource.
A DataSource which is used to manipulate a reference to an external value.
A DataSource which is used to read a const reference to an external value.
virtual void reset()
Reset the data to initial values.
void const * getRawDataConst()
NArityDataSource(function f, const std::vector< typename DataSource< arg_t >::shared_ptr > &dsargs)
Create a DataSource which returns the return value of a function f.
virtual void reset()
Reset the data to initial values.
UnaryDataSource(typename DataSource< arg_t >::shared_ptr a, function f)
Create a DataSource which returns the return value of a function f which is given argument a...
A DataSource which is used to manipulate a const reference to an external value, by means of a pointe...
A generic binary composite DataSource.
boost::intrusive_ptr< NArityDataSource< function > > shared_ptr
virtual DataSource< T > * copy(std::map< const base::DataSourceBase *, base::DataSourceBase * > &alreadyCloned) const =0
Create a deep copy of this internal::DataSource, unless it is already cloned.
DataSource< T >::result_t value() const
Return the result of the last evaluate() function.
AssignableDataSource< T >::const_reference_t rvalue() const
Get a const reference to the value of this DataSource.
virtual void reset()
Reset the data to initial values.
AssignableDataSource< T >::const_reference_t rvalue() const
Get a const reference to the value of this DataSource.
AssignableDataSource< T >::const_reference_t rvalue() const
Get a const reference to the value of this DataSource.
DataSource< T >::result_t value() const
Return the result of the last evaluate() function.
virtual NArityDataSource< function > * 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 which is used to execute an action and then return the value of another DataSource...
virtual value_t value() const
Return the result of the last evaluate() function.
virtual BoundType * clone() const
DataSource< T >::const_reference_t rvalue() const
Get a const reference to the value of this DataSource.
virtual const_reference_t rvalue() const =0
Get a const reference to the value of this DataSource.
virtual bool execute()=0
Execute the functionality of this action.
boost::intrusive_ptr< LateReferenceDataSource< T > > shared_ptr
boost::intrusive_ptr< AliasDataSource< T > > shared_ptr
Based on the software pattern 'command', this interface allows execution of action objects...
DataSource< value_t >::const_reference_t rvalue() const
Get a const reference to the value of this DataSource.
ActionAliasAssignableDataSource(base::ActionInterface *act, AssignableDataSource< T > *ds)
~ActionAliasAssignableDataSource()
virtual value_t value() const
Return the result of the last evaluate() function.
virtual AliasDataSource< T > * clone() const
Return a shallow clone of this DataSource.
A DataSource which is used to mirror another datasource.
virtual BinaryDataSource< function > * clone() const
Return a shallow clone of this DataSource.
virtual void reset()
Reset the data to initial values.
LateConstReferenceDataSource(const typename DataSource< T >::value_t *ptr=0)
virtual LateConstReferenceDataSource< T > * copy(std::map< const base::DataSourceBase *, base::DataSourceBase * > &) const
Create a deep copy of this internal::DataSource, unless it is already cloned.
boost::intrusive_ptr< DataSource< T > > shared_ptr
boost::intrusive_ptr< AssignableDataSource< T > > shared_ptr
Use this type to store a pointer to an AssignableDataSource.
virtual void reset()
Reset the data to initial values.
DataSource< T >::result_t value() const
Return the result of the last evaluate() function.
virtual BinaryDataSource< function > * copy(std::map< const base::DataSourceBase *, base::DataSourceBase * > &alreadyCloned) const
Create a deep copy of this internal::DataSource, unless it is already cloned.
DataSource< T >::result_t value() const
Return the result of the last evaluate() function.
A special DataSource only to be used for if you understand the copy()/clone() semantics very well...
DataSource< T >::const_reference_t rvalue() const
Get a const reference to the value of this DataSource.
A DataSource which holds a constant value and returns it in its get() method.
virtual AliasDataSource< T > * copy(std::map< const base::DataSourceBase *, base::DataSourceBase * > &alreadyCloned) const
Create a deep copy of this internal::DataSource, unless it is already cloned.
ActionAliasDataSource(base::ActionInterface *act, DataSource< T > *ds)
A DataSource that holds a fixed size array, using the types::carray class.
virtual ActionAliasDataSource< T > * 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 which has set() methods.
DataSource< T >::const_reference_t rvalue() const
Get a const reference to the value of this DataSource.
virtual ActionAliasDataSource< T > * clone() const
Return a shallow clone of this DataSource.
virtual ValueDataSource< T > * clone() const
Return a shallow clone of this DataSource.
boost::intrusive_ptr< ReferenceDataSource< T > > shared_ptr
void const * getRawDataConst()
void reset()
Reset the data to initial values.
void setPointer(const typename AssignableDataSource< T >::value_t *ptr)
DataSource< value_t >::const_reference_t rvalue() const
Get a const reference to the value of this DataSource.
boost::remove_const< typename boost::remove_reference< T >::type >::type type
virtual result_t value() const =0
Return the result of the last evaluate() function.
DataSource< T >::value_t value_t
DataSource< T >::const_reference_t const_reference_t
DataSource< T >::const_reference_t rvalue() const
Get a const reference to the value of this DataSource.
Object that may receive a reference to some data by means of a pointer or data source.
boost::intrusive_ptr< DataSourceBase > shared_ptr
Use this type to store a pointer to a DataSourceBase.
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
AssignableDataSource< T >::const_reference_t rvalue() const
Get a const reference to the value of this DataSource.
virtual LateConstReferenceDataSource< T > * clone() const
Return a shallow clone of this DataSource.
virtual bool evaluate() const
Force an evaluation of the DataSourceBase.
AssignableDataSource< T >::const_reference_t rvalue() const
Get a const reference to the value of this DataSource.
void ref() const
Increase the reference count by one.
A simple, yet very useful DataSource, which keeps a value, and returns it in its get() method...
~ValueDataSource()
Use shared_ptr.
details::GetConstRef< T >::type const_reference_t
virtual ActionAliasAssignableDataSource< T > * clone() const
Return a shallow clone of this DataSource.
virtual ActionAliasAssignableDataSource< T > * copy(std::map< const base::DataSourceBase *, base::DataSourceBase * > &alreadyCloned) const
Create a deep copy of this internal::DataSource, unless it is already cloned.
A generic N-arity composite DataSource.
DataSource< value_t >::const_reference_t rvalue() const
Get a const reference to the value of this DataSource.
boost::intrusive_ptr< ValueDataSource< T > > shared_ptr
DataSource< T >::result_t value() const
Return the result of the last evaluate() function.
virtual UnaryDataSource< function > * clone() const
Return a shallow clone of this DataSource.
boost::intrusive_ptr< ActionAliasDataSource< T > > shared_ptr
boost::intrusive_ptr< BinaryDataSource< function > > shared_ptr
An AssignableDataSource which is used to execute an action and then return the value of another DataS...
virtual AssignableDataSource< T > * copy(std::map< const base::DataSourceBase *, base::DataSourceBase * > &alreadyCloned) const =0
Create a deep copy of this internal::DataSource, unless it is already cloned.
boost::call_traits< value_t >::param_type param_t
virtual ActionInterface * copy(std::map< const DataSourceBase *, DataSourceBase * > &alreadyCloned) const
When copying an Orocos program, we want identical internal::DataSource's to be mapped to identical Da...