RTI Connext Modern C++ API
Version 6.1.1
|
The generic definition of FlatData topic-types. More...
#include <FlatSample.hpp>
Inherits rti::flat::SampleBase.
Public Types | |
typedef OffsetType | Offset |
The related Offset type. More... | |
typedef OffsetType::ConstOffset | ConstOffset |
The related read-only Offset type. More... | |
Public Member Functions | |
Offset | root () |
Provides the Offset to the top-level type. More... | |
ConstOffset | root () const |
Provides the Offset to the top-level type. More... | |
Sample< OffsetType > * | clone () const |
Clones a Sample, creating an unmanaged Sample. More... | |
Static Public Member Functions | |
static Sample< OffsetType > * | create_data () |
Creates an unmanaged FlatData Sample. More... | |
static void | delete_data (rti::flat::Sample< OffsetType > *sample) |
Releases an unmanaged Sample. More... | |
The generic definition of FlatData topic-types.
OffsetType | The Offset to the beginning of the data Sample (the root), for example MyFlatFinalOffset, or MyFlatMutableOffset. |
For a FlatData IDL type, rtiddsgen generates an instantiation of this class, such as MyFlatFinal or MyFlatMutable. That's the topic-type used to declare a dds::topic::Topic and write or read FlatData samples.
A FlatData Sample owns an inline buffer that contains the serialized data. To access the Sample data members we use Offsets, iterators that point to the position of a member in the Sample buffer. The root() is the Offset to the top-level element (for example MyFlatMutableOffset). From there MyFlatMutableOffset's member functions provide access to its members.
The method to create a Sample varies depending on whether the type is final or mutable.
Samples of final FlatData types always have the same size, and can be obtained directly with dds::pub::DataWriter::get_loan().
Samples of mutable FlatData types need to be "built" using the Builder returned by rti::flat::build_data() (MyFlatMutableBuilder in this example). A Builder allows adding each member individually in any order, and sizing sequences as needed.
See Publishing FlatData for code snippets.
Samples created with dds::pub::DataWriter::get_loan() or rti::flat::build_data() are DataWriter-managed and do not need to be explicitly deleted. See dds::pub::DataWriter::get_loan() for an explanation of the lifecycle of DataWriter-managed samples.
Samples received with a dds::sub::DataReader can be examined by obtaining the root(), but cannot be modified. See Subscribing to FlatData.
FlatData samples are not value types. They don't provide copy constructors or assignment operators, because of their definition as an inline buffer that contains the serialized Sample at all times. A Sample can be cloned with the static function clone(). A cloned Sample is unmanaged and has to be deleted with the static function delete_data().
typedef OffsetType rti::flat::Sample< OffsetType >::Offset |
The related Offset type.
This is the template parameter, OffsetType
typedef OffsetType::ConstOffset rti::flat::Sample< OffsetType >::ConstOffset |
The related read-only Offset type.
For example, MyFlatMutableOffset::ConstOffset.
|
inline |
Provides the Offset to the top-level type.
This overload allows modifying the Sample.
Example:
|
inline |
Provides the Offset to the top-level type.
This overload doesn't allow modifying the Sample.
Example:
|
static |
Creates an unmanaged FlatData Sample.
If the topic-type is final, the returned Sample can be initialized by obtaining the root().
If the topic-type is mutable, the resulting Sample has no members, and root() returns a null Offset. The result of create_data() must be used to create a Builder. This is a rare use case, and rti::flat::build_data() should be used in most situations.
In all cases, the returned Sample must be explicitly deleted with delete_data().
|
inline |
Clones a Sample, creating an unmanaged Sample.
Creates a new Sample and copies the underlying serialized buffer.
delete_data() must be called to release the Sample.
|
inlinestatic |
Releases an unmanaged Sample.
Unmanaged samples are those created with create_data() or clone().
sample
cannot have been created with dds::pub::DataWriter::get_loan or rti::flat::build_data().sample
becomes invalid and shouldn't be used