19#ifndef FASTDDS_RTPS_COMMON__CACHECHANGE_HPP
20#define FASTDDS_RTPS_COMMON__CACHECHANGE_HPP
25#include <fastdds/rtps/common/ChangeKind_t.hpp>
26#include <fastdds/rtps/common/FragmentNumber.hpp>
27#include <fastdds/rtps/common/InstanceHandle.hpp>
28#include <fastdds/rtps/common/SerializedPayload.hpp>
29#include <fastdds/rtps/common/Time_t.hpp>
30#include <fastdds/rtps/common/Types.hpp>
31#include <fastdds/rtps/common/VendorId_t.hpp>
32#include <fastdds/rtps/common/WriteParams.hpp>
33#include <fastdds/rtps/history/IPayloadPool.hpp>
128 uint32_t payload_size,
129 bool is_untyped =
false)
152 fragment_size_ = ch_ptr->fragment_size_;
153 fragment_count_ = ch_ptr->fragment_count_;
154 first_missing_fragment_ = ch_ptr->first_missing_fragment_;
193 return fragment_count_;
202 return fragment_size_;
211 return first_missing_fragment_ >= fragment_count_;
219 return 0 < first_missing_fragment_;
230 frag_sns.
base(first_missing_fragment_ + 1);
233 uint32_t current_frag = first_missing_fragment_;
234 while (current_frag < fragment_count_)
236 frag_sns.
add(current_frag + 1);
237 current_frag = get_next_missing_fragment(current_frag);
251 uint16_t fragment_size,
252 bool create_fragment_list =
false)
254 fragment_size_ = fragment_size;
256 first_missing_fragment_ = 0;
258 if (fragment_size > 0)
261 fragment_count_ = (
serializedPayload.length + fragment_size - 1) / fragment_size;
263 if (create_fragment_list)
268 for (uint32_t i = 1; i <= fragment_count_; i++, offset += fragment_size_)
270 set_next_missing_fragment(i - 1, i);
277 first_missing_fragment_ = fragment_count_;
284 uint32_t fragment_starting_num,
285 uint32_t fragments_in_submessage)
287 uint32_t original_offset = (fragment_starting_num - 1) * fragment_size_;
288 uint32_t incoming_length = fragment_size_ * fragments_in_submessage;
289 uint32_t last_fragment_index = fragment_starting_num + fragments_in_submessage - 1;
298 if (last_fragment_index > fragment_count_)
304 if (last_fragment_index < fragment_count_)
306 if (incoming_data.
length < incoming_length)
321 if (received_fragments(fragment_starting_num - 1, fragments_in_submessage))
325 incoming_data.
data, incoming_length);
334 uint16_t fragment_size_ = 0;
337 uint32_t fragment_count_ = 0;
340 uint32_t first_missing_fragment_ = 0;
342 uint32_t get_next_missing_fragment(
343 uint32_t fragment_index)
345 uint32_t* ptr = next_fragment_pointer(fragment_index);
349 void set_next_missing_fragment(
350 uint32_t fragment_index,
351 uint32_t next_fragment_index)
353 uint32_t* ptr = next_fragment_pointer(fragment_index);
354 *ptr = next_fragment_index;
357 uint32_t* next_fragment_pointer(
358 uint32_t fragment_index)
360 size_t offset = fragment_size_;
361 offset *= fragment_index;
362 offset = (offset + 3u) & ~3u;
363 return reinterpret_cast<uint32_t*
>(&serializedPayload.
data[offset]);
375 bool received_fragments(
376 uint32_t initial_fragment,
377 uint32_t num_of_fragments)
379 bool at_least_one_changed =
false;
381 if ((fragment_size_ > 0) && (initial_fragment < fragment_count_))
383 uint32_t last_fragment = initial_fragment + num_of_fragments;
384 if (last_fragment > fragment_count_)
386 last_fragment = fragment_count_;
389 if (initial_fragment <= first_missing_fragment_)
392 while (first_missing_fragment_ < last_fragment)
394 first_missing_fragment_ = get_next_missing_fragment(first_missing_fragment_);
395 at_least_one_changed =
true;
401 uint32_t current_frag = first_missing_fragment_;
402 while (current_frag < initial_fragment)
404 uint32_t next_frag = get_next_missing_fragment(current_frag);
405 if (next_frag >= initial_fragment)
409 uint32_t next_missing_fragment = next_frag;
410 while (next_missing_fragment < last_fragment)
412 next_missing_fragment = get_next_missing_fragment(next_missing_fragment);
413 at_least_one_changed =
true;
417 if (at_least_one_changed)
419 set_next_missing_fragment(current_frag, next_missing_fragment);
423 current_frag = next_frag;
428 return at_least_one_changed;
T base() const noexcept
Get base of the range.
Definition fixed_size_bitmap.hpp:131
bool add(const T &item) noexcept
Adds an element to the range.
Definition fixed_size_bitmap.hpp:295
Structure Time_t, used to describe times at RTPS protocol.
Definition Time_t.hpp:38
This class contains additional information of a CacheChange.
Definition WriteParams.hpp:36
Contains the RTPS protocol implementation.
@ LITTLEEND
Little endianness.
Definition Types.hpp:44
const VendorId_t c_VendorId_Unknown
Definition VendorId_t.hpp:34
std::array< uint8_t, 2 > VendorId_t
Structure VendorId_t, specifying the vendor Id of the implementation.
Definition VendorId_t.hpp:32
constexpr Endianness_t DEFAULT_ENDIAN
Definition Types.hpp:80
ChangeKind_t
Enumerates the different types of CacheChange_t.
Definition ChangeKind_t.hpp:38
@ ALIVE
ALIVE.
Definition ChangeKind_t.hpp:39
BitmapRange< FragmentNumber_t > FragmentNumberSet_t
Structure FragmentNumberSet_t, contains a group of fragmentnumbers.
Definition FragmentNumber.hpp:37
Structure CacheChange_t, contains information on a specific CacheChange.
Definition CacheChange.hpp:78
ChangeKind_t kind
Kind of change, default value ALIVE.
Definition CacheChange.hpp:80
bool is_untyped_
Definition CacheChange.hpp:105
bool contains_first_fragment()
Checks if the first fragment is present.
Definition CacheChange.hpp:217
InstanceHandle_t instanceHandle
Handle of the data associated with this change.
Definition CacheChange.hpp:84
bool isRead
Indicates if the cache has been read (only used in READERS).
Definition CacheChange.hpp:92
fastdds::rtps::VendorId_t vendor_id
Vendor Id of the writer that generated this change.
Definition CacheChange.hpp:96
Time_t sourceTimestamp
Source TimeStamp.
Definition CacheChange.hpp:94
CacheChange_t(const CacheChange_t &)=delete
void setFragmentSize(uint16_t fragment_size, bool create_fragment_list=false)
Set fragment size for this change.
Definition CacheChange.hpp:250
CacheChangeReaderInfo_t reader_info
Definition CacheChange.hpp:100
virtual ~CacheChange_t()=default
SerializedPayload_t inline_qos
CDR serialization of inlined QoS for this change.
Definition CacheChange.hpp:90
void copy_not_memcpy(const CacheChange_t *ch_ptr)
Copy information form a different change into this one.
Definition CacheChange.hpp:164
uint16_t getFragmentSize() const
Get the size of each fragment this change is split into.
Definition CacheChange.hpp:200
uint32_t getFragmentCount() const
Get the number of fragments this change is split into.
Definition CacheChange.hpp:191
bool copy(const CacheChange_t *ch_ptr)
Copy a different change into this one.
Definition CacheChange.hpp:140
bool add_fragments(const SerializedPayload_t &incoming_data, uint32_t fragment_starting_num, uint32_t fragments_in_submessage)
Definition CacheChange.hpp:282
CacheChangeWriterInfo_t writer_info
Definition CacheChange.hpp:101
GUID_t writerGUID
GUID_t of the writer that generated this change.
Definition CacheChange.hpp:82
CacheChange_t(uint32_t payload_size, bool is_untyped=false)
Constructor with payload size.
Definition CacheChange.hpp:127
SerializedPayload_t serializedPayload
Serialized Payload associated with the change.
Definition CacheChange.hpp:88
void get_missing_fragments(FragmentNumberSet_t &frag_sns)
Fills a FragmentNumberSet_t with the list of missing fragments.
Definition CacheChange.hpp:226
SequenceNumber_t sequenceNumber
SequenceNumber of the change.
Definition CacheChange.hpp:86
CacheChange_t()
Default constructor.
Definition CacheChange.hpp:111
WriteParams write_params
Definition CacheChange.hpp:104
bool is_fully_assembled()
Checks if all fragments have been received.
Definition CacheChange.hpp:209
Specific information for a reader.
Definition CacheChange.hpp:62
Time_t receptionTimestamp
Reception TimeStamp (only used in Readers).
Definition CacheChange.hpp:64
int32_t no_writers_generation_count
No-writers generation of the instance when this entry was added to it.
Definition CacheChange.hpp:68
uint32_t writer_ownership_strength
Ownership stregth of its writer when the sample was received.
Definition CacheChange.hpp:70
int32_t disposed_generation_count
Disposed generation of the instance when this entry was added to it.
Definition CacheChange.hpp:66
Specific information for a writer.
Definition CacheChange.hpp:45
std::atomic_bool is_linked
Used to know if the object is already in a list.
Definition CacheChange.hpp:55
size_t num_sent_submessages
Number of DATA / DATA_FRAG submessages sent to the transport (only used in Writers).
Definition CacheChange.hpp:47
CacheChange_t *volatile next
Used to link with next node in a list.
Definition CacheChange.hpp:53
CacheChange_t *volatile previous
Used to link with previous node in a list.
Definition CacheChange.hpp:50
Structure GUID_t, entity identifier, unique in DDS-RTPS Domain.
Definition Guid.hpp:40
Struct InstanceHandle_t, used to contain the key for WITH_KEY topics.
Definition InstanceHandle.hpp:154
Structure SequenceNumber_t, different for each change in the same writer.
Definition SequenceNumber.hpp:38
Structure SerializedPayload_t.
Definition SerializedPayload.hpp:59
octet * data
Pointer to the data.
Definition SerializedPayload.hpp:68
uint16_t encapsulation
Encapsulation of the data as suggested in the RTPS 2.1 specification chapter 10.
Definition SerializedPayload.hpp:64
bool is_serialized_key
Whether the payload contains a serialized key, or the whole data.
Definition SerializedPayload.hpp:76
uint32_t length
Actual length of the data.
Definition SerializedPayload.hpp:66