BuiltinProtocols.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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. * @file BuiltinProtocols.h
  16. *
  17. */
  18. #ifndef _FASTDDS_RTPS_BUILTINPROTOCOLS_H_
  19. #define _FASTDDS_RTPS_BUILTINPROTOCOLS_H_
  20. #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
  21. #include <list>
  22. #include <fastdds/rtps/attributes/RTPSParticipantAttributes.h>
  23. #include <fastdds/rtps/network/NetworkFactory.h>
  24. namespace eprosima {
  25. namespace fastdds {
  26. namespace dds {
  27. namespace builtin {
  28. class TypeLookupManager;
  29. } // namespace builtin
  30. class ReaderQos;
  31. class WriterQos;
  32. } // namespace dds
  33. } // namespace fastdds
  34. namespace fastrtps {
  35. class TopicAttributes;
  36. namespace rtps {
  37. class PDP;
  38. class WLP;
  39. class RTPSParticipantImpl;
  40. class RTPSWriter;
  41. class RTPSReader;
  42. /**
  43. * Class BuiltinProtocols that contains builtin endpoints implementing the discovery and liveliness protocols.
  44. * *@ingroup BUILTIN_MODULE
  45. */
  46. class BuiltinProtocols
  47. {
  48. friend class RTPSParticipantImpl;
  49. private:
  50. BuiltinProtocols();
  51. virtual ~BuiltinProtocols();
  52. public:
  53. /**
  54. * Initialize the builtin protocols.
  55. * @param attributes Discovery configuration attributes
  56. * @param p_part Pointer to the Participant implementation
  57. * @return True if correct.
  58. */
  59. bool initBuiltinProtocols(
  60. RTPSParticipantImpl* p_part,
  61. BuiltinAttributes& attributes);
  62. /**
  63. * Update the metatraffic locatorlist after it was created. Because when you create
  64. * the EDP readers you are not sure the selected endpoints can be used.
  65. * @param loclist LocatorList to update
  66. * @return True on success
  67. */
  68. bool updateMetatrafficLocators(
  69. LocatorList_t& loclist);
  70. /**
  71. * Traverses the list of discover servers translating from remote to local locators
  72. * if possible
  73. * @param nf NetworkFactory used to make the translation
  74. */
  75. void transform_server_remote_locators(
  76. NetworkFactory & nf);
  77. //!BuiltinAttributes of the builtin protocols.
  78. BuiltinAttributes m_att;
  79. //!Pointer to the RTPSParticipantImpl.
  80. RTPSParticipantImpl* mp_participantImpl;
  81. //!Pointer to the PDPSimple.
  82. PDP* mp_PDP;
  83. //!Pointer to the WLP
  84. WLP* mp_WLP;
  85. //!Pointer to the TypeLookupManager
  86. fastdds::dds::builtin::TypeLookupManager* tlm_;
  87. //!Locator list for metatraffic
  88. LocatorList_t m_metatrafficMulticastLocatorList;
  89. //!Locator List for metatraffic unicast
  90. LocatorList_t m_metatrafficUnicastLocatorList;
  91. //! Initial peers
  92. LocatorList_t m_initialPeersList;
  93. //! Known discovery and backup server container
  94. std::list<RemoteServerAttributes> m_DiscoveryServers;
  95. /**
  96. * Add a local Writer to the BuiltinProtocols.
  97. * @param w Pointer to the RTPSWriter
  98. * @param topicAtt Attributes of the associated topic
  99. * @param wqos QoS policies dictated by the publisher
  100. * @return True if correct.
  101. */
  102. bool addLocalWriter(
  103. RTPSWriter* w,
  104. const TopicAttributes& topicAtt,
  105. const fastdds::dds::WriterQos& wqos);
  106. /**
  107. * Add a local Reader to the BuiltinProtocols.
  108. * @param R Pointer to the RTPSReader.
  109. * @param topicAtt Attributes of the associated topic
  110. * @param rqos QoS policies dictated by the subscriber
  111. * @return True if correct.
  112. */
  113. bool addLocalReader(
  114. RTPSReader* R,
  115. const TopicAttributes& topicAtt,
  116. const fastdds::dds::ReaderQos& rqos);
  117. /**
  118. * Update a local Writer QOS
  119. * @param W Writer to update
  120. * @param topicAtt Attributes of the associated topic
  121. * @param wqos New Writer QoS
  122. * @return
  123. */
  124. bool updateLocalWriter(
  125. RTPSWriter* W,
  126. const TopicAttributes& topicAtt,
  127. const fastdds::dds::WriterQos& wqos);
  128. /**
  129. * Update a local Reader QOS
  130. * @param R Reader to update
  131. * @param topicAtt Attributes of the associated topic
  132. * @param qos New Reader QoS
  133. * @return
  134. */
  135. bool updateLocalReader(
  136. RTPSReader* R,
  137. const TopicAttributes& topicAtt,
  138. const fastdds::dds::ReaderQos& qos);
  139. /**
  140. * Remove a local Writer from the builtinProtocols.
  141. * @param W Pointer to the writer.
  142. * @return True if correctly removed.
  143. */
  144. bool removeLocalWriter(
  145. RTPSWriter* W);
  146. /**
  147. * Remove a local Reader from the builtinProtocols.
  148. * @param R Pointer to the reader.
  149. * @return True if correctly removed.
  150. */
  151. bool removeLocalReader(
  152. RTPSReader* R);
  153. //! Announce RTPSParticipantState (force the sending of a DPD message.)
  154. void announceRTPSParticipantState();
  155. //!Stop the RTPSParticipant Announcement (used in tests to avoid multiple packets being send)
  156. void stopRTPSParticipantAnnouncement();
  157. //!Reset to timer to make periodic RTPSParticipant Announcements.
  158. void resetRTPSParticipantAnnouncement();
  159. };
  160. }
  161. } /* namespace rtps */
  162. } /* namespace eprosima */
  163. #endif
  164. #endif /* _FASTDDS_RTPS_BUILTINPROTOCOLS_H_ */