DataSource.hpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef CORELIB_DATASOURCE_HPP
00039 #define CORELIB_DATASOURCE_HPP
00040
00041 #include <map>
00042 #include <string>
00043 #include "rtt-config.h"
00044 #include <boost/call_traits.hpp>
00045 #include <boost/type_traits.hpp>
00046
00047 #include "DataSourceBase.hpp"
00048
00049 namespace RTT
00050 {
00051
00052 #ifndef ORO_EMBEDDED
00053
00058 struct RTT_EXPORT bad_assignment
00059 {
00060 };
00061 #endif
00062
00063
00075 template<typename T>
00076 class DataSource
00077 : public DataSourceBase
00078 {
00079 protected:
00080 virtual ~DataSource();
00081
00082 public:
00086 typedef typename boost::remove_const<typename boost::remove_reference<T>::type>::type value_t;
00087 typedef T result_t;
00088
00089 typedef typename boost::intrusive_ptr<DataSource<T> > shared_ptr;
00090
00091 typedef typename boost::intrusive_ptr<const DataSource<T> > const_ptr;
00092
00096 virtual result_t get() const = 0;
00097
00101 virtual result_t value() const = 0;
00102
00103 virtual bool evaluate() const;
00104
00105 virtual DataSource<T>* clone() const = 0;
00106
00107 virtual DataSource<T>* copy( std::map<const DataSourceBase*, DataSourceBase*>& alreadyCloned ) const = 0;
00108
00109 virtual std::string getType() const;
00110
00114 static std::string GetType();
00115
00116 virtual const TypeInfo* getTypeInfo() const;
00117
00121 static const TypeInfo* GetTypeInfo();
00122
00127 static std::string GetTypeName();
00128
00129 virtual std::string getTypeName() const;
00130
00135 static DataSource<T>* narrow(DataSourceBase* db);
00136
00137 };
00138
00143 template<typename T>
00144 class AssignableDataSource
00145 : public DataSource<T>
00146 {
00147 protected:
00148 ~AssignableDataSource();
00149 public:
00150 typedef typename DataSource<T>::value_t value_t;
00151 typedef typename boost::call_traits<value_t>::param_type param_t;
00152 typedef typename boost::call_traits<value_t>::reference reference_t;
00153 typedef typename boost::call_traits<value_t>::const_reference const_reference_t;
00154
00155
00156
00157
00158 typedef typename boost::remove_const<typename boost::call_traits<value_t>::param_type>::type copy_t;
00159
00163 typedef boost::intrusive_ptr<AssignableDataSource<T> > shared_ptr;
00164 typedef typename boost::intrusive_ptr<const AssignableDataSource<T> > const_ptr;
00165
00169 virtual void set( param_t t ) = 0;
00170
00178 virtual reference_t set() = 0;
00179
00187 virtual const_reference_t rvalue() const = 0;
00188
00189 virtual bool update( DataSourceBase* other );
00190
00191 virtual CommandInterface* updateCommand( DataSourceBase* other);
00192
00193 virtual AssignableDataSource<T>* clone() const = 0;
00194
00195 virtual AssignableDataSource<T>* copy( std::map<const DataSourceBase*, DataSourceBase*>& alreadyCloned ) const = 0;
00196
00197 virtual bool updateBlob(int protocol, const void* data);
00198
00199 virtual void* server(int protocol, void* data );
00200
00205 static AssignableDataSource<T>* narrow(DataSourceBase* db);
00206
00207 };
00208 }
00209
00210
00211 #ifndef ORO_CORELIB_DATASOURCES_HPP
00212 #include "DataSource.inl"
00213 #endif
00214 #endif
00215