Orocos Real-Time Toolkit  2.9.0
DataObjectDataSource.hpp
Go to the documentation of this file.
1 #ifndef DATAOBJECTDATASOURCE_HPP_
2 #define DATAOBJECTDATASOURCE_HPP_
3 
4 #include "DataSource.hpp"
5 #include "../base/DataObjectInterface.hpp"
6 
7 namespace RTT
8 {
9  namespace internal {
17  template<typename T>
19  : public DataSource<T>
20  {
22  mutable T mcopy;
23  public:
24  typedef boost::intrusive_ptr<DataObjectDataSource<T> > shared_ptr;
25 
27  : mobject(obj)
28  {}
29 
30  virtual ~DataObjectDataSource() { }
31 
32  bool evaluate() const {
33  mobject->Get( mcopy );
34  return true;
35  }
36 
37  typename DataSource<T>::result_t get() const
38  {
39  mobject->Get(mcopy);
40  return mcopy;
41  }
42 
43  typename DataSource<T>::result_t value() const
44  {
45  return mcopy;
46  }
47 
49  {
50  return mcopy;
51  }
52 
53  virtual void reset() { }
54 
55  virtual DataObjectDataSource<T>* clone() const {
56  return new DataObjectDataSource(mobject);
57  }
58  virtual DataObjectDataSource<T>* copy( std::map<const base::DataSourceBase*, base::DataSourceBase*>& alreadyCloned ) const {
59  return new DataObjectDataSource(mobject);
60  }
61  };
62  }
63 }
64 
65 #endif /* DATAOBJECTDATASOURCE_HPP_ */
DataSource is a base class representing a generic way to read data of type T.
Definition: DataSource.hpp:94
virtual DataObjectDataSource< T > * clone() const
Return a shallow clone of this DataSource.
boost::shared_ptr< DataObjectInterface< T > > shared_ptr
Used for shared_ptr management.
bool evaluate() const
Force an evaluation of the DataSourceBase.
virtual FlowStatus Get(reference_t pull, bool copy_old_data=true) const =0
Get a copy of the Data of this data object.
virtual DataObjectDataSource< T > * copy(std::map< const base::DataSourceBase *, base::DataSourceBase * > &alreadyCloned) const
Create a deep copy of this internal::DataSource, unless it is already cloned.
virtual void reset()
Reset the data to initial values.
boost::intrusive_ptr< DataObjectDataSource< T > > shared_ptr
DataSource< T >::const_reference_t rvalue() const
Get a const reference to the value of this DataSource.
DataObjectDataSource(typename base::DataObjectInterface< T >::shared_ptr obj)
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:52
details::GetConstRef< T >::type const_reference_t
Definition: DataSource.hpp:107
A DataSource which is used to read a DataObject.
DataSource< T >::result_t value() const
Return the result of the last evaluate() function.