Orocos Real-Time Toolkit
2.5.0
|
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 <vector> 00047 #include "../os/Atomic.hpp" 00048 #include "../rtt-config.h" 00049 #include "ActionInterface.hpp" 00050 #include "../rtt-fwd.hpp" 00051 00052 namespace RTT 00053 { namespace base { 00054 00076 class RTT_API DataSourceBase 00077 { 00078 protected: 00088 mutable os::AtomicInt refcount; 00089 00093 virtual ~DataSourceBase(); 00094 00095 public: 00099 typedef boost::intrusive_ptr<DataSourceBase> shared_ptr; 00100 00104 typedef boost::intrusive_ptr<const DataSourceBase> const_ptr; 00105 00111 static shared_ptr stack_shared_ptr(DataSourceBase* dsb); 00112 00118 static const_ptr stack_const_ptr(const DataSourceBase* dsb); 00119 00120 DataSourceBase(); 00124 void ref() const; 00128 void deref() const; 00129 00133 virtual void reset(); 00134 00139 virtual bool evaluate() const = 0; 00140 00146 virtual bool isAssignable() const; 00147 00153 virtual void updated(); 00154 00163 virtual bool update( DataSourceBase* other ); 00164 00172 virtual ActionInterface* updateAction( DataSourceBase* other); 00173 00182 virtual shared_ptr getMember( const std::string& member_name); 00183 00191 virtual shared_ptr getMember( DataSourceBase::shared_ptr member_id, DataSourceBase::shared_ptr offset); 00192 00199 virtual std::vector<std::string> getMemberNames() const; 00200 00205 virtual shared_ptr getParent(); 00206 00213 virtual DataSourceBase* clone() const = 0; 00214 00222 virtual DataSourceBase* copy( std::map<const DataSourceBase*, DataSourceBase*>& alreadyCloned ) const = 0; 00223 00227 virtual std::string getType() const = 0; 00228 00232 virtual const types::TypeInfo* getTypeInfo() const = 0; 00233 00238 virtual std::string getTypeName() const = 0; 00239 00244 std::ostream& write(std::ostream& os); 00245 00250 std::string toString(); 00251 00258 virtual void* getRawPointer(); 00259 00266 virtual void const* getRawConstPointer(); 00267 }; 00268 00273 RTT_API std::ostream& operator<<(std::ostream& os, DataSourceBase::shared_ptr dsb ); 00274 00275 RTT_API void intrusive_ptr_add_ref( const RTT::base::DataSourceBase* p ); 00276 RTT_API void intrusive_ptr_release( const RTT::base::DataSourceBase* p ); 00277 00278 }} 00279 00280 #endif