WriterAttributes.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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 WriterAttributes.h
  16. *
  17. */
  18. #ifndef _FASTDDS_WRITERATTRIBUTES_H_
  19. #define _FASTDDS_WRITERATTRIBUTES_H_
  20. #include <fastdds/rtps/common/Time_t.h>
  21. #include <fastdds/rtps/common/Guid.h>
  22. #include <fastdds/rtps/flowcontrol/ThroughputControllerDescriptor.h>
  23. #include <fastdds/rtps/attributes/EndpointAttributes.h>
  24. #include <fastrtps/utils/collections/ResourceLimitedContainerConfig.hpp>
  25. #include <fastrtps/qos/QosPolicies.h>
  26. #include <functional>
  27. namespace eprosima {
  28. namespace fastrtps {
  29. namespace rtps {
  30. class ReaderProxyData;
  31. typedef enum RTPSWriterPublishMode : octet
  32. {
  33. SYNCHRONOUS_WRITER,
  34. ASYNCHRONOUS_WRITER
  35. } RTPSWriterPublishMode;
  36. /**
  37. * Struct WriterTimes, defining the times associated with the Reliable Writers events.
  38. * @ingroup RTPS_ATTRIBUTES_MODULE
  39. */
  40. struct WriterTimes
  41. {
  42. //! Initial heartbeat delay. Default value ~11ms.
  43. Duration_t initialHeartbeatDelay;
  44. //! Periodic HB period, default value 3s.
  45. Duration_t heartbeatPeriod;
  46. //!Delay to apply to the response of a ACKNACK message, default value ~5ms.
  47. Duration_t nackResponseDelay;
  48. //!This time allows the RTPSWriter to ignore nack messages too soon after the data as sent, default value 0s.
  49. Duration_t nackSupressionDuration;
  50. WriterTimes()
  51. {
  52. //initialHeartbeatDelay.fraction = 50*1000*1000;
  53. initialHeartbeatDelay.nanosec = 12 * 1000 * 1000;
  54. heartbeatPeriod.seconds = 3;
  55. //nackResponseDelay.fraction = 20*1000*1000;
  56. nackResponseDelay.nanosec = 5 * 1000 * 1000;
  57. }
  58. virtual ~WriterTimes()
  59. {
  60. }
  61. bool operator ==(
  62. const WriterTimes& b) const
  63. {
  64. return (this->initialHeartbeatDelay == b.initialHeartbeatDelay) &&
  65. (this->heartbeatPeriod == b.heartbeatPeriod) &&
  66. (this->nackResponseDelay == b.nackResponseDelay) &&
  67. (this->nackSupressionDuration == b.nackSupressionDuration);
  68. }
  69. };
  70. /**
  71. * Class WriterAttributes, defining the attributes of a RTPSWriter.
  72. * @ingroup RTPS_ATTRIBUTES_MODULE
  73. */
  74. class WriterAttributes
  75. {
  76. public:
  77. WriterAttributes()
  78. : liveliness_kind(AUTOMATIC_LIVELINESS_QOS)
  79. , liveliness_lease_duration(TIME_T_INFINITE_SECONDS, TIME_T_INFINITE_NANOSECONDS)
  80. , liveliness_announcement_period(TIME_T_INFINITE_SECONDS, TIME_T_INFINITE_NANOSECONDS)
  81. , mode(SYNCHRONOUS_WRITER)
  82. , disable_heartbeat_piggyback(false)
  83. , disable_positive_acks(false)
  84. , keep_duration(TIME_T_INFINITE_SECONDS, TIME_T_INFINITE_NANOSECONDS)
  85. {
  86. endpoint.endpointKind = WRITER;
  87. endpoint.durabilityKind = TRANSIENT_LOCAL;
  88. endpoint.reliabilityKind = RELIABLE;
  89. }
  90. virtual ~WriterAttributes()
  91. {
  92. }
  93. //!Attributes of the associated endpoint.
  94. EndpointAttributes endpoint;
  95. //!Writer Times (only used for RELIABLE).
  96. WriterTimes times;
  97. //! Liveliness kind
  98. fastrtps::LivelinessQosPolicyKind liveliness_kind;
  99. //! Liveliness lease duration
  100. Duration_t liveliness_lease_duration;
  101. //! Liveliness announcement period
  102. Duration_t liveliness_announcement_period;
  103. //!Indicates if the Writer is synchronous or asynchronous
  104. RTPSWriterPublishMode mode;
  105. // Throughput controller, always the last one to apply
  106. ThroughputControllerDescriptor throughputController;
  107. //! Disable the sending of heartbeat piggybacks.
  108. bool disable_heartbeat_piggyback;
  109. //! Define the allocation behaviour for matched-reader-dependent collections.
  110. ResourceLimitedContainerConfig matched_readers_allocation;
  111. //! Disable the sending of positive ACKs
  112. bool disable_positive_acks;
  113. //! Keep duration to keep a sample before considering it has been acked
  114. Duration_t keep_duration;
  115. };
  116. } /* namespace rtps */
  117. } /* namespace fastrtps */
  118. } /* namespace eprosima */
  119. #endif /* _FASTDDS_WRITERATTRIBUTES_H_ */