/src/Fast-DDS/include/fastdds/rtps/builtin/BuiltinProtocols.h
Line | Count | Source (jump to first uncovered line) |
1 | | // Copyright 2016 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 | | |
15 | | /** |
16 | | * @file BuiltinProtocols.h |
17 | | * |
18 | | */ |
19 | | |
20 | | #ifndef _FASTDDS_RTPS_BUILTINPROTOCOLS_H_ |
21 | | #define _FASTDDS_RTPS_BUILTINPROTOCOLS_H_ |
22 | | #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC |
23 | | |
24 | | #include <list> |
25 | | |
26 | | #include <fastdds/rtps/attributes/RTPSParticipantAttributes.h> |
27 | | #include <fastdds/rtps/builtin/data/ContentFilterProperty.hpp> |
28 | | #include <fastdds/rtps/network/NetworkFactory.h> |
29 | | |
30 | | #include <fastrtps/utils/shared_mutex.hpp> |
31 | | |
32 | | namespace eprosima { |
33 | | |
34 | | namespace fastdds { |
35 | | namespace dds { |
36 | | namespace builtin { |
37 | | |
38 | | class TypeLookupManager; |
39 | | |
40 | | } // namespace builtin |
41 | | |
42 | | class ReaderQos; |
43 | | class WriterQos; |
44 | | } // namespace dds |
45 | | } // namespace fastdds |
46 | | |
47 | | namespace fastrtps { |
48 | | |
49 | | class TopicAttributes; |
50 | | |
51 | | namespace rtps { |
52 | | |
53 | | class PDP; |
54 | | class WLP; |
55 | | class RTPSParticipantImpl; |
56 | | class RTPSWriter; |
57 | | class RTPSReader; |
58 | | |
59 | | /** |
60 | | * Class BuiltinProtocols that contains builtin endpoints implementing the discovery and liveliness protocols. |
61 | | * *@ingroup BUILTIN_MODULE |
62 | | */ |
63 | | class BuiltinProtocols |
64 | | { |
65 | | friend class RTPSParticipantImpl; |
66 | | |
67 | | private: |
68 | | |
69 | | BuiltinProtocols(); |
70 | | virtual ~BuiltinProtocols(); |
71 | | |
72 | | /* |
73 | | * Mutex to protect the m_DiscoveryServers collection. Element access is not protected by this mutex, the PDP mutex |
74 | | * needs to be used when querying or modifying mutable members of the collection. |
75 | | */ |
76 | | mutable eprosima::shared_mutex discovery_mutex_; |
77 | | |
78 | | public: |
79 | | |
80 | | /** |
81 | | * Initialize the builtin protocols. |
82 | | * @param attributes Discovery configuration attributes |
83 | | * @param p_part Pointer to the Participant implementation |
84 | | * @return True if correct. |
85 | | */ |
86 | | bool initBuiltinProtocols( |
87 | | RTPSParticipantImpl* p_part, |
88 | | BuiltinAttributes& attributes); |
89 | | |
90 | | /** |
91 | | * Enable the builtin protocols |
92 | | */ |
93 | | void enable(); |
94 | | |
95 | | /** |
96 | | * Update the metatraffic locatorlist after it was created. Because when you create |
97 | | * the EDP readers you are not sure the selected endpoints can be used. |
98 | | * @param loclist LocatorList to update |
99 | | * @return True on success |
100 | | */ |
101 | | bool updateMetatrafficLocators( |
102 | | LocatorList_t& loclist); |
103 | | |
104 | | /** |
105 | | * Traverses the list of discover servers translating from remote to local locators |
106 | | * if possible |
107 | | * @param nf NetworkFactory used to make the translation |
108 | | */ |
109 | | void transform_server_remote_locators( |
110 | | NetworkFactory& nf); |
111 | | |
112 | | //!BuiltinAttributes of the builtin protocols. |
113 | | BuiltinAttributes m_att; |
114 | | //!Pointer to the RTPSParticipantImpl. |
115 | | RTPSParticipantImpl* mp_participantImpl; |
116 | | //!Pointer to the PDPSimple. |
117 | | PDP* mp_PDP; |
118 | | //!Pointer to the WLP |
119 | | WLP* mp_WLP; |
120 | | //!Pointer to the TypeLookupManager |
121 | | fastdds::dds::builtin::TypeLookupManager* tlm_; |
122 | | //!Locator list for metatraffic |
123 | | LocatorList_t m_metatrafficMulticastLocatorList; |
124 | | //!Locator List for metatraffic unicast |
125 | | LocatorList_t m_metatrafficUnicastLocatorList; |
126 | | //! Initial peers |
127 | | LocatorList_t m_initialPeersList; |
128 | | //! Known discovery and backup server container |
129 | | std::list<eprosima::fastdds::rtps::RemoteServerAttributes> m_DiscoveryServers; |
130 | | |
131 | | /** |
132 | | * Add a local Writer to the BuiltinProtocols. |
133 | | * @param w Pointer to the RTPSWriter |
134 | | * @param topicAtt Attributes of the associated topic |
135 | | * @param wqos QoS policies dictated by the publisher |
136 | | * @return True if correct. |
137 | | */ |
138 | | bool addLocalWriter( |
139 | | RTPSWriter* w, |
140 | | const TopicAttributes& topicAtt, |
141 | | const fastdds::dds::WriterQos& wqos); |
142 | | /** |
143 | | * Add a local Reader to the BuiltinProtocols. |
144 | | * @param R Pointer to the RTPSReader. |
145 | | * @param topicAtt Attributes of the associated topic |
146 | | * @param rqos QoS policies dictated by the subscriber |
147 | | * @param content_filter Optional content filtering information. |
148 | | * @return True if correct. |
149 | | */ |
150 | | bool addLocalReader( |
151 | | RTPSReader* R, |
152 | | const TopicAttributes& topicAtt, |
153 | | const fastdds::dds::ReaderQos& rqos, |
154 | | const fastdds::rtps::ContentFilterProperty* content_filter = nullptr); |
155 | | |
156 | | /** |
157 | | * Update a local Writer QOS |
158 | | * @param W Writer to update |
159 | | * @param topicAtt Attributes of the associated topic |
160 | | * @param wqos New Writer QoS |
161 | | * @return |
162 | | */ |
163 | | bool updateLocalWriter( |
164 | | RTPSWriter* W, |
165 | | const TopicAttributes& topicAtt, |
166 | | const fastdds::dds::WriterQos& wqos); |
167 | | /** |
168 | | * Update a local Reader QOS |
169 | | * @param R Reader to update |
170 | | * @param topicAtt Attributes of the associated topic |
171 | | * @param qos New Reader QoS |
172 | | * @param content_filter Optional content filtering information. |
173 | | * @return |
174 | | */ |
175 | | bool updateLocalReader( |
176 | | RTPSReader* R, |
177 | | const TopicAttributes& topicAtt, |
178 | | const fastdds::dds::ReaderQos& qos, |
179 | | const fastdds::rtps::ContentFilterProperty* content_filter = nullptr); |
180 | | /** |
181 | | * Remove a local Writer from the builtinProtocols. |
182 | | * @param W Pointer to the writer. |
183 | | * @return True if correctly removed. |
184 | | */ |
185 | | bool removeLocalWriter( |
186 | | RTPSWriter* W); |
187 | | /** |
188 | | * Remove a local Reader from the builtinProtocols. |
189 | | * @param R Pointer to the reader. |
190 | | * @return True if correctly removed. |
191 | | */ |
192 | | bool removeLocalReader( |
193 | | RTPSReader* R); |
194 | | |
195 | | //! Announce RTPSParticipantState (force the sending of a DPD message.) |
196 | | void announceRTPSParticipantState(); |
197 | | //!Stop the RTPSParticipant Announcement (used in tests to avoid multiple packets being send) |
198 | | void stopRTPSParticipantAnnouncement(); |
199 | | //!Reset to timer to make periodic RTPSParticipant Announcements. |
200 | | void resetRTPSParticipantAnnouncement(); |
201 | | |
202 | | /** |
203 | | * Get Discovery mutex |
204 | | * @return Associated Mutex |
205 | | */ |
206 | | inline eprosima::shared_mutex& getDiscoveryMutex() const |
207 | 0 | { |
208 | 0 | return discovery_mutex_; |
209 | 0 | } |
210 | | |
211 | | }; |
212 | | |
213 | | } // namespace rtps |
214 | | } /* namespace rtps */ |
215 | | } /* namespace eprosima */ |
216 | | #endif // ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC |
217 | | #endif /* _FASTDDS_RTPS_BUILTINPROTOCOLS_H_ */ |