LoanableSequence: public eprosima::fastdds::dds::LoanableTypedCollection<T>¶
A type-safe, ordered collection of elements that can receive the buffer from outside (loan).
For users who define data types in OMG IDL, this type corresponds to the IDL express sequence<T>.
For any user-data type Foo that an application defines for the purpose of data-distribution with Fast DDS, a ‘
using FooSeq = LoanableSequence<Foo>’ is generated. The sequence offers a subset of the methods defined by the standard OMG IDL to C++ mapping for sequences. We refer to an IDL ‘
The state of a sequence is described by the properties ‘maximum’, ‘length’ and ‘has_ownership’.
The ‘maximum’ represents the size of the underlying buffer; this is the maximum number of elements it can possibly hold. It is returned by the maximum() operation.
The ‘length’ represents the actual number of elements it currently holds. It is returned by the length() operation.
The ‘has_ownership’ flag represents whether the sequence owns the underlying buffer. It is returned by the has_ownership() operation. If the sequence does not own the underlying buffer, the underlying buffer is loaned from somewhere else. This flag influences the lifecycle of the sequence and what operations are allowed on it. The general guidelines are provided below and more details are described in detail as pre-conditions and post-conditions of each of the sequence’s operations:
If has_ownership == true, the sequence has ownership on the buffer. It is then responsible for destroying the buffer when the sequence is destroyed.
If has_ownership == false, the sequence does not have ownership on the buffer. This implies that the sequence is loaning the buffer. The sequence should not be destroyed until the loan is returned.
A sequence with a zero maximum always has has_ownership == true
LoanableSequence() = default¶
Creates the sequence with no data.
Creates the sequence with an initial number of allocated elements. When the input parameter is less than or equal to 0, the behavior is equivalent to the default constructor. Otherwise, the post-conditions below will apply.
Deallocate this sequence’s buffer.
LoanableSequence(const LoanableSequence &other)¶
Construct a sequence with the contents of another sequence.
This method performs a deep copy of the sequence received into this one. Allocations will happen when other.length() > 0
operator=(const LoanableSequence &other)¶
Copy the contents of another sequence into this one.
This method performs a deep copy of the sequence received into this one. If this sequence had a buffer loaned, it will behave as if unloan has been called. Allocations will happen when (a) has_ownership() == false and other.length() > 0 (b) has_ownership() == true and other.length() > maximum()