DataSourceBase.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
00039
00040 #ifndef CORELIB_DATASOURCE_BASE_HPP
00041 #define CORELIB_DATASOURCE_BASE_HPP
00042
00043 #include <boost/intrusive_ptr.hpp>
00044 #include <map>
00045 #include <string>
00046 #include "os/Atomic.hpp"
00047 #include "rtt-config.h"
00048 #include "CommandInterface.hpp"
00049
00050 namespace RTT
00051 {
00052 class TypeInfo;
00053 class PropertyBag;
00054 class MethodC;
00055
00077 class RTT_API DataSourceBase
00078 {
00079 protected:
00089 mutable OS::AtomicInt refcount;
00090
00094 virtual ~DataSourceBase();
00095
00096 public:
00100 typedef boost::intrusive_ptr<DataSourceBase> shared_ptr;
00101
00105 typedef boost::intrusive_ptr<const DataSourceBase> const_ptr;
00106
00107 DataSourceBase();
00111 void ref() const;
00115 void deref() const;
00116
00120 virtual void reset();
00121
00127 virtual bool evaluate() const = 0;
00128
00134 virtual void updated();
00135
00143 virtual bool update( DataSourceBase* other );
00144
00151 virtual CommandInterface* updateCommand( DataSourceBase* other);
00152
00160 virtual bool updatePart( DataSourceBase* part, DataSourceBase* other );
00161
00169 virtual CommandInterface* updatePartCommand( DataSourceBase* part, DataSourceBase* other);
00170
00177 virtual DataSourceBase* clone() const = 0;
00178
00186 virtual DataSourceBase* copy( std::map<const DataSourceBase*, DataSourceBase*>& alreadyCloned ) const = 0;
00187
00191 virtual std::string getType() const = 0;
00192
00196 virtual const TypeInfo* getTypeInfo() const = 0;
00197
00202 virtual std::string getTypeName() const = 0;
00203
00208 std::ostream& write(std::ostream& os);
00209
00214 std::string toString();
00215
00220 bool decomposeType( PropertyBag& targetbag );
00221
00226 bool composeType( DataSourceBase::shared_ptr source);
00227
00235 virtual void* createBlob(int protocol);
00236
00244 virtual void* getBlob(int protocol);
00245
00252 virtual bool updateBlob(int protocol, const void* data);
00253
00259 virtual int serverProtocol() const;
00260
00267 virtual void* server( int protocol, void* arg );
00268
00275 virtual void* method( int protocol, MethodC* orig, void* arg );
00276 };
00277
00282 RTT_API std::ostream& operator<<(std::ostream& os, DataSourceBase::shared_ptr dsb );
00283
00284 }
00285
00286 RTT_API void intrusive_ptr_add_ref(const RTT::DataSourceBase* p );
00287 RTT_API void intrusive_ptr_release(const RTT::DataSourceBase* p );
00288
00289 #endif