RTI Connext Traditional C++ API  Version 6.0.0
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
rti::flat::AbstractBuilder Class Reference

Base class of all Builders. More...

#include <Builder.hpp>

Inheritance diagram for rti::flat::AbstractBuilder:
rti::flat::AbstractListBuilder rti::flat::AggregationBuilder rti::flat::AbstractSequenceBuilder rti::flat::MutableArrayBuilder< ElementBuilder, N > MyFlatMutableBuilder rti::flat::UnionBuilder< Discriminator > rti::flat::UnionBuilder< int32_t > rti::flat::PrimitiveSequenceBuilder< char > rti::flat::FinalSequenceBuilder< ElementOffset > rti::flat::MutableSequenceBuilder< ElementBuilder > rti::flat::PrimitiveSequenceBuilder< T > MyFlatUnionBuilder rti::flat::StringBuilder

Public Member Functions

void discard ()
 Discards a member in process of being built.
 
bool is_nested () const
 Returns whether this is a member Builder.
 
bool is_valid () const
 Whether this Builder is valid.
 
rti::xcdr::length_t capacity () const
 Returns the total capacity in bytes.
 
bool check_failure ()
 Checks if the previous operation failed and resets the failure flag.
 

Protected Member Functions

virtual ~AbstractBuilder ()
 If this is a member Builder, it calls finish().
 

Detailed Description

Base class of all Builders.

Constructor & Destructor Documentation

virtual rti::flat::AbstractBuilder::~AbstractBuilder ( )
inlineprotectedvirtual

If this is a member Builder, it calls finish().

If this Builder is building a member (that is, is_nested() is true), and the object goes out of scope before finish() has been called, its destructor calls finish(). Note, however, that it won't report any error.

If this Builder is building a sample (!is_nested()), its destructor doesn't do anything.

Member Function Documentation

void rti::flat::AbstractBuilder::discard ( )
inline

Discards a member in process of being built.

This function ends the creation of a member, returning the Builder of the type that contains the member to its previous state, as if this member had never been built.

Precondition
This object must be a member Builder, not a sample Builder.

This method is useful when during the building of a member an error occurs and the application wants to roll back, instead of finishing an incomplete member.

bool rti::flat::AbstractBuilder::is_nested ( ) const
inline

Returns whether this is a member Builder.

A member Builder is a Builder that has been created by calling a "build_<member>" function on another Builder (for example, MyFlatMutableBuilder::build_my_mutable()).

Returns
True if this is a member Builder, or false if this is a sample Builder.
bool rti::flat::AbstractBuilder::is_valid ( ) const
inline

Whether this Builder is valid.

A Builder is not valid when it is default-constructed, or after any of these functions is called: finish(), finish_sample(), discard().

Since the Traditional C++ API doesn't use exceptions, certain function failures due to the Builder running out resources are also reported by invalidating the Builder.

rti::xcdr::length_t rti::flat::AbstractBuilder::capacity ( ) const
inline

Returns the total capacity in bytes.

The capacity is the total number of bytes this Builder can contain. For a sample Builder (that is, one such that is_nested() returns false), rti::flat::build_data reserves enough bytes to accommodate any sample of a given type.

bool rti::flat::AbstractBuilder::check_failure ( )
inline

Checks if the previous operation failed and resets the failure flag.

This function must be called after each Builder operation to check if it succeeded. Note that after calling check_failure() the error flag is reset, so a subsequent call will always return false.

Returns
True if there was a failure in the previous operation, false if there was no failure since the last call to check_failure.

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