RTI Connext Modern C++ API Version 7.3.0
|
Offsets provide access to the members of a FlatData Sample. More...
Classes | |
class | MyFlatFinalOffset |
Represents the Offset to an arbitrary user-defined FlatData final IDL struct. More... | |
class | MyFlatMutableOffset |
Represents the Offset to an arbitrary user-defined FlatData mutable IDL struct. More... | |
class | MyFlatUnionOffset |
Represents the Offset to an arbitrary user-defined FlatData mutable IDL union. More... | |
class | rti::flat::OffsetBase |
Base class of all Offset types. More... | |
class | rti::flat::FinalOffset< T > |
The base class of all Offsets to a final struct type. More... | |
class | rti::flat::MutableOffset |
The base class of all Offsets to a final struct type. More... | |
struct | rti::flat::PrimitiveConstOffset< T > |
A const Offset to an optional primitive member. More... | |
struct | rti::flat::PrimitiveOffset< T > |
An Offset to an optional primitive member. More... | |
class | rti::flat::SequenceIterator< E, OffsetKind > |
Iterator for collections of Offsets. More... | |
class | rti::flat::AbstractPrimitiveList< T > |
Base class for Offsets to sequences and arrays of primitive types. More... | |
class | rti::flat::PrimitiveSequenceOffset< T > |
Offset to a sequence of primitive elements. More... | |
class | rti::flat::PrimitiveArrayOffset< T, N > |
Offset to an array of primitive elements. More... | |
class | rti::flat::StringOffset |
Offset to a string. More... | |
class | rti::flat::AbstractAlignedList< ElementOffset > |
Base class of Offsets to sequences and arrays of non-primitive members. More... | |
class | rti::flat::SequenceOffset< ElementOffset > |
Offset to a sequence of non-primitive elements. More... | |
class | rti::flat::MutableArrayOffset< ElementOffset, N > |
Offset to an array of variable-size elements. More... | |
class | rti::flat::FinalArrayOffset< ElementOffset, N > |
Offset to an array of final elements. More... | |
class | rti::flat::FinalAlignedArrayOffset< ElementOffset, N > |
Offset to an array of final elements. More... | |
Functions | |
template<typename OffsetType > | |
flat_type_traits< OffsetType >::plain_type * | rti::flat::plain_cast (OffsetType &offset) |
Casts into an equivalent plain C++ type. More... | |
template<typename OffsetType > | |
const flat_type_traits< OffsetType >::plain_type * | rti::flat::plain_cast (const OffsetType &offset) |
Const version of plain_cast. More... | |
Offsets provide access to the members of a FlatData Sample.
An Offset represents a position within a FlatData Sample that allows accessing a member of that Sample, or the Sample's root.
Offsets can be described as iterators. They represent a position in a buffer, not the value itself. As such, they're lightweight objects that can be copied to point to the same data.
There are the following Offset types to access the different IDL types:
Category | Offset type |
---|---|
User types | For example:
|
Arrays |
|
Sequences | |
Primitive types |
|
Offsets for user types are generated by rtiddsgen and provide methods to access the type's members by their names. Offsets for arrays and sequences provide methods to access each element.
Some offsets allow accessing the data through a pointer to the equivalent plain C++ type, which generally provides better performance. See rti::flat::plain_cast().
Functions that return an Offset may return a "null" Offset (one such that is_null() returns true
).
An Offset may be null if a member doesn't exist in the Sample. For example, if the member 'my_final' in MyFlatMutable doesn't exist (because it wasn't added while building the Sample, or because it wasn't received in the subscribing application), MyFlatMutableOffset::my_final() returns an null Offset. Note that a member in a final type (for example, MyFlatFinalOffset::my_complex()) always exists, except in the case of an error.
Other than that, any error condition will cause one of the following exceptions, not a null Offset:
flat_type_traits< OffsetType >::plain_type * rti::flat::plain_cast | ( | OffsetType & | offset | ) |
Casts into an equivalent plain C++ type.
Some FlatData types can be cast to their equivalent plain definition as a regular non-FlatData C++ type. This is a more efficient way to access the data. This function casts, if possible, the member pointed to by the offset argument to an equivalent plain C++ type. Any changes made through the plain type are reflected in the FlatData sample.
OffsetType | The Offset type |
offset.is_cpp_compatible() indicates if the member meets the requirements. If the type doesn't, this function throws dds::core::PreconditionNotMetError.
offset | The offset to the member to cast. |
offset
referred to, cast as a plain C++ type with the same definition. If offset
is an array or sequence member, the returned pointer represents a C++ array with the same number of elements.The following table summarizes the possible parameters to this function (assuming that they meet the previous requirements), and the return type in each case:
OffsetType | return type |
---|---|
Offset to a final struct, such as MyFlatFinalOffset | MyFlatFinalPlainHelper* (pointer to a single element). This is a type with the same IDL definition, but without @language_binding(FLAT_DATA) . |
Offset to an array of final structs, such as FinalArrayOffset<MyFlatFinalOffset, N> | MyFlatFinalPlainHelper* (array of N elements) |
Offset to a sequence of final structs, such as SequenceOffset<MyFlatFinalOffset> | MyFlatFinalPlainHelper* (array of offset.element_count() elements) |
Offset to an array of primitive types, such as PrimitiveArrayOffset<int32_t, N> | int32_t* (array of N elements) |
Offset to a sequence of primitive types, such as PrimitiveSequenceOffset<int32_t> | int32_t* (array of offset.element_count() elements) |
Due to the performance advantages that plain_cast
offers, it is recommended to define FlatData types in a way that their largest member(s) can be plain_cast
.
The following example shows how to use plain_cast
to cast a MyFlatFinalOffset into the type with the same IDL definition as MyFlatFinal, but without the @language_binding(FLAT_DATA)
annotation:
This example shows how to use plain_cast to efficiently build a sequence of final elements and a sequence of integers, both members of a mutable type:
const flat_type_traits< OffsetType >::plain_type * rti::flat::plain_cast | ( | const OffsetType & | offset | ) |
Const version of plain_cast.