RTPSParticipant.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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 RTPSParticipant.h
  16. */
  17. #ifndef _FASTDDS_RTPS_RTPSParticipant_H_
  18. #define _FASTDDS_RTPS_RTPSParticipant_H_
  19. #include <cstdlib>
  20. #include <memory>
  21. #include <fastrtps/fastrtps_dll.h>
  22. #include <fastdds/rtps/common/Guid.h>
  23. #include <fastdds/rtps/reader/StatefulReader.h>
  24. #include <fastdds/rtps/attributes/RTPSParticipantAttributes.h>
  25. #include <fastrtps/qos/ReaderQos.h>
  26. #include <fastrtps/qos/WriterQos.h>
  27. namespace eprosima {
  28. namespace fastdds {
  29. namespace dds {
  30. namespace builtin {
  31. class TypeLookupManager;
  32. } // namespace builtin
  33. } // namespace dds
  34. } // namespace fastdds
  35. namespace fastrtps {
  36. class TopicAttributes;
  37. namespace rtps {
  38. class RTPSParticipantImpl;
  39. class RTPSParticipantListener;
  40. class RTPSWriter;
  41. class RTPSReader;
  42. class WriterProxyData;
  43. class ReaderProxyData;
  44. class ResourceEvent;
  45. class WLP;
  46. /**
  47. * @brief Class RTPSParticipant, contains the public API for a RTPSParticipant.
  48. * @ingroup RTPS_MODULE
  49. */
  50. class RTPS_DllAPI RTPSParticipant
  51. {
  52. friend class RTPSParticipantImpl;
  53. friend class RTPSDomain;
  54. private:
  55. /**
  56. * Constructor. Requires a pointer to the implementation.
  57. * @param pimpl Implementation.
  58. */
  59. RTPSParticipant(
  60. RTPSParticipantImpl* pimpl);
  61. virtual ~RTPSParticipant();
  62. public:
  63. //!Get the GUID_t of the RTPSParticipant.
  64. const GUID_t& getGuid() const;
  65. //!Force the announcement of the RTPSParticipant state.
  66. void announceRTPSParticipantState();
  67. // //!Method to loose the next change (ONLY FOR TEST). //TODO remove this method because is only for testing
  68. // void loose_next_change();
  69. //!Stop the RTPSParticipant announcement period. //TODO remove this method because is only for testing
  70. void stopRTPSParticipantAnnouncement();
  71. //!Reset the RTPSParticipant announcement period. //TODO remove this method because is only for testing
  72. void resetRTPSParticipantAnnouncement();
  73. /**
  74. * Indicate the Participant that you have discovered a new Remote Writer.
  75. * This method can be used by the user to implements its own Static Endpoint
  76. * Discovery Protocol
  77. * @param pguid GUID_t of the discovered Writer.
  78. * @param userDefinedId ID of the discovered Writer.
  79. * @return True if correctly added.
  80. */
  81. bool newRemoteWriterDiscovered(
  82. const GUID_t& pguid,
  83. int16_t userDefinedId);
  84. /**
  85. * Indicate the Participant that you have discovered a new Remote Reader.
  86. * This method can be used by the user to implements its own Static Endpoint
  87. * Discovery Protocol
  88. * @param pguid GUID_t of the discovered Reader.
  89. * @param userDefinedId ID of the discovered Reader.
  90. * @return True if correctly added.
  91. */
  92. bool newRemoteReaderDiscovered(
  93. const GUID_t& pguid,
  94. int16_t userDefinedId);
  95. /**
  96. * Get the Participant ID.
  97. * @return Participant ID.
  98. */
  99. uint32_t getRTPSParticipantID() const;
  100. /**
  101. * Register a RTPSWriter in the builtin Protocols.
  102. * @param Writer Pointer to the RTPSWriter.
  103. * @param topicAtt Topic Attributes where you want to register it.
  104. * @param wqos WriterQos.
  105. * @return True if correctly registered.
  106. */
  107. bool registerWriter(
  108. RTPSWriter* Writer,
  109. const TopicAttributes& topicAtt,
  110. const WriterQos& wqos);
  111. /**
  112. * Register a RTPSReader in the builtin Protocols.
  113. * @param Reader Pointer to the RTPSReader.
  114. * @param topicAtt Topic Attributes where you want to register it.
  115. * @param rqos ReaderQos.
  116. * @return True if correctly registered.
  117. */
  118. bool registerReader(
  119. RTPSReader* Reader,
  120. const TopicAttributes& topicAtt,
  121. const ReaderQos& rqos);
  122. /**
  123. * Update writer QOS
  124. * @param Writer to update
  125. * @param topicAtt Topic Attributes where you want to register it.
  126. * @param wqos New writer QoS
  127. * @return true on success
  128. */
  129. bool updateWriter(
  130. RTPSWriter* Writer,
  131. const TopicAttributes& topicAtt,
  132. const WriterQos& wqos);
  133. /**
  134. * Update reader QOS
  135. * @param Reader to update
  136. * @param topicAtt Topic Attributes where you want to register it.
  137. * @param rqos New reader QoS
  138. * @return true on success
  139. */
  140. bool updateReader(
  141. RTPSReader* Reader,
  142. const TopicAttributes& topicAtt,
  143. const ReaderQos& rqos);
  144. /**
  145. * Returns a list with the participant names.
  146. * @return list of participant names.
  147. */
  148. std::vector<std::string> getParticipantNames() const;
  149. /**
  150. * Get a copy of the actual state of the RTPSParticipantParameters
  151. * @return RTPSParticipantAttributes copy of the params.
  152. */
  153. const RTPSParticipantAttributes& getRTPSParticipantAttributes() const;
  154. /**
  155. * Retrieves the maximum message size.
  156. */
  157. uint32_t getMaxMessageSize() const;
  158. /**
  159. * Retrieves the maximum data size.
  160. */
  161. uint32_t getMaxDataSize() const;
  162. ResourceEvent& get_resource_event() const;
  163. /**
  164. * @brief A method to retrieve the built-in writer liveliness protocol
  165. * @return Writer liveliness protocol
  166. */
  167. WLP* wlp() const;
  168. /**
  169. * @brief Fills a new entityId if set to unknown, or checks if a entity already exists with that
  170. * entityId in other case.
  171. * @param entityId to check of fill. If filled, EntityKind will be "vendor-specific" (0x01)
  172. * @return True if filled or the entityId is available.
  173. */
  174. bool get_new_entity_id(
  175. EntityId_t& entityId);
  176. /**
  177. * Allows setting a function to check if a type is already known by the top level API participant.
  178. */
  179. void set_check_type_function(
  180. std::function<bool(const std::string&)>&& check_type);
  181. /**
  182. * @brief Retrieves the built-in typelookup service manager.
  183. * @return
  184. */
  185. fastdds::dds::builtin::TypeLookupManager* typelookup_manager() const;
  186. /**
  187. * @brief Modifies the participant listener
  188. * @param listener
  189. */
  190. void set_listener(
  191. RTPSParticipantListener* listener);
  192. /**
  193. * @brief Retrieves the DomainId.
  194. */
  195. uint32_t get_domain_id() const;
  196. /**
  197. * @brief This operation enables the RTPSParticipantImpl
  198. */
  199. void enable();
  200. private:
  201. //!Pointer to the implementation.
  202. RTPSParticipantImpl* mp_impl;
  203. };
  204. }
  205. } /* namespace rtps */
  206. } /* namespace eprosima */
  207. #endif /* _FASTDDS_RTPS_RTPSParticipant_H_ */