RTI Connext Modern C++ API  Version 6.0.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
rti::flat::MutableArrayBuilder< ElementBuilder, N > Class Template Reference

Builds an array member of variable-size elements. More...

#include <SequenceBuilders.hpp>

Inheritance diagram for rti::flat::MutableArrayBuilder< ElementBuilder, N >:
rti::flat::AbstractListBuilder rti::flat::AbstractBuilder

Public Types

typedef MutableArrayOffset
< typename
ElementBuilder::Offset, N > 
Offset
 The related Offset type.
 

Public Member Functions

ElementBuilder build_next ()
 Begins building the next element.
 
Offset finish ()
 Finishes building the array.
 

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.
 

Detailed Description

template<typename ElementBuilder, unsigned int N>
class rti::flat::MutableArrayBuilder< ElementBuilder, N >

Builds an array member of variable-size elements.

Template Parameters
ElementBuilderThe Builder type for the elements of the array
NThe array bound; the exact number of elements this array builder must build. For multidimensional arrays, N is the product of each dimension bound.

Each element of this array needs to be built using the ElementBuilder returned by build_next(). N elements exactly must be built. Unlike a sequence Builder, it is not possible to finish an array with less than N elements.

This example shows how to use a MutableArrayBuilder to build an array member of MyFlatMutableBuilder:

auto array_builder = builder.build_my_mutable_array();
for (int i = 0; i < 10; i++) {
FlatMutableBarBuilder element_builder = array_builder.build_next();
// ... build element
element_builder.finish();
}
array_builder.finish();

Note that Builder types are not necessary for arrays of fixed-size elements, since they are added at once (see MyFlatMutableBuilder::add_my_final_array()).

Member Typedef Documentation

template<typename ElementBuilder , unsigned int N>
typedef MutableArrayOffset<typename ElementBuilder::Offset, N> rti::flat::MutableArrayBuilder< ElementBuilder, N >::Offset

The related Offset type.

Member Function Documentation

template<typename ElementBuilder , unsigned int N>
ElementBuilder rti::flat::MutableArrayBuilder< ElementBuilder, N >::build_next ( )
inline

Begins building the next element.

Before calling build_next() to create a new element, the element Builder returned by a previous call to build_next must have been finished.

template<typename ElementBuilder , unsigned int N>
Offset rti::flat::MutableArrayBuilder< ElementBuilder, N >::finish ( )
inline

Finishes building the array.

Precondition
build_next() must have been succesfully called N times exactly.
Returns
The Offset to the member that has been built.
See Also
discard()

RTI Connext Modern C++ API Version 6.0.0 Copyright © Sun Mar 3 2019 Real-Time Innovations, Inc