00001
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::Type const* type_def;
00017 Typelib::MemoryLayout layout;
00018 std::string m_typename_typelib;
00019 std::string m_typename_orocos;
00020
00021 public:
00022 struct Handle;
00023
00024 TypelibMarshallerBase(bool plain_type,
00025 std::string const& typelib_typename,
00026 std::string const& orocos_typename,
00027 Typelib::Registry const& registry);
00028
00032 bool isPlainTypelibType() const;
00033
00040 char const* getMarshallingType() const;
00041
00044 void setTypelibSample(Handle* data, Typelib::Value typelib_data, bool refresh_orocos = true);
00045
00056 virtual void setTypelibSample(Handle* data, uint8_t* typelib_data, bool refresh_orocos = true) = 0;
00057
00068 virtual void setOrocosSample(Handle* data, void* sample, bool refresh_typelib = true) = 0;
00069
00073 virtual void refreshOrocosSample(Handle* data) = 0;
00074
00078 virtual void refreshTypelibSample(Handle* handle) = 0;
00079
00083 uint8_t* getTypelibSample(Handle* sample);
00084
00088 virtual uint8_t* releaseOrocosSample(Handle* sample) = 0;
00089
00095 virtual Handle* createSample() = 0;
00096
00102 Handle* createHandle();
00103
00109 virtual void deleteOrocosSample(Handle* data) = 0;
00110
00116 virtual void deleteTypelibSample(Handle* data) = 0;
00117
00124 void deleteHandle(Handle* data);
00125
00129 virtual RTT::base::DataSourceBase::shared_ptr getDataSource(Handle* handle) = 0;
00130
00133 virtual void writeDataSource(RTT::base::DataSourceBase& source, Handle const* handle) = 0;
00134
00137 virtual bool readDataSource(RTT::base::DataSourceBase& source, Handle* handle) = 0;
00138
00141 size_t getMarshallingSize(Handle const* sample) const;
00144 void marshal(int fd, Handle* sample);
00147 void marshal(std::ostream& stream, Handle* sample);
00150 void marshal(std::vector<uint8_t>& buffer, Handle* sample);
00153 int marshal(void* buffer, int buffer_size, Handle* sample);
00156 virtual void unmarshal(std::vector<uint8_t>& buffer, Handle* sample);
00159 virtual void unmarshal(void const* buffer, int buffer_size, Handle* sample);
00160
00161 virtual RTT::base::ChannelElementBase::shared_ptr createStream(RTT::base::PortInterface* port, const RTT::ConnPolicy& policy, bool is_sender) const
00162 { return RTT::base::ChannelElementBase::shared_ptr(); }
00163 };
00164
00177 void* getOpaqueValue(std::string const& expected_type, Typelib::Value value);
00178 }
00179
00180 #endif
00181