Fast DDS  Version 3.6.1.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
18
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 static_cast<void>(allowed_to_send);
82 }
83
89 void enable(
90 bool should_enable)
91 {
92 enabled = should_enable && remote_guid != c_Guid_Unknown;
93 }
94
98 void reset()
99 {
100 state.unicast.clear();
101 state.multicast.clear();
102 }
103
105 const LocatorList_t& unicast_locators,
106 const LocatorList_t& multicast_locators)
107 {
108 // Create an entry with space for all locators
109 LocatorSelectorEntry entry(unicast_locators.size(), multicast_locators.size());
110 // Add and select unicast locators
111 for (const Locator_t& locator : unicast_locators)
112 {
113 entry.state.unicast.push_back(entry.unicast.size());
114 entry.unicast.push_back(locator);
115 }
116 // Add and select multicast locators
117 for (const Locator_t& locator : multicast_locators)
118 {
119 entry.state.multicast.push_back(entry.multicast.size());
120 entry.multicast.push_back(locator);
121 }
122 // Return created entry
123 return entry;
124 }
125
127 const LocatorList_t& unicast_locators)
128 {
129 // Use previous overload with an empty multicast list
130 LocatorList_t empty_list {};
131 return create_fully_selected_entry(unicast_locators, empty_list);
132 }
133
145 bool allowed_to_send {true};
148};
149
150} // namespace rtps
151} // namespace fastdds
152} // namespace eprosima
153
154#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
155#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
Class Locator_t, uniquely identifies a communication channel for a particular transport.
Definition Locator.hpp:74
FASTDDS_EXPORTED_API size_t size() const
Return the number of locators.
Definition LocatorList.hpp:222
Contains the RTPS protocol implementation.
eprosima::fastdds::rtps::LocatorList LocatorList_t
Definition LocatorList.hpp:478
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
ResourceLimitedVector< Locator_t > unicast
List of unicast locators to send data to the remote entity.
Definition LocatorSelectorEntry.hpp:137
void enable(bool should_enable)
Set the enabled value.
Definition LocatorSelectorEntry.hpp:89
static LocatorSelectorEntry create_fully_selected_entry(const LocatorList_t &unicast_locators, const LocatorList_t &multicast_locators)
Definition LocatorSelectorEntry.hpp:104
LocatorSelectorEntry(size_t max_unicast_locators, size_t max_multicast_locators)
Construct a LocatorSelectorEntry.
Definition LocatorSelectorEntry.hpp:71
bool allowed_to_send
Indicates whether this entry is allowed to send data.
Definition LocatorSelectorEntry.hpp:145
bool enabled
Indicates whether this entry should be taken into consideration.
Definition LocatorSelectorEntry.hpp:143
static LocatorSelectorEntry create_fully_selected_entry(const LocatorList_t &unicast_locators)
Definition LocatorSelectorEntry.hpp:126
ResourceLimitedVector< Locator_t > multicast
List of multicast locators to send data to the remote entity.
Definition LocatorSelectorEntry.hpp:139
GUID_t remote_guid
GUID of the remote entity.
Definition LocatorSelectorEntry.hpp:135
bool transport_should_process
A temporary value for each transport to help optimizing some use cases.
Definition LocatorSelectorEntry.hpp:147
void reset()
Reset the selections.
Definition LocatorSelectorEntry.hpp:98
EntryState state
State of the entry.
Definition LocatorSelectorEntry.hpp:141