Fast DDS  Version 3.0.0
Fast DDS
Loading...
Searching...
No Matches
LocatorSelectorEntry.hpp
1// Copyright 2019 Proyectos y Sistemas de Mantenimiento SL (eProsima).
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
19#ifndef FASTDDS_RTPS_COMMON__LOCATORSELECTORENTRY_HPP
20#define FASTDDS_RTPS_COMMON__LOCATORSELECTORENTRY_HPP
21
22#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
23
24#include <fastdds/rtps/common/Guid.hpp>
25#include <fastdds/rtps/common/Locator.hpp>
26#include <fastdds/rtps/common/LocatorList.hpp>
27#include <fastdds/utils/collections/ResourceLimitedVector.hpp>
28
29namespace eprosima {
30namespace fastdds {
31namespace rtps {
32
39{
44 {
52 size_t max_unicast_locators,
53 size_t max_multicast_locators)
54 : unicast(ResourceLimitedContainerConfig::fixed_size_configuration(max_unicast_locators))
55 , multicast(ResourceLimitedContainerConfig::fixed_size_configuration(max_multicast_locators))
56 {
57 }
58
63 };
64
72 size_t max_unicast_locators,
73 size_t max_multicast_locators)
75 , unicast(ResourceLimitedContainerConfig::fixed_size_configuration(max_unicast_locators))
76 , multicast(ResourceLimitedContainerConfig::fixed_size_configuration(max_multicast_locators))
77 , state(max_unicast_locators, max_multicast_locators)
78 , enabled(false)
80 {
81 }
82
88 void enable(
89 bool should_enable)
90 {
91 enabled = should_enable && remote_guid != c_Guid_Unknown;
92 }
93
97 void reset()
98 {
101 }
102
104 const LocatorList_t& unicast_locators,
105 const LocatorList_t& multicast_locators)
106 {
107 // Create an entry with space for all locators
108 LocatorSelectorEntry entry(unicast_locators.size(), multicast_locators.size());
109 // Add and select unicast locators
110 for (const Locator_t& locator : unicast_locators)
111 {
112 entry.state.unicast.push_back(entry.unicast.size());
113 entry.unicast.push_back(locator);
114 }
115 // Add and select multicast locators
116 for (const Locator_t& locator : multicast_locators)
117 {
118 entry.state.multicast.push_back(entry.multicast.size());
119 entry.multicast.push_back(locator);
120 }
121 // Return created entry
122 return entry;
123 }
124
126 const LocatorList_t& unicast_locators)
127 {
128 // Use previous overload with an empty multicast list
129 LocatorList_t empty_list {};
130 return create_fully_selected_entry(unicast_locators, empty_list);
131 }
132
145};
146
147} // namespace rtps
148} // namespace fastdds
149} // namespace eprosima
150
151#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
152#endif // FASTDDS_RTPS_COMMON__LOCATORSELECTORENTRY_HPP
Resource limited wrapper of std::vector.
Definition ResourceLimitedVector.hpp:59
pointer push_back(const value_type &val)
Add element at the end.
Definition ResourceLimitedVector.hpp:174
void clear()
Definition ResourceLimitedVector.hpp:494
Class Locator_t, uniquely identifies a communication channel for a particular transport.
Definition Locator.hpp:71
Class LocatorList, a Locator vector that doesn't allow duplicates.
Definition LocatorList.hpp:97
FASTDDS_EXPORTED_API size_t size() const
Return the number of locators.
Definition LocatorList.hpp:222
const GUID_t c_Guid_Unknown
Definition Guid.hpp:213
eProsima namespace.
Specifies the configuration of a resource limited collection.
Definition ResourceLimitedContainerConfig.hpp:36
Structure GUID_t, entity identifier, unique in DDS-RTPS Domain.
Definition Guid.hpp:40
Holds the selection state of the locators held by a LocatorSelectorEntry.
Definition LocatorSelectorEntry.hpp:44
ResourceLimitedVector< size_t > unicast
Unicast locators selection state.
Definition LocatorSelectorEntry.hpp:60
ResourceLimitedVector< size_t > multicast
Multicast locators selection state.
Definition LocatorSelectorEntry.hpp:62
EntryState(size_t max_unicast_locators, size_t max_multicast_locators)
Construct an EntryState object.
Definition LocatorSelectorEntry.hpp:51
An entry for the LocatorSelector.
Definition LocatorSelectorEntry.hpp:39
ResourceLimitedVector< Locator_t > unicast
List of unicast locators to send data to the remote entity.
Definition LocatorSelectorEntry.hpp:136
void enable(bool should_enable)
Set the enabled value.
Definition LocatorSelectorEntry.hpp:88
static LocatorSelectorEntry create_fully_selected_entry(const LocatorList_t &unicast_locators, const LocatorList_t &multicast_locators)
Definition LocatorSelectorEntry.hpp:103
LocatorSelectorEntry(size_t max_unicast_locators, size_t max_multicast_locators)
Construct a LocatorSelectorEntry.
Definition LocatorSelectorEntry.hpp:71
bool enabled
Indicates whether this entry should be taken into consideration.
Definition LocatorSelectorEntry.hpp:142
static LocatorSelectorEntry create_fully_selected_entry(const LocatorList_t &unicast_locators)
Definition LocatorSelectorEntry.hpp:125
ResourceLimitedVector< Locator_t > multicast
List of multicast locators to send data to the remote entity.
Definition LocatorSelectorEntry.hpp:138
GUID_t remote_guid
GUID of the remote entity.
Definition LocatorSelectorEntry.hpp:134
bool transport_should_process
A temporary value for each transport to help optimizing some use cases.
Definition LocatorSelectorEntry.hpp:144
void reset()
Reset the selections.
Definition LocatorSelectorEntry.hpp:97
EntryState state
State of the entry.
Definition LocatorSelectorEntry.hpp:140