RTI Connext Traditional C++ API Version 7.2.0
|
Represents the Builder for an arbitrary user-defined mutable type. More...
#include <Builder.hpp>
Public Types | |
typedef MyFlatMutableOffset | Offset |
The related offset type. More... | |
Public Member Functions | |
MyFlatMutableBuilder () | |
Creates an invalid Builder. More... | |
MyFlatMutableBuilder (unsigned char *buffer, int32_t size, bool initialize_members=false) | |
Construct a Builder with an arbitrary buffer. More... | |
Offset | finish () |
Finishes building a member. More... | |
MyFlatMutable * | finish_sample () |
Finishes building a sample. More... | |
bool | add_my_primitive (int32_t value) |
Adds a primitive member. More... | |
bool | add_my_optional_primitive (int32_t value) |
Adds a primitive member. More... | |
rti::flat::PrimitiveArrayOffset< int32_t, 10 > | add_my_primitive_array () |
Adds a primitive array member. More... | |
rti::flat::PrimitiveSequenceBuilder< int32_t > | build_my_primitive_seq () |
Begins building a primitive-sequence member. More... | |
MyFlatFinalOffset | add_my_final () |
Adds a final complex member. More... | |
rti::flat::FinalAlignedArrayOffset< MyFlatFinalOffset, 10 > | add_my_final_array () |
Adds an array member of final complex elements. More... | |
rti::flat::FinalSequenceBuilder< MyFlatFinalOffset > | build_my_final_seq () |
Begins building a sequence member of final complex elements. More... | |
FlatMutableBarBuilder | build_my_mutable () |
Begins building a mutable complex member. More... | |
rti::flat::MutableArrayBuilder< FlatMutableBarBuilder, 10 > | build_my_mutable_array () |
Begins building an array member of mutable complex elements. More... | |
rti::flat::MutableSequenceBuilder< FlatMutableBarBuilder > | build_my_mutable_seq () |
Begins building a sequence member of mutable complex elements. More... | |
rti::flat::StringBuilder | build_my_string () |
Begins building a string member. More... | |
rti::flat::MutableSequenceBuilder< rti::flat::StringBuilder > | build_my_string_seq () |
Begins building a sequence member of string elements. 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::AbstractBuilder | |
virtual | ~AbstractBuilder () |
If this is a member Builder, it calls finish(). More... | |
Represents the Builder for an arbitrary user-defined mutable type.
This example type represents the Builder type that rtiddsgen would generate for MyFlatMutable and allows creating a sample or a member of that type.
The most common way to create a Builder is rti::flat::build_data(), which obtains a managed sample from a FooDataWriter as described in Publishing FlatData. It is also possible to create a Builder with an arbitrary buffer using the constructor that receives the buffer and its size.
When a Builder is created, the type is empty–it doesn't contain any members. The Builder provides functions to create each member. There are two kind of functions: add
functions and build
functions.
Fixed-size members are "added", and the corresponding function is called add_<member_name>
. "Add" functions directly place the member in the buffer, and return an Offset that allows setting its values.
By default, after calling add_<member_name>
the member values are uninitialized. This behavior can be changed by creating the writer with DDS_DataWriterResourceLimitsQosPolicy::initialize_writer_loaned_sample; this is however not recommended in general because of the performance impact for large types.
Variable-size members are "built", and the function is called build_<member_name>
. "Build" functions return another Builder to build the member.
While a member is being built, the parent Builder is a bound state, which prevents any changes to it until the member has been finished by calling member_builder.finish()
. In particular, the member Builder must be finished before adding or building any other member, or before finishing builder
.
The add/build
function for each member can be called one or zero times. That is, all members are optional, even those without the @optional
IDL annotation. However @key
member must be added or FooDataWriter::write will fail.
FlatData samples received by DDSDataReader will not contain the members that were not added/built–the corresponding member getters return a null Offset. A DDSDataReader for an equivalent non-FlatData (plain) definition of this type will assign default values to any non-optional members that were not present in the sample when written.
It is not permitted to add a member more than once, but builders don't enforce this. Trying to build/add a member more than once may cause the Builder to overflow (see Builder Error Management). If it doesn't, it may be possible to write and read the data samples, but the duplicate members will be ignored.
The related offset type.
|
inline |
Creates an invalid Builder.
build_<member>
function.
|
inline |
Construct a Builder with an arbitrary buffer.
buffer | The buffer that will be used to build the data sample |
size | The size of the buffer |
initialize_members | Whether fixed-size elements added to this Builder will be initialized to their default values or will be left uninitialized (more efficient). |
If the sample being built overflows the buffer size, the add/build operations will fail. See Builder Error Management.
Offset MyFlatMutableBuilder::finish | ( | ) |
Finishes building a member.
MyFlatMutable * MyFlatMutableBuilder::finish_sample | ( | ) |
Finishes building a sample.
This function completes and returns the sample built with this Builder.
bool MyFlatMutableBuilder::add_my_primitive | ( | int32_t | value | ) |
Adds a primitive member.
bool MyFlatMutableBuilder::add_my_optional_primitive | ( | int32_t | value | ) |
Adds a primitive member.
rti::flat::PrimitiveArrayOffset< int32_t, 10 > MyFlatMutableBuilder::add_my_primitive_array | ( | ) |
Adds a primitive array member.
rti::flat::PrimitiveSequenceBuilder< int32_t > MyFlatMutableBuilder::build_my_primitive_seq | ( | ) |
Begins building a primitive-sequence member.
MyFlatFinalOffset MyFlatMutableBuilder::add_my_final | ( | ) |
Adds a final complex member.
rti::flat::FinalAlignedArrayOffset< MyFlatFinalOffset, 10 > MyFlatMutableBuilder::add_my_final_array | ( | ) |
Adds an array member of final complex elements.
rti::flat::FinalSequenceBuilder< MyFlatFinalOffset > MyFlatMutableBuilder::build_my_final_seq | ( | ) |
Begins building a sequence member of final complex elements.
FlatMutableBarBuilder MyFlatMutableBuilder::build_my_mutable | ( | ) |
Begins building a mutable complex member.
FlatMutableBar represents another arbitrary mutable FlatData type.
rti::flat::MutableArrayBuilder< FlatMutableBarBuilder, 10 > MyFlatMutableBuilder::build_my_mutable_array | ( | ) |
Begins building an array member of mutable complex elements.
rti::flat::MutableSequenceBuilder< FlatMutableBarBuilder > MyFlatMutableBuilder::build_my_mutable_seq | ( | ) |
Begins building a sequence member of mutable complex elements.
rti::flat::StringBuilder MyFlatMutableBuilder::build_my_string | ( | ) |
Begins building a string member.
rti::flat::MutableSequenceBuilder< rti::flat::StringBuilder > MyFlatMutableBuilder::build_my_string_seq | ( | ) |
Begins building a sequence member of string elements.