| Fast DDS Version 3.3.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
29 namespace eprosima {
30 namespace fastdds {
31 namespace rtps {
32
38 struct LocatorSelectorEntry
39{
43 struct EntryState
44 {
51 EntryState(
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
60 ResourceLimitedVector<size_t> unicast;
62 ResourceLimitedVector<size_t> multicast;
63 };
64
71 LocatorSelectorEntry(
72 size_t max_unicast_locators,
73 size_t max_multicast_locators)
74 : remote_guid(c_Guid_Unknown)
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)
79 , transport_should_process(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 {
99 state.unicast.clear();
100 state.multicast.clear();
101 }
102
103 static LocatorSelectorEntry create_fully_selected_entry(
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
125 static LocatorSelectorEntry create_fully_selected_entry(
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
134 GUID_t remote_guid;
136 ResourceLimitedVector<Locator_t> unicast;
138 ResourceLimitedVector<Locator_t> multicast;
140 EntryState state;
142 bool enabled;
144 bool transport_should_process;
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
eprosima::fastdds::ResourceLimitedVector
Resource limited wrapper of std::vector.
Definition ResourceLimitedVector.hpp:59
eprosima::fastdds::ResourceLimitedVector::push_back
pointer push_back(const value_type &val)
Add element at the end.
Definition ResourceLimitedVector.hpp:174
eprosima::fastdds::rtps::Locator_t
Class Locator_t, uniquely identifies a communication channel for a particular transport.
Definition Locator.hpp:71
eprosima::fastdds::rtps::LocatorList::size
FASTDDS_EXPORTED_API size_t size() const
Return the number of locators.
Definition LocatorList.hpp:222
eprosima::fastdds::rtps
Contains the RTPS protocol implementation.
eprosima::fastdds::rtps::LocatorList_t
eprosima::fastdds::rtps::LocatorList LocatorList_t
Definition LocatorList.hpp:478
eprosima::fastdds::rtps::c_Guid_Unknown
const GUID_t c_Guid_Unknown
Definition Guid.hpp:213
eprosima::fastdds
eprosima
eProsima namespace.
eprosima::fastdds::ResourceLimitedContainerConfig
Specifies the configuration of a resource limited collection.
Definition ResourceLimitedContainerConfig.hpp:36
eprosima::fastdds::rtps::GUID_t
Structure GUID_t, entity identifier, unique in DDS-RTPS Domain.
Definition Guid.hpp:40
eprosima::fastdds::rtps::LocatorSelectorEntry::EntryState
Holds the selection state of the locators held by a LocatorSelectorEntry.
Definition LocatorSelectorEntry.hpp:44
eprosima::fastdds::rtps::LocatorSelectorEntry::EntryState::unicast
ResourceLimitedVector< size_t > unicast
Unicast locators selection state.
Definition LocatorSelectorEntry.hpp:60
eprosima::fastdds::rtps::LocatorSelectorEntry::EntryState::multicast
ResourceLimitedVector< size_t > multicast
Multicast locators selection state.
Definition LocatorSelectorEntry.hpp:62
eprosima::fastdds::rtps::LocatorSelectorEntry::EntryState::EntryState
EntryState(size_t max_unicast_locators, size_t max_multicast_locators)
Construct an EntryState object.
Definition LocatorSelectorEntry.hpp:51
eprosima::fastdds::rtps::LocatorSelectorEntry::unicast
ResourceLimitedVector< Locator_t > unicast
List of unicast locators to send data to the remote entity.
Definition LocatorSelectorEntry.hpp:136
eprosima::fastdds::rtps::LocatorSelectorEntry::enable
void enable(bool should_enable)
Set the enabled value.
Definition LocatorSelectorEntry.hpp:88
eprosima::fastdds::rtps::LocatorSelectorEntry::create_fully_selected_entry
static LocatorSelectorEntry create_fully_selected_entry(const LocatorList_t &unicast_locators, const LocatorList_t &multicast_locators)
Definition LocatorSelectorEntry.hpp:103
eprosima::fastdds::rtps::LocatorSelectorEntry::LocatorSelectorEntry
LocatorSelectorEntry(size_t max_unicast_locators, size_t max_multicast_locators)
Construct a LocatorSelectorEntry.
Definition LocatorSelectorEntry.hpp:71
eprosima::fastdds::rtps::LocatorSelectorEntry::enabled
bool enabled
Indicates whether this entry should be taken into consideration.
Definition LocatorSelectorEntry.hpp:142
eprosima::fastdds::rtps::LocatorSelectorEntry::create_fully_selected_entry
static LocatorSelectorEntry create_fully_selected_entry(const LocatorList_t &unicast_locators)
Definition LocatorSelectorEntry.hpp:125
eprosima::fastdds::rtps::LocatorSelectorEntry::multicast
ResourceLimitedVector< Locator_t > multicast
List of multicast locators to send data to the remote entity.
Definition LocatorSelectorEntry.hpp:138
eprosima::fastdds::rtps::LocatorSelectorEntry::remote_guid
GUID_t remote_guid
GUID of the remote entity.
Definition LocatorSelectorEntry.hpp:134
eprosima::fastdds::rtps::LocatorSelectorEntry::transport_should_process
bool transport_should_process
A temporary value for each transport to help optimizing some use cases.
Definition LocatorSelectorEntry.hpp:144
eprosima::fastdds::rtps::LocatorSelectorEntry::reset
void reset()
Reset the selections.
Definition LocatorSelectorEntry.hpp:97
eprosima::fastdds::rtps::LocatorSelectorEntry::state
EntryState state
State of the entry.
Definition LocatorSelectorEntry.hpp:140