Orocos Real-Time Toolkit  2.8.3
DataSource.inl
Go to the documentation of this file.
1 #ifndef CORELIB_DATASOURCE_INL
2 #define CORELIB_DATASOURCE_INL
3 
4 #include "AssignCommand.hpp"
5 #include "DataSourceTypeInfo.hpp"
6 #include "../types/TypeTransporter.hpp"
7 
8 #include "../rtt-config.h"
9 
10 namespace RTT
11 { namespace internal {
12 
13 
14  template<typename T>
16  {
17  }
18 
19  template< typename T>
20  std::string DataSource<T>::getType() const
21  {
22  return DataSource<T>::GetType();
23  }
24 
25  template< typename T>
26  std::string DataSource<T>::getTypeName() const
27  {
29  }
30 
31  template< typename T>
32  std::string DataSource<T>::GetType()
33  {
35 
36  }
37 
38  template< typename T>
40  {
42 
43  }
44 
45  template< typename T>
46  const types::TypeInfo* DataSource<T>::getTypeInfo() const { return GetTypeInfo(); }
47 
48  template< typename T>
50 
51  template< typename T>
53  {
54  this->get();
55  return true;
56  }
57 
58  template<>
59  inline void const* DataSource<void>::getRawConstPointer() { return 0; }
60 
61  template<typename T>
63  {}
64 
65  template<class T>
67  DataSource<T>* ret = dynamic_cast< DataSource<T>* >( dsb );
68  return ret;
69  }
70 
71  template<class T>
73  AssignableDataSource<T>* ret = dynamic_cast< AssignableDataSource<T>* >( dsb );
74  return ret;
75  }
76 
77  template<class T>
79  if (!other) return false;
80 
82  typename DataSource<T>::shared_ptr o = boost::dynamic_pointer_cast< DataSource<T> >( DataSourceTypeInfo<T>::getTypeInfo()->convert(r) );
83  if (o) {
84  if ( o->evaluate() ) {
85  this->set( o->value() );
86  return true;
87  }
88  return false;
89  }
90  return false;
91  }
92 
93  template<class T>
95 #ifndef ORO_EMBEDDED
96  if (!other) throw bad_assignment();
97 #else
98  if (!other) return 0;
99 #endif
100 
101  // Use the same rules of parameter passing as C++, but no const for 'int',...
103  typename DataSource<value_t>::shared_ptr t = boost::dynamic_pointer_cast< DataSource<value_t> >( DataSourceTypeInfo<T>::getTypeInfo()->convert(r) );
104  if ( t )
105  return new AssignCommand<value_t>( this, t );
106 
107 #ifndef ORO_EMBEDDED
108  throw bad_assignment();
109 #endif
110 
111  return 0;
112  }
113 }}
114 
115 
116 #endif
DataSource is a base class representing a generic way to read data of type T.
Definition: DataSource.hpp:94
base::DataSourceBase::shared_ptr convert(base::DataSourceBase::shared_ptr arg) const
Automatic conversion: convert a internal::DataSource to this type.
Definition: TypeInfo.cpp:118
The base class for all internal data representations.
static const std::string & getQualifier()
Return the &#39;const&#39;, &#39;ref&#39;, &#39;pointer&#39; qualifier for this type.
static std::string GetTypeName()
Return the Orocos type name, without const, pointer or reference qualifiers.
Definition: DataSource.inl:39
This exception is thrown if the target and source type of an assignment of a DataSource with a base::...
Definition: DataSource.hpp:62
static const types::TypeInfo * GetTypeInfo()
Return the Orocos type info.
Definition: DataSource.inl:49
virtual std::string getType() const
Return useful type info in a human readable format.
Definition: DataSource.inl:20
static const types::TypeInfo * getTypeInfo()
Return the typeinfo object.
Based on the software pattern &#39;command&#39;, this interface allows execution of action objects...
A class for representing a user type, and which can build instances of that type. ...
Definition: TypeInfo.hpp:66
virtual base::ActionInterface * updateAction(base::DataSourceBase *other)
Generate a ActionInterface object which will update this internal::DataSource with the value of anoth...
Definition: DataSource.inl:94
boost::intrusive_ptr< DataSource< T > > shared_ptr
Definition: DataSource.hpp:115
static AssignableDataSource< T > * narrow(base::DataSourceBase *db)
This method narrows a base::DataSourceBase to a typeded AssignableDataSource, possibly returning a ne...
Definition: DataSource.inl:72
A DataSource which has set() methods.
Definition: DataSource.hpp:184
static DataSource< T > * narrow(base::DataSourceBase *db)
This method narrows a base::DataSourceBase to a typeded DataSource, possibly returning a new object...
Definition: DataSource.inl:66
virtual result_t value() const =0
Return the result of the last evaluate() function.
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.
Definition: Activity.cpp:51
This is a command that will assign the value of an expression to another at runtime.
void const * getRawConstPointer()
Generic implementation of getRawConstPointer() based on rvalue()
Definition: DataSource.hpp:141
virtual bool evaluate() const
Force an evaluation of the DataSourceBase.
Definition: DataSource.inl:52
virtual bool update(base::DataSourceBase *other)
Update the value of this internal::DataSource with the value of an other DataSource.
Definition: DataSource.inl:78
static std::string GetType()
Return usefull type info in a human readable format.
Definition: DataSource.inl:32
static const std::string & getTypeName()
Return the unqualified typename.
virtual std::string getTypeName() const
Return the Orocos type name, without const, pointer or reference qualifiers.
Definition: DataSource.inl:26
virtual const types::TypeInfo * getTypeInfo() const
Return the Orocos type info object.
Definition: DataSource.inl:46