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

Builds a sequence member of fixed-size elements. More...

#include <SequenceBuilders.hpp>

Inheritance diagram for rti::flat::FinalSequenceBuilder< ElementOffset >:
rti::flat::AbstractSequenceBuilder< detail::DHeaderGenerator > rti::flat::AbstractListBuilder< detail::DHeaderGenerator > rti::flat::AbstractBuilder

Public Member Functions

ElementOffset add_next ()
 Adds the next element. More...
FinalSequenceBuilderadd_n (unsigned int count)
 Adds a number of elements at once. More...
Offset finish ()
 Finishes building the sequence. More...
- Public Member Functions inherited from rti::flat::AbstractSequenceBuilder< detail::DHeaderGenerator >
unsigned int element_count () const
 Returns the current number of elements that have been added. More...
- Public Member Functions inherited from rti::flat::AbstractBuilder
void discard ()
 Discards a member in process of being built. More...
bool is_nested () const
 Returns whether this is a member Builder. More...
bool is_valid () const
 Whether this Builder is valid. More...
rti::xcdr::length_t capacity () const
 Returns the total capacity in bytes. More...
bool check_failure ()
 Checks if the previous operation failed and resets the failure flag. More...

Additional Inherited Members

- Protected Member Functions inherited from rti::flat::AbstractListBuilder< detail::DHeaderGenerator >
unsigned int element_count () const
 Returns the current number of elements that have been added. More...
- Protected Member Functions inherited from rti::flat::AbstractBuilder
virtual ~AbstractBuilder ()
 If this is a member Builder, it calls finish(). More...

Detailed Description

template<typename ElementOffset>
class rti::flat::FinalSequenceBuilder< ElementOffset >

Builds a sequence member of fixed-size elements.

Template Parameters
ElementOffsetThe Offset type for the elements of the sequence

To add an element, call add_next() and use the ElementOffset it returns to initialize the element's values. An empty sequence can be built by calling finish() without any call to add_next().

This class doesn't enforce the sequence bound set in IDL.

The following example uses a FinalSequenceBuilder to initialize a sequence member of MyFlatMutableBuilder with two elements:

auto seq_builder = builder.build_my_final_seq();
MyFlatFinalOffset element = seq_builder.add_next();
// ... continue initializing the first element
element = seq_builder.add_next();
// ... continue initializing the second element
Represents the Offset to an arbitrary user-defined FlatData final IDL struct.
Definition: Offset.hpp:125
int32_t my_primitive() const
Retrieves the value for a primitive member.
Represents the Builder for an arbitrary user-defined mutable type.
Definition: Builder.hpp:206
rti::flat::FinalSequenceBuilder< MyFlatFinalOffset > build_my_final_seq()
Begins building a sequence 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

If the element type meets certain requirements, rti::flat::plain_cast() provides a more efficient way to initialize a sequence of final elements.

Member Function Documentation

◆ add_next()

template<typename ElementOffset >
ElementOffset rti::flat::FinalSequenceBuilder< ElementOffset >::add_next ( )

Adds the next element.

The Offset that can be used to set the element values

◆ add_n()

template<typename ElementOffset >
FinalSequenceBuilder & rti::flat::FinalSequenceBuilder< ElementOffset >::add_n ( unsigned int  count)

Adds a number of elements at once.

This is an alternative to add_next().

To initialize the elements, call finish() and use the Offset it returns to access the elements.

◆ finish()

template<typename ElementOffset >
Offset rti::flat::FinalSequenceBuilder< ElementOffset >::finish ( )

Finishes building the sequence.

An Offset to the member that has been built.
See also