11 #ifndef RTI_DDS_FLAT_FLATSAMPLE_HPP_
12 #define RTI_DDS_FLAT_FLATSAMPLE_HPP_
19 #include "xcdr/xcdr_stream_impl.h"
20 #include "xcdr/xcdr_flat_data.h"
21 #include "xcdr/xcdr_interpreter.h"
23 #include "rti/xcdr/Interpreter.hpp"
39 namespace rti {
namespace flat {
41 struct fixed_size_type_tag_t {};
42 struct variable_size_type_tag_t {};
44 typedef RTIXCdrUnsignedLong offset_t;
45 typedef RTIXCdrUnsignedLong member_id_t;
51 unsigned char* get_buffer()
56 const unsigned char* get_buffer()
const
61 unsigned char* get_root_buffer()
63 return get_buffer() + RTI_XCDR_ENCAPSULATION_SIZE;
69 const unsigned char* get_root_buffer()
const
71 return get_buffer() + RTI_XCDR_ENCAPSULATION_SIZE;
74 void initialize_stream(
75 RTIXCdrStream& stream,
77 offset_t serialized_size)
const
79 RTIXCdrFlatData_initializeStream(
81 const_cast<unsigned char*>(get_buffer()),
87 #if !defined(RTI_FLAT_DATA_CXX11_DELETED_FUNCTIONS)
89 SampleBase(
const SampleBase&) {}
90 SampleBase& operator=(
const SampleBase&);
92 SampleBase() =
delete;
93 SampleBase(
const SampleBase&) =
delete;
94 SampleBase& operator=(
const SampleBase&) =
delete;
99 unsigned char data[1];
147 template <
typename OffsetType>
183 return root_impl(
typename Offset::offset_kind());
205 return root_impl(
typename ConstOffset::offset_kind());
211 RTIXCdrEndian endian()
const
213 RTIXCdrStream tmp_stream;
214 initialize_stream(tmp_stream, 0, RTI_XCDR_ENCAPSULATION_SIZE);
215 return tmp_stream._endian;
221 static Sample<OffsetType>* from_buffer(
unsigned char *buffer)
223 return reinterpret_cast<Sample<OffsetType>*
>(buffer);
261 unsigned char *buffer = RTIXCdrFlatData_cloneSample(
265 if (buffer == NULL) {
266 #ifndef RTI_FLAT_DATA_NO_EXCEPTIONS
267 throw std::bad_alloc();
288 RTIXCdrFlatData_deleteSample(sample);
293 offset_t buffer_size()
const
295 return sample_size() + RTI_XCDR_ENCAPSULATION_SIZE;
300 offset_t sample_size()
const
302 return sample_size_impl(
typename OffsetType::offset_kind());
306 offset_t sample_size_impl(fixed_size_type_tag_t)
const
308 return OffsetType::serialized_size(0);
311 offset_t sample_size_impl(variable_size_type_tag_t)
const
313 return RTIXCdrFlatSample_getMutableSampleSize(
315 RTI_XCDR_ENCAPSULATION_SIZE);
318 Offset root_impl(fixed_size_type_tag_t)
320 return Offset(
this, RTI_XCDR_ENCAPSULATION_SIZE);
323 Offset root_impl(variable_size_type_tag_t)
325 return Offset(
this, RTI_XCDR_ENCAPSULATION_SIZE, sample_size());
330 return ConstOffset(
this, RTI_XCDR_ENCAPSULATION_SIZE);
333 ConstOffset root_impl(variable_size_type_tag_t)
const
335 return ConstOffset(
this, RTI_XCDR_ENCAPSULATION_SIZE, sample_size());
339 template <
typename T>
340 struct flat_type_traits;
344 #ifdef DOXYGEN_DOCUMENTATION_ONLY
450 #endif // RTI_DDS_FLAT_FLATSAMPLE_HPP_