ReaderHistory.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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 ReaderHistory.h
  16. *
  17. */
  18. #ifndef _FASTDDS_RTPS_READERHISTORY_H_
  19. #define _FASTDDS_RTPS_READERHISTORY_H_
  20. #include <fastdds/rtps/history/History.h>
  21. #include <fastdds/rtps/common/CacheChange.h>
  22. namespace eprosima {
  23. namespace fastrtps {
  24. namespace rtps {
  25. class WriterProxy;
  26. class RTPSReader;
  27. /**
  28. * Class ReaderHistory, container of the different CacheChanges of a reader
  29. * @ingroup READER_MODULE
  30. */
  31. class ReaderHistory : public History
  32. {
  33. friend class RTPSReader;
  34. ReaderHistory(
  35. ReaderHistory&&) = delete;
  36. ReaderHistory& operator =(
  37. ReaderHistory&&) = delete;
  38. public:
  39. /**
  40. * Constructor of the ReaderHistory. It needs a HistoryAttributes.
  41. */
  42. RTPS_DllAPI ReaderHistory(
  43. const HistoryAttributes& att);
  44. RTPS_DllAPI virtual ~ReaderHistory() override;
  45. /**
  46. * Virtual method that is called when a new change is received.
  47. * In this implementation this method just calls add_change. The suer can overload this method in case
  48. * he needs to perform additional checks before adding the change.
  49. * @param change Pointer to the change
  50. * @return True if added.
  51. */
  52. RTPS_DllAPI virtual bool received_change(CacheChange_t* change, size_t);
  53. /**
  54. * Add a CacheChange_t to the ReaderHistory.
  55. * @param a_change Pointer to the CacheChange to add.
  56. * @return True if added.
  57. */
  58. RTPS_DllAPI bool add_change(
  59. CacheChange_t* a_change);
  60. /**
  61. * Remove a CacheChange_t from the ReaderHistory.
  62. * @param a_change Pointer to the CacheChange to remove.
  63. * @return True if removed.
  64. */
  65. RTPS_DllAPI bool remove_change(
  66. CacheChange_t* a_change) override;
  67. /**
  68. * Remove a specific change from the history.
  69. * @param ch Pointer to the CacheChange_t.
  70. * @param position Iterator where the CacheChange_t is located in the history.
  71. * @return An iterator pointing to the new location of the element that followed the removed CacheChange_t.
  72. */
  73. const_iterator remove_change_nts(
  74. CacheChange_t* ch,
  75. const_iterator position);
  76. /**
  77. * Remove all changes from the History that have a certain guid.
  78. * @param a_guid Pointer to the target guid to search for.
  79. * @return True if succesful, even if no changes have been removed.
  80. * */
  81. RTPS_DllAPI bool remove_changes_with_guid(
  82. const GUID_t& a_guid);
  83. /**
  84. * Remove all fragmented changes from certain writer up to certain sequence number.
  85. * @param seq_num First SequenceNumber_t not to be removed.
  86. * @param writer_guid GUID of the writer for which changes should be looked for.
  87. * @return True if succesful, even if no changes have been removed.
  88. */
  89. bool remove_fragmented_changes_until(
  90. const SequenceNumber_t& seq_num,
  91. const GUID_t& writer_guid);
  92. RTPS_DllAPI bool get_min_change_from(
  93. CacheChange_t** min_change,
  94. const GUID_t& writerGuid);
  95. protected:
  96. //!Pointer to the reader
  97. RTPSReader* mp_reader;
  98. };
  99. }
  100. } /* namespace rtps */
  101. } /* namespace eprosima */
  102. #endif /* _FASTDDS_RTPS_READERHISTORY_H_ */