$search
00001 /* Generated from orogen/lib/orogen/templates/typekit/typelib/TypelibMarshallerBase.hpp */ 00002 00003 #ifndef OROGEN_TYPELIB_MARSHALLER_BASE_HPP 00004 #define OROGEN_TYPELIB_MARSHALLER_BASE_HPP 00005 00006 #include <rtt/types/TypeTransporter.hpp> 00007 #include <typelib/value_ops.hh> 00008 00009 namespace orogen_transports 00010 { 00011 static const int TYPELIB_MARSHALLER_ID = 42; 00012 00013 class TypelibMarshallerBase : public RTT::types::TypeTransporter 00014 { 00015 bool m_plain; 00016 Typelib::Registry const* registry; 00017 Typelib::Type const* type_def; 00018 Typelib::MemoryLayout layout; 00019 std::string m_typename_typelib; 00020 std::string m_typename_orocos; 00021 00022 public: 00023 struct Handle; 00024 00025 TypelibMarshallerBase(bool plain_type, 00026 std::string const& typelib_typename, 00027 std::string const& orocos_typename, 00028 Typelib::Registry const& registry); 00029 00032 Typelib::Registry const& getRegistry() const; 00033 00037 bool isPlainTypelibType() const; 00038 00045 char const* getMarshallingType() const; 00046 00049 void setTypelibSample(Handle* data, Typelib::Value typelib_data, bool refresh_orocos = true); 00050 00061 virtual void setTypelibSample(Handle* data, uint8_t* typelib_data, bool refresh_orocos = true) = 0; 00062 00073 virtual void setOrocosSample(Handle* data, void* sample, bool refresh_typelib = true) = 0; 00074 00078 virtual void refreshOrocosSample(Handle* data) = 0; 00079 00083 virtual void refreshTypelibSample(Handle* handle) = 0; 00084 00093 uint8_t* getTypelibSample(Handle* sample); 00094 00103 uint8_t* getOrocosSample(Handle* sample); 00104 00108 virtual uint8_t* releaseOrocosSample(Handle* sample) = 0; 00109 00115 virtual Handle* createSample() = 0; 00116 00122 Handle* createHandle(); 00123 00129 virtual void deleteOrocosSample(Handle* data) = 0; 00130 00136 virtual void deleteTypelibSample(Handle* data) = 0; 00137 00144 void deleteHandle(Handle* data); 00145 00149 virtual RTT::base::DataSourceBase::shared_ptr getDataSource(Handle* handle) = 0; 00150 00153 virtual void writeDataSource(RTT::base::DataSourceBase& source, Handle const* handle) = 0; 00154 00157 virtual bool readDataSource(RTT::base::DataSourceBase& source, Handle* handle) = 0; 00158 00161 size_t getMarshallingSize(Handle const* sample) const; 00164 void marshal(int fd, Handle* sample); 00167 void marshal(std::ostream& stream, Handle* sample); 00170 void marshal(std::vector<uint8_t>& buffer, Handle* sample); 00173 int marshal(void* buffer, int buffer_size, Handle* sample); 00176 virtual void unmarshal(std::vector<uint8_t>& buffer, Handle* sample); 00179 virtual void unmarshal(void const* buffer, int buffer_size, Handle* sample); 00180 00181 virtual RTT::base::ChannelElementBase::shared_ptr createStream(RTT::base::PortInterface* port, const RTT::ConnPolicy& policy, bool is_sender) const 00182 { return RTT::base::ChannelElementBase::shared_ptr(); } 00183 }; 00184 00197 void* getOpaqueValue(std::string const& expected_type, Typelib::Value value); 00198 00201 orogen_transports::TypelibMarshallerBase* getMarshallerFor(std::string const& type); 00202 } 00203 00204 #endif 00205