WriterHistory.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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 WriterHistory.h
  16. *
  17. */
  18. #ifndef _FASTDDS_RTPS_WRITERHISTORY_H_
  19. #define _FASTDDS_RTPS_WRITERHISTORY_H_
  20. #include <fastdds/rtps/history/History.h>
  21. namespace eprosima {
  22. namespace fastrtps{
  23. namespace rtps {
  24. class RTPSWriter;
  25. class WriteParams;
  26. /**
  27. * Class WriterHistory, container of the different CacheChanges of a writer
  28. * @ingroup WRITER_MODULE
  29. */
  30. class WriterHistory : public History
  31. {
  32. friend class RTPSWriter;
  33. friend class PersistentWriter;
  34. WriterHistory(WriterHistory&&) = delete;
  35. WriterHistory& operator=(WriterHistory&&) = delete;
  36. public:
  37. /**
  38. * Constructor of the WriterHistory.
  39. */
  40. RTPS_DllAPI WriterHistory(const HistoryAttributes& att);
  41. RTPS_DllAPI virtual ~WriterHistory() override;
  42. /**
  43. * Add a CacheChange_t to the WriterHistory.
  44. * @param a_change Pointer to the CacheChange_t to be added.
  45. * @return True if added.
  46. */
  47. RTPS_DllAPI bool add_change(CacheChange_t* a_change);
  48. /**
  49. * Add a CacheChange_t to the WriterHistory.
  50. * @param a_change Pointer to the CacheChange_t to be added.
  51. * @param wparams Extra write parameters.
  52. * @return True if added.
  53. */
  54. RTPS_DllAPI bool add_change(
  55. CacheChange_t* a_change,
  56. WriteParams &wparams);
  57. /**
  58. * Remove a specific change from the history.
  59. * @param a_change Pointer to the CacheChange_t.
  60. * @return True if removed.
  61. */
  62. RTPS_DllAPI bool remove_change(CacheChange_t* a_change) override;
  63. virtual bool remove_change_g(CacheChange_t* a_change);
  64. RTPS_DllAPI bool remove_change(const SequenceNumber_t& sequence_number);
  65. RTPS_DllAPI CacheChange_t* remove_change_and_reuse(const SequenceNumber_t& sequence_number);
  66. /**
  67. * Remove the CacheChange_t with the minimum sequenceNumber.
  68. * @return True if correctly removed.
  69. */
  70. RTPS_DllAPI bool remove_min_change();
  71. RTPS_DllAPI SequenceNumber_t next_sequence_number() const { return m_lastCacheChangeSeqNum + 1; }
  72. protected:
  73. bool add_change_(CacheChange_t* a_change, WriteParams &wparams,
  74. std::chrono::time_point<std::chrono::steady_clock> max_blocking_time
  75. = std::chrono::steady_clock::now() + std::chrono::hours(24));
  76. //!Last CacheChange Sequence Number added to the History.
  77. SequenceNumber_t m_lastCacheChangeSeqNum;
  78. //!Pointer to the associated RTPSWriter;
  79. RTPSWriter* mp_writer;
  80. };
  81. }
  82. } /* namespace fastrtps */
  83. } /* namespace eprosima */
  84. #endif /* _FASTDDS_RTPS_WRITERHISTORY_H_ */