RTI Connext .Net APIs  Version 5.2.0
 All Classes Namespaces Functions Variables Enumerations Properties Groups Pages
DDS::LoanableSequence< E > Class Template Referenceabstract

A sequence implementation used internally by the middleware to efficiently manage memory during DDS::TypedDataReader::read and DDS::TypedDataReader::take operations. More...

#include <managed_sequence.h>

Inheritance diagram for DDS::LoanableSequence< E >:
DDS::Sequence< E > DDS::SampleInfoSeq FooSeq

Public Member Functions

virtual E get_at (System::Int32 i) overridesealed
 Get the i-th element for a const sequence.
 
virtual System::Boolean copy_from_no_alloc (Sequence< E >^src) overridesealed
 Copy elements from another sequence, only if the destination sequence has enough capacity.
 
virtual void unloan () overridesealed
 Return the loaned buffer in the sequence and set the maximum to 0.
 
- Public Member Functions inherited from DDS::Sequence< E >
System::Boolean ensure_length (System::Int32 length, System::Int32 max)
 Set the sequence to the desired length, and resize the sequence if necessary.
 
virtual void set_at (System::Int32 i, Eval)
 Set the i-th element of the sequence.
 
void loan (array< E >^buffer, System::Int32 new_length)
 Loan a contiguous buffer to this sequence.
 
void from_array (array< E >^arr)
 Copy elements from an array of elements, resizing the sequence if necessary. The original contents of the sequence (if any) are replaced.
 
void to_array (array< E >^arr)
 Copy elements to an array of elements. The original contents of the array (if any) are replaced.
 
System::Boolean copy_from (Sequence< E >^src_seq)
 Copy elements from another sequence, resizing the sequence if necessary.
 

Additional Inherited Members

- Properties inherited from DDS::Sequence< E >
System::Int32 length [get, set]
 The logical length of this sequence.
 
virtual System::Int32 maximum [get, set]
 The current maximum number of elements that can be stored in this sequence.
 
array< E >^ buffer [get]
 Return the contiguous buffer of the sequence.
 
System::Boolean has_ownership [get]
 Return the value of the owned flag.
 

Detailed Description

template<typename E>
class DDS::LoanableSequence< E >

A sequence implementation used internally by the middleware to efficiently manage memory during DDS::TypedDataReader::read and DDS::TypedDataReader::take operations.

Applications are not expected to use this type directly.

Member Function Documentation

template<typename E>
virtual E DDS::LoanableSequence< E >::get_at ( System::Int32  i)
overridesealedvirtual

Get the i-th element for a const sequence.

Parameters
iindex of element to access, must be >= 0 and less than DDS::Sequence::length
Returns
the i-th element

Reimplemented from DDS::Sequence< E >.

template<typename E>
virtual System::Boolean DDS::LoanableSequence< E >::copy_from_no_alloc ( Sequence< E >^  src_seq)
overridesealedvirtual

Copy elements from another sequence, only if the destination sequence has enough capacity.

Fill the elements in this sequence by copying the corresponding elements in src_seq. The original contents in this sequence are replaced via the element assignment operation (Foo_copy() function). By default, elements are discarded; 'delete' is not invoked on the discarded elements.

Precondition
this::maximum >= src_seq::length
this::owned == true
Postcondition
this::length == src_seq::length
this[i] == src_seq[i] for 0 <= i < target_seq::length
this::owned == true
Parameters
src_seq<<in>> the sequence from which to copy
Returns
true if the sequence was successfully copied; false otherwise.
Note
If the pre-conditions are not met, the operator will print a message to stdout and leave this sequence unchanged.
See Also
DDS::Sequence::copy_from_no_alloc(DDS::Sequence<T>^)

Reimplemented from DDS::Sequence< E >.

template<typename E>
virtual void DDS::LoanableSequence< E >::unloan ( )
overridesealedvirtual

Return the loaned buffer in the sequence and set the maximum to 0.

This method affects only the state of this sequence; it does not change the contents of the buffer in any way.

Only the user who originally loaned a buffer should return that loan, as the user may have dependencies on that memory known only to them. Unloaning someone else's buffer may cause unspecified problems. For example, suppose a sequence is loaning memory from a custom memory pool. A user of the sequence likely has no way to release the memory back into the pool, so unloaning the sequence buffer would result in a resource leak. If the user were to then re-loan a different buffer, the original creator of the sequence would have no way to discover, when freeing the sequence, that the loan no longer referred to its own memory and would thus not free the user's memory properly, exacerbating the situation and leading to undefined behavior.

Precondition
owned == false
Postcondition
owned == true
maximum == 0
Returns
true if the preconditions were met. Otherwise false. The function only fails if the pre-conditions are not met, in which case it leaves the sequence unmodified.
See Also
DDS::Sequence<T>::loan(array<T>^, System::Int32), ::DDS::Sequence::loan_discontiguous, DDS::Sequence::maximum

Reimplemented from DDS::Sequence< E >.


RTI Connext .Net APIs Version 5.2.0 Copyright © Sun Jun 21 2015 Real-Time Innovations, Inc