RTI Connext Modern C++ API  Version 6.1.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 rti::flat::AbstractListBuilder 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::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...
 

Additional Inherited Members

- Protected Member Functions inherited from rti::flat::AbstractListBuilder
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();
element.my_primitive(1);
// ... continue initializing the first element
element = seq_builder.add_next();
element.my_primitive(2);
// ... continue initializing the second element
seq_builder.finish();

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 ( )
inline

Adds the next element.

Returns
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)
inline

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 ( )
inline

Finishes building the sequence.

Returns
An Offset to the member that has been built.
See also
discard()