Orocos Real-Time Toolkit
2.5.0
|
00001 /*************************************************************************** 00002 tag: Peter Soetens Mon Jan 19 14:11:26 CET 2004 TypeInfo.hpp 00003 00004 TypeInfo.hpp - description 00005 ------------------- 00006 begin : Mon January 19 2004 00007 copyright : (C) 2004 Peter Soetens 00008 email : peter.soetens@mech.kuleuven.ac.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 #ifndef ORO_CORELIB_TYPEINFO_HPP 00039 #define ORO_CORELIB_TYPEINFO_HPP 00040 00041 #include <vector> 00042 #include <string> 00043 #include "../base/DataSourceBase.hpp" 00044 #include "../base/ChannelElementBase.hpp" 00045 00046 namespace RTT 00047 { namespace types { 00048 00053 class RTT_API TypeInfo 00054 { 00055 protected: 00056 typedef std::vector<TypeBuilder*> Constructors; 00057 typedef std::vector<TypeTransporter*> Transporters; 00058 Constructors constructors; 00059 Transporters transporters; 00060 public: 00061 virtual ~TypeInfo(); 00065 virtual const std::string& getTypeName() const = 0; 00066 00077 virtual bool installTypeInfoObject() = 0; 00078 00089 virtual base::AttributeBase* buildConstant(std::string name,base::DataSourceBase::shared_ptr, int sizehint) const; 00090 virtual base::AttributeBase* buildConstant(std::string name,base::DataSourceBase::shared_ptr) const = 0; 00096 virtual base::AttributeBase* buildVariable(std::string name,int sizehint) const; 00097 virtual base::AttributeBase* buildVariable(std::string name) const = 0; 00098 00103 virtual bool resize(base::DataSourceBase::shared_ptr arg, int size) const; 00104 00110 virtual base::DataSourceBase::shared_ptr construct(const std::vector<base::DataSourceBase::shared_ptr>& args) const; 00111 00117 virtual base::DataSourceBase::shared_ptr convert(base::DataSourceBase::shared_ptr arg) const; 00118 00122 virtual void addConstructor(TypeBuilder* tb); 00123 00128 virtual base::AttributeBase* buildAlias(std::string name, base::DataSourceBase::shared_ptr b ) const = 0; 00129 00133 virtual base::PropertyBase* buildProperty(const std::string& name, const std::string& desc, base::DataSourceBase::shared_ptr source = 0) const = 0; 00134 00138 virtual base::AttributeBase* buildAttribute(std::string name, base::DataSourceBase::shared_ptr source = 0 ) const = 0; 00139 00143 virtual base::DataSourceBase::shared_ptr buildValue() const = 0; 00144 00148 virtual base::DataSourceBase::shared_ptr buildReference(void* ptr) const = 0; 00149 00155 virtual base::DataSourceBase::shared_ptr buildActionAlias(base::ActionInterface* action, base::DataSourceBase::shared_ptr source) const = 0; 00167 virtual std::ostream& write(std::ostream& os, base::DataSourceBase::shared_ptr in ) const = 0; 00168 00173 virtual std::istream& read(std::istream& os, base::DataSourceBase::shared_ptr out ) const = 0; 00174 00178 virtual std::string toString( base::DataSourceBase::shared_ptr in ) const; 00179 00183 virtual bool fromString( const std::string& value, base::DataSourceBase::shared_ptr out ) const; 00184 00189 virtual bool isStreamable() const = 0; 00202 virtual std::vector<std::string> getMemberNames() const; 00203 00211 virtual base::DataSourceBase::shared_ptr getMember(base::DataSourceBase::shared_ptr item, const std::string& name) const; 00212 00219 virtual base::DataSourceBase::shared_ptr getMember(base::DataSourceBase::shared_ptr item, 00220 base::DataSourceBase::shared_ptr id) const; 00221 00240 virtual bool composeType( base::DataSourceBase::shared_ptr source, base::DataSourceBase::shared_ptr target) const = 0; 00241 00253 virtual base::DataSourceBase::shared_ptr decomposeType(base::DataSourceBase::shared_ptr source) const; 00254 00262 virtual base::DataSourceBase::shared_ptr convertType(base::DataSourceBase::shared_ptr source) const; 00263 00277 bool addProtocol(int protocol_id, TypeTransporter* tt); 00278 00284 TypeTransporter* getProtocol(int protocol_id) const; 00285 00289 bool hasProtocol(int protocol_id) const; 00290 00294 std::vector<int> getTransportNames() const; 00295 00296 typedef const std::type_info * TypeId; 00297 virtual TypeId getTypeId() const = 0; 00298 virtual const char * getTypeIdName() const = 0; 00299 00304 virtual base::InputPortInterface* inputPort(std::string const& name) const = 0; 00305 00310 virtual base::OutputPortInterface* outputPort(std::string const& name) const = 0; 00311 00318 virtual base::ChannelElementBase::shared_ptr buildDataStorage(ConnPolicy const& policy) const = 0; 00319 virtual base::ChannelElementBase::shared_ptr buildChannelOutput(base::InputPortInterface& port) const = 0; 00320 virtual base::ChannelElementBase::shared_ptr buildChannelInput(base::OutputPortInterface& port) const = 0; 00321 00322 protected: 00330 void migrateProtocols(TypeInfo* orig); 00331 }; 00332 00333 }} 00334 00335 #endif