Topic.hpp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. // Copyright 2020 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 Topic.hpp
  16. */
  17. #ifndef _FASTDDS_TOPIC_HPP_
  18. #define _FASTDDS_TOPIC_HPP_
  19. #include <fastrtps/fastrtps_dll.h>
  20. #include <fastdds/dds/core/Entity.hpp>
  21. #include <fastdds/dds/core/status/BaseStatus.hpp>
  22. #include <fastdds/dds/topic/TopicDescription.hpp>
  23. #include <fastdds/dds/topic/qos/TopicQos.hpp>
  24. using eprosima::fastrtps::types::ReturnCode_t;
  25. namespace dds {
  26. namespace topic {
  27. class Topic;
  28. } // namespace topic
  29. } // namespace dds
  30. namespace eprosima {
  31. namespace fastdds {
  32. namespace dds {
  33. class DomainParticipant;
  34. class TopicListener;
  35. class DomainParticipantImpl;
  36. class TopicImpl;
  37. /**
  38. * Class TopicDescription, represents the fact that both publications
  39. * and subscriptions are tied to a single data-type
  40. * @ingroup FASTDDS_MODULE
  41. */
  42. class Topic : public DomainEntity, public TopicDescription
  43. {
  44. friend class TopicImpl;
  45. friend class DomainParticipantImpl;
  46. /**
  47. * Create a topic, assigning its pointer to the associated implementation.
  48. * Don't use directly, create Topic using create_topic from Participant.
  49. */
  50. RTPS_DllAPI Topic(
  51. const std::string& topic_name,
  52. const std::string& type_name,
  53. TopicImpl* p,
  54. const StatusMask& mask = StatusMask::all());
  55. RTPS_DllAPI Topic(
  56. DomainParticipant* dp,
  57. const std::string& topic_name,
  58. const std::string& type_name,
  59. const TopicQos& qos = TOPIC_QOS_DEFAULT,
  60. TopicListener* listener = nullptr,
  61. const StatusMask& mask = StatusMask::all());
  62. public:
  63. /**
  64. * @brief Destructor
  65. */
  66. RTPS_DllAPI virtual ~Topic();
  67. /**
  68. * @brief Getter for the DomainParticipant
  69. * @return DomainParticipant pointer
  70. */
  71. virtual DomainParticipant* get_participant() const override;
  72. /**
  73. * Allows the application to retrieve the INCONSISTENT_TOPIC_STATUS status of a Topic.
  74. * @param status [out] Status to be retrieved.
  75. * @return RETCODE_OK
  76. */
  77. ReturnCode_t get_inconsistent_topic_status(
  78. InconsistentTopicStatus& status);
  79. /**
  80. * Allows accessing the Topic Qos.
  81. * @return reference to TopicQos
  82. */
  83. RTPS_DllAPI const TopicQos& get_qos() const;
  84. /**
  85. * Retrieves the Topic Qos.
  86. * @param qos TopicQos where the qos is returned
  87. * @return RETCODE_OK
  88. */
  89. RTPS_DllAPI ReturnCode_t get_qos(
  90. TopicQos& qos) const;
  91. /**
  92. * Allows modifying the Topic Qos.
  93. * The given Qos must be supported by the Topic.
  94. * @param qos new TopicQos value to set for the Topic.
  95. * @retval RETCODE_IMMUTABLE_POLICY if a change was not allowed.
  96. * @retval RETCODE_INCONSISTENT_POLICY if new qos has inconsistent values.
  97. * @retval RETCODE_OK if qos was updated.
  98. */
  99. RTPS_DllAPI ReturnCode_t set_qos(
  100. const TopicQos& qos);
  101. /**
  102. * Retrieves the attached TopicListener.
  103. * @return pointer to TopicListener
  104. */
  105. RTPS_DllAPI const TopicListener* get_listener() const;
  106. /**
  107. * Modifies the TopicListener.
  108. * @param listener new value for the TopicListener
  109. * @param mask StatusMask (default: all)
  110. * @return RETCODE_OK
  111. */
  112. RTPS_DllAPI ReturnCode_t set_listener(
  113. TopicListener* listener,
  114. const StatusMask& mask = StatusMask::all());
  115. /**
  116. * @brief Getter for the TopicDescriptionImpl
  117. * @return pointer to TopicDescriptionImpl
  118. */
  119. TopicDescriptionImpl* get_impl() const override;
  120. private:
  121. TopicImpl* impl_;
  122. friend class ::dds::topic::Topic;
  123. };
  124. } /* namespace dds */
  125. } /* namespace fastdds */
  126. } /* namespace eprosima */
  127. #endif /* _FASTDDS_TOPIC_HPP_ */