RTI Connext Traditional C++ API Version 7.3.0
rti::flat::FinalAlignedArrayOffset< ElementOffset, N > Class Template Reference

Offset to an array of final elements. More...

#include <SequenceOffsets.hpp>

Inheritance diagram for rti::flat::FinalAlignedArrayOffset< ElementOffset, N >:
rti::flat::AbstractAlignedList< ElementOffset > rti::flat::OffsetBase

Public Member Functions

ElementOffset get_element (unsigned int i)
 Gets the Offset to an element. More...
- Public Member Functions inherited from rti::flat::AbstractAlignedList< ElementOffset >
iterator begin ()
 Gets an iterator to the first Offset. More...
iterator end ()
 Gets an iterator to the past-the-end element. More...
- Public Member Functions inherited from rti::flat::OffsetBase
bool is_null () const
 Indicates whether this Offset doesn't point to a valid element. More...
bool is_cpp_compatible () const
 Indicates whether rti::flat::plain_cast() is possible. More...
const unsigned char * get_buffer () const
 Gets this member's position in the buffer. More...
offset_t get_buffer_size () const
 Gets the size, in bytes, of this member in the buffer. More...

Additional Inherited Members

- Public Types inherited from rti::flat::AbstractAlignedList< ElementOffset >
typedef SequenceIterator< ElementOffset, typename ElementOffset::offset_kind > iterator
 The iterator type, SequenceIterator. More...

Detailed Description

template<typename ElementOffset, unsigned int N>
class rti::flat::FinalAlignedArrayOffset< ElementOffset, N >

Offset to an array of final elements.

Template Parameters
ElementOffsetA final struct Offset, such as MyFlatFinalOffset.
NThe array bound. For multidimensional arrays, N is the product of each dimension bound.

Represents an Offset to an array member and allows getting an Offset to each of its elements.

The following code shows how to use a FinalAlignedArrayOffset to initialize an array member with MyFlatMutableBuilder:

auto array_offset = builder.add_my_final_array();
for (MyFlatFinalOffset element_offset : array_offset) {
// ...
// Or access an element directly:
auto element_offset = array_offset.get_element(3);
Represents the Offset to an arbitrary user-defined FlatData final IDL struct.
Definition: Offset.hpp:125
Represents the Builder for an arbitrary user-defined mutable type.
Definition: Builder.hpp:206
rti::flat::FinalAlignedArrayOffset< MyFlatFinalOffset, 10 > add_my_final_array()
Adds an array member of final complex elements.
rti::flat::flat_type_traits< TopicType >::builder build_data(typename TopicType::DataWriter *writer)
Begins building a new sample.
Definition: ndds_flat_data_cpp.ifcxx:63

A more efficient way to access a final array, provided it complies with the required preconditions, is through rti::flat::plain_cast().

FinalArrayOffset and FinalAlignedArrayOffset provide the same interface, but have different implementation details. FinalArrayOffset is used when the array member is part of a final type too, whereas FinalAlignedArrayOffset corresponds to an array inside a mutable type.

A FinalAlignedArrayOffset may meet the requirements to be cast to an array of the equivalent plain C++ element type (see rti::flat::plain_cast()).

See also
MutableArrayOffset encapsulates arrays of variable-size elements

Member Function Documentation

◆ get_element()

template<typename ElementOffset , unsigned int N>
ElementOffset rti::flat::FinalAlignedArrayOffset< ElementOffset, N >::get_element ( unsigned int  i)

Gets the Offset to an element.

iThe zero-based index to the element
The Offset to the element in the i-th position
See also
rti::flat::plain_cast() for a method to access all the elements at once