DomainParticipantListener.hpp 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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. /**
  15. * @file DomainParticipantListener.hpp
  16. *
  17. */
  18. #ifndef __FASTDDS__PARTICIPANT_PARTICIPANTLISTENER_HPP__
  19. #define __FASTDDS__PARTICIPANT_PARTICIPANTLISTENER_HPP__
  20. #include <fastdds/rtps/participant/ParticipantDiscoveryInfo.h>
  21. #include <fastdds/rtps/reader/ReaderDiscoveryInfo.h>
  22. #include <fastdds/rtps/writer/WriterDiscoveryInfo.h>
  23. #include <fastdds/dds/publisher/PublisherListener.hpp>
  24. #include <fastdds/dds/subscriber/SubscriberListener.hpp>
  25. #include <fastdds/dds/topic/TopicListener.hpp>
  26. #include <fastrtps/types/TypeIdentifier.h>
  27. #include <fastrtps/types/TypeObject.h>
  28. #include <fastrtps/types/DynamicTypePtr.h>
  29. namespace eprosima {
  30. namespace fastdds {
  31. namespace dds {
  32. class DomainParticipant;
  33. /**
  34. * Class DomainParticipantListener, overrides behaviour towards certain events.
  35. * @ingroup FASTDDS_MODULE
  36. */
  37. class DomainParticipantListener :
  38. public PublisherListener,
  39. public SubscriberListener,
  40. public TopicListener
  41. {
  42. public:
  43. /**
  44. * @brief Constructor
  45. */
  46. DomainParticipantListener()
  47. {
  48. }
  49. /**
  50. * @brief Destructor
  51. */
  52. virtual ~DomainParticipantListener()
  53. {
  54. }
  55. /*!
  56. * This method is called when a new Participant is discovered, or a previously discovered participant changes
  57. * its QOS or is removed.
  58. * @param participant Pointer to the Participant which discovered the remote participant.
  59. * @param info Remote participant information. User can take ownership of the object.
  60. */
  61. virtual void on_participant_discovery(
  62. DomainParticipant* participant,
  63. fastrtps::rtps::ParticipantDiscoveryInfo&& info)
  64. {
  65. (void)participant, (void)info;
  66. }
  67. #if HAVE_SECURITY
  68. /*!
  69. * This method is called when a new Participant is authenticated.
  70. * @param participant Pointer to the authenticated Participant.
  71. * @param info Remote participant authentication information. User can take ownership of the object.
  72. */
  73. virtual void onParticipantAuthentication(
  74. DomainParticipant* participant,
  75. fastrtps::rtps::ParticipantAuthenticationInfo&& info)
  76. {
  77. (void)participant, (void)info;
  78. }
  79. #endif
  80. /*!
  81. * This method is called when a new Subscriber is discovered, or a previously discovered subscriber changes
  82. * its QOS or is removed.
  83. * @param participant Pointer to the Participant which discovered the remote subscriber.
  84. * @param info Remote subscriber information. User can take ownership of the object.
  85. */
  86. virtual void on_subscriber_discovery(
  87. DomainParticipant* participant,
  88. fastrtps::rtps::ReaderDiscoveryInfo&& info)
  89. {
  90. (void)participant, (void)info;
  91. }
  92. /*!
  93. * This method is called when a new Publisher is discovered, or a previously discovered publisher changes
  94. * its QOS or is removed.
  95. * @param participant Pointer to the Participant which discovered the remote publisher.
  96. * @param info Remote publisher information. User can take ownership of the object.
  97. */
  98. virtual void on_publisher_discovery(
  99. DomainParticipant* participant,
  100. fastrtps::rtps::WriterDiscoveryInfo&& info)
  101. {
  102. (void)participant, (void)info;
  103. }
  104. /*!
  105. * This method is called when a participant discovers a new Type
  106. * The ownership of all object belongs to the caller so if needs to be used after the
  107. * method ends, a full copy should be perform (except for dyn_type due to its shared_ptr nature.
  108. * For example:
  109. * fastrtps::types::TypeIdentifier new_type_id = *identifier;
  110. */
  111. virtual void on_type_discovery(
  112. DomainParticipant* participant,
  113. const fastrtps::rtps::SampleIdentity& request_sample_id,
  114. const fastrtps::string_255& topic,
  115. const fastrtps::types::TypeIdentifier* identifier,
  116. const fastrtps::types::TypeObject* object,
  117. fastrtps::types::DynamicType_ptr dyn_type)
  118. {
  119. (void)participant, (void)request_sample_id, (void)topic, (void)identifier, (void)object, (void)dyn_type;
  120. }
  121. /*!
  122. * This method is called when the typelookup client received a reply to a getTypeDependencies request.
  123. * The user may want to retrieve these new types using the getTypes request and create a new
  124. * DynamicType using the retrieved TypeObject.
  125. */
  126. virtual void on_type_dependencies_reply(
  127. DomainParticipant* participant,
  128. const fastrtps::rtps::SampleIdentity& request_sample_id,
  129. const fastrtps::types::TypeIdentifierWithSizeSeq& dependencies)
  130. {
  131. (void)participant, (void)request_sample_id, (void)dependencies;
  132. }
  133. /*!
  134. * This method is called when a participant receives a TypeInformation while discovering another participant.
  135. */
  136. virtual void on_type_information_received(
  137. DomainParticipant* participant,
  138. const fastrtps::string_255 topic_name,
  139. const fastrtps::string_255 type_name,
  140. const fastrtps::types::TypeInformation& type_information)
  141. {
  142. (void)participant, (void)topic_name, (void)type_name, (void)type_information;
  143. }
  144. // TODO: Methods in DomainParticipantListener (p.33 - DDS)
  145. };
  146. } // namespace dds
  147. } // namespace fastdds
  148. } // namespace eprosima
  149. #endif // __FASTDDS__PARTICIPANT_PARTICIPANTLISTENER_HPP__