00001 /*************************************************************************** 00002 tag: Peter Soetens Wed Jan 18 14:11:39 CET 2006 DataSourceBase.hpp 00003 00004 DataSourceBase.hpp - description 00005 ------------------- 00006 begin : Wed January 18 2006 00007 copyright : (C) 2006 Peter Soetens 00008 email : peter.soetens@mech.kuleuven.be 00009 00010 *************************************************************************** 00011 * This library is free software; you can redistribute it and/or * 00012 * modify it under the terms of the GNU General Public * 00013 * License as published by the Free Software Foundation; * 00014 * version 2 of the License. * 00015 * * 00016 * As a special exception, you may use this file as part of a free * 00017 * software library without restriction. Specifically, if other files * 00018 * instantiate templates or use macros or inline functions from this * 00019 * file, or you compile this file and link it with other files to * 00020 * produce an executable, this file does not by itself cause the * 00021 * resulting executable to be covered by the GNU General Public * 00022 * License. This exception does not however invalidate any other * 00023 * reasons why the executable file might be covered by the GNU General * 00024 * Public License. * 00025 * * 00026 * This library is distributed in the hope that it will be useful, * 00027 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00028 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00029 * Lesser General Public License for more details. * 00030 * * 00031 * You should have received a copy of the GNU General Public * 00032 * License along with this library; if not, write to the Free Software * 00033 * Foundation, Inc., 59 Temple Place, * 00034 * Suite 330, Boston, MA 02111-1307 USA * 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/oro_atomic.h" 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 DataSourceBase 00078 { 00079 protected: 00089 mutable oro_atomic_t 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 std::ostream& operator<<(std::ostream& os, DataSourceBase::shared_ptr dsb ); 00283 00284 } 00285 00286 void intrusive_ptr_add_ref(const RTT::DataSourceBase* p ); 00287 void intrusive_ptr_release(const RTT::DataSourceBase* p ); 00288 00289 #endif
1.5.8