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"
39namespace rti {
namespace flat {
41struct fixed_size_type_tag_t {};
42struct variable_size_type_tag_t {};
44typedef RTIXCdrUnsignedLong offset_t;
45typedef 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];
147template <
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());
344#ifdef DOXYGEN_DOCUMENTATION_ONLY
The generic definition of FlatData topic-types.
Definition: FlatSample.hpp:148
OffsetType Offset
The related Offset type.
Definition: FlatSample.hpp:155
Offset root()
Provides the Offset to the top-level type.
Definition: FlatSample.hpp:181
static Sample< OffsetType > * create_data()
Creates an unmanaged FlatData Sample.
Definition: FlatSampleImpl.hpp:67
static void delete_data(rti::flat::Sample< OffsetType > *sample)
Releases an unmanaged Sample.
Definition: FlatSample.hpp:286
Sample< OffsetType > * clone() const
Clones a Sample, creating an unmanaged Sample.
Definition: FlatSample.hpp:259
ConstOffset root() const
Provides the Offset to the top-level type.
Definition: FlatSample.hpp:203
OffsetType::ConstOffset ConstOffset
The related read-only Offset type.
Definition: FlatSample.hpp:162
rti::flat::Sample< MyFlatMutableOffset > MyFlatMutable
Represents an arbitrary user-defined flat mutable IDL struct.
Definition: FlatSample.hpp:416
rti::flat::Sample< MyFlatFinalOffset > MyFlatFinal
Represents an arbitrary user-defined FlatData final IDL struct.
Definition: FlatSample.hpp:375
rti::flat::Sample< MyFlatUnionOffset > MyFlatUnion
Represents an arbitrary user-defined flat mutable IDL union.
Definition: FlatSample.hpp:447
The RTI namespace.
Definition: AggregationBuilders.hpp:17
Given a Sample, an Offset or a Builder, it allows obtaining the other types.
Definition: FlatSample.hpp:340