11#ifndef RTI_DDS_FLAT_BUILDERHELPER_HPP_
12#define RTI_DDS_FLAT_BUILDERHELPER_HPP_
14namespace rti {
namespace flat {
17class PrimitiveSequenceBuilder;
19template <
typename ElementBuilder>
20class MutableSequenceBuilder;
22template <
typename ElementOffset>
23class FinalSequenceBuilder;
25template <
typename ElementBuilder,
unsigned int N>
26class MutableArrayBuilder;
36template <
size_t PrimitiveSize>
37struct primitive_lc_code_helper;
40struct primitive_lc_code_helper<1> {
48struct primitive_lc_code_helper<2> {
56struct primitive_lc_code_helper<4> {
64struct primitive_lc_code_helper<8> {
72struct primitive_lc_code {
73 enum { value = primitive_lc_code_helper<
sizeof(T)>::single };
87struct lc_code<MutableSequenceBuilder<T> > {
94struct lc_code<FinalSequenceBuilder<T> > {
100template <
typename T,
unsigned int N>
101struct lc_code<MutableArrayBuilder<T, N> > {
109struct lc_code<PrimitiveSequenceBuilder<T> > {
110 enum { value = primitive_lc_code_helper<
sizeof(T)>::sequence };
114struct lc_code<StringBuilder> : lc_code<PrimitiveSequenceBuilder<char> > {};
120template <
typename Offset>
121struct final_offset_initializer {
123 static bool initialize(Offset& offset)
125 return RTI_XCDR_TRUE == RTIXCdrFlatData_initializeSample(
126 (
char *) offset.get_buffer(),
127 offset.get_buffer_size(),
135template <
typename T,
typename Enable =
void>
136struct default_primitive_value {
143template <
typename T,
unsigned int N>
144struct final_offset_initializer<
rti::flat::PrimitiveArrayOffset<T, N> > {
148 T default_value = default_primitive_value<T>::get();
149 if (default_value == (T) 0) {
160template <
typename T,
unsigned int N>
161struct final_offset_initializer<
rti::flat::FinalAlignedArrayOffset<T, N> > {
165 for (
unsigned int i = 0; i < N; i++) {
167 if (offset.is_null()) {
171 if (!final_offset_initializer<T>::initialize(offset)) {
bool set_element(unsigned int i, T value)
Sets an element by index.
Definition: SequenceOffsets.hpp:111
Offset to an array of final elements.
Definition: SequenceOffsets.hpp:730
ElementOffset get_element(unsigned int i)
Gets the Offset to an element.
Definition: SequenceOffsets.hpp:768
const unsigned char * get_buffer() const
Gets this member's position in the buffer.
Definition: Offset.hpp:554
offset_t get_buffer_size() const
Gets the size, in bytes, of this member in the buffer.
Definition: Offset.hpp:568
Offset to an array of primitive elements.
Definition: SequenceOffsets.hpp:220
unsigned int element_count() const
Returns the number of elements, N.
Definition: SequenceOffsets.hpp:242
The generic definition of FlatData topic-types.
Definition: FlatSample.hpp:148
The RTI namespace.
Definition: AggregationBuilders.hpp:17