15#ifndef _TYPES_DYNAMIC_LOANABLE_SEQUENCE_HPP_
16#define _TYPES_DYNAMIC_LOANABLE_SEQUENCE_HPP_
21#include <fastdds/dds/core/LoanableSequence.hpp>
22#include <fastdds/dds/log/Log.hpp>
23#include <fastrtps/types/DynamicData.h>
24#include <fastrtps/types/DynamicPubSubType.h>
25#include <fastrtps/types/DynamicTypePtr.h>
39template<
typename _NonConstEnabler>
40class LoanableSequence<fastrtps::types::DynamicData, _NonConstEnabler>
41 :
public LoanableTypedCollection<fastrtps::types::DynamicData, _NonConstEnabler>
58 : dynamic_type_support_(new fastrtps::types::DynamicPubSubType(dyn_type))
83 if (elements_ && !has_ownership_)
85 EPROSIMA_LOG_WARNING(SUBSCRIBER,
"Sequence destroyed with active loan");
94 const LoanableSequence&) =
delete;
97 LoanableSequence& operator =(
98 const LoanableSequence&) =
delete;
102 LoanableSequence&&) =
default;
105 LoanableSequence& operator =(
106 LoanableSequence&&) =
default;
110 using LoanableCollection::maximum_;
111 using LoanableCollection::length_;
112 using LoanableCollection::elements_;
113 using LoanableCollection::has_ownership_;
125 assert(has_ownership_);
128 data_.reserve(maximum);
129 data_.resize(maximum);
130 elements_ =
reinterpret_cast<element_type*
>(data_.data());
133 while (maximum_ < maximum)
144 if (has_ownership_ && elements_)
146 for (size_type n = 0; n < maximum_; ++n)
149 dynamic_type_support_->deleteData(elem);
151 std::vector<fastrtps::types::DynamicData*>().swap(data_);
157 has_ownership_ =
true;
161 std::vector<fastrtps::types::DynamicData*> data_;
164 std::unique_ptr<fastrtps::types::DynamicPubSubType> dynamic_type_support_;
LoanableSequence(fastrtps::types::DynamicType_ptr dyn_type)
Construct a LoanableSequence with a specified dynamic type.
Definition DynamicLoanableSequence.hpp:56
LoanableSequence(LoanableSequence &&)=default
Move constructor for LoanableSequence.
~LoanableSequence()
Destructor for LoanableSequence.
Definition DynamicLoanableSequence.hpp:81
LoanableCollection::element_type element_type
Type for the elements in the sequence.
Definition DynamicLoanableSequence.hpp:49
LoanableSequence(size_type max)
Construct a LoanableSequence with a specified maximum size.
Definition DynamicLoanableSequence.hpp:67
LoanableCollection::size_type size_type
Type for the size of the sequence.
Definition DynamicLoanableSequence.hpp:46
LoanableSequence(const LoanableSequence &)=delete
Deleted copy constructor for LoanableSequence.
Definition DynamicData.h:44
Definition DynamicTypePtr.h:27
LoanableSequence< fastrtps::types::DynamicData, std::true_type > DynamicLoanableSequence
Alias for LoanableSequence with DynamicData and true_type.
Definition DynamicLoanableSequence.hpp:168
eProsima namespace.
Definition LibrarySettingsAttributes.h:23