Orocos Real-Time Toolkit
2.6.0
|
00001 #ifndef DATAOBJECTDATASOURCE_HPP_ 00002 #define DATAOBJECTDATASOURCE_HPP_ 00003 00004 #include "DataSource.hpp" 00005 #include "../base/DataObjectInterface.hpp" 00006 00007 namespace RTT 00008 { 00009 namespace internal { 00017 template<typename T> 00018 class DataObjectDataSource 00019 : public DataSource<T> 00020 { 00021 typename base::DataObjectInterface<T>::shared_ptr mobject; 00022 mutable T mcopy; 00023 public: 00024 typedef boost::intrusive_ptr<DataObjectDataSource<T> > shared_ptr; 00025 00026 DataObjectDataSource(typename base::DataObjectInterface<T>::shared_ptr obj) 00027 : mobject(obj) 00028 {} 00029 00030 virtual ~DataObjectDataSource() { } 00031 00032 bool evaluate() const { 00033 mobject->Get( mcopy ); 00034 return true; 00035 } 00036 00037 typename DataSource<T>::result_t get() const 00038 { 00039 mobject->Get(mcopy); 00040 return mcopy; 00041 } 00042 00043 typename DataSource<T>::result_t value() const 00044 { 00045 return mcopy; 00046 } 00047 00048 typename DataSource<T>::const_reference_t rvalue() const 00049 { 00050 return mcopy; 00051 } 00052 00053 virtual void reset() { } 00054 00055 virtual DataObjectDataSource<T>* clone() const { 00056 return new DataObjectDataSource(mobject); 00057 } 00058 virtual DataObjectDataSource<T>* copy( std::map<const base::DataSourceBase*, base::DataSourceBase*>& alreadyCloned ) const { 00059 return new DataObjectDataSource(mobject); 00060 } 00061 }; 00062 } 00063 } 00064 00065 #endif /* DATAOBJECTDATASOURCE_HPP_ */