OpenDDS  Snapshot(2023/04/07-19:43)
Public Member Functions | Protected Attributes | List of all members
OpenDDS::DCPS::WriterDataSampleList Class Reference

#include <WriterDataSampleList.h>

Collaboration diagram for OpenDDS::DCPS::WriterDataSampleList:
Collaboration graph
[legend]

Public Member Functions

 WriterDataSampleList ()
 Default constructor clears the list. More...
 
 ~WriterDataSampleList ()
 
void reset ()
 Reset to initial state. More...
 
ssize_t size () const
 
DataSampleElementhead () const
 
DataSampleElementtail () const
 
void enqueue_tail (const DataSampleElement *element)
 
bool dequeue_head (DataSampleElement *&stale)
 
bool dequeue (const DataSampleElement *stale)
 

Protected Attributes

DataSampleElementhead_
 The first element of the list. More...
 
DataSampleElementtail_
 The last element of the list. More...
 
ssize_t size_
 Number of elements in the list. More...
 

Detailed Description

A list of DataSampleElement pointers to be queued by the order the samples are written to the DataWriter (within PRESENTATION.access_scope==TOPIC). Cache the number of elements in the list so that list traversal is not required to find this information. Manages DataSampleElement's previous_writer_sample/next_writer_sample pointers

Definition at line 29 of file WriterDataSampleList.h.

Constructor & Destructor Documentation

◆ WriterDataSampleList()

ACE_INLINE OpenDDS::DCPS::WriterDataSampleList::WriterDataSampleList ( )

Default constructor clears the list.

Definition at line 18 of file WriterDataSampleList.inl.

References ACE_INLINE.

19  : head_(0),
20  tail_(0),
21  size_(0)
22 {
23 }
ssize_t size_
Number of elements in the list.
DataSampleElement * head_
The first element of the list.
DataSampleElement * tail_
The last element of the list.

◆ ~WriterDataSampleList()

OpenDDS::DCPS::WriterDataSampleList::~WriterDataSampleList ( )
inline

Definition at line 34 of file WriterDataSampleList.h.

34 {}

Member Function Documentation

◆ dequeue()

bool OpenDDS::DCPS::WriterDataSampleList::dequeue ( const DataSampleElement stale)

Definition at line 22 of file WriterDataSampleList.cpp.

References dequeue_head(), head(), head_, OpenDDS::DCPS::DataSampleElement::next_writer_sample_, OPENDDS_END_VERSIONED_NAMESPACE_DECL, OpenDDS::DCPS::DataSampleElement::previous_writer_sample_, size_, and tail_.

Referenced by OpenDDS::DCPS::WriteDataContainer::release_buffer().

23 {
24  if (head_ == 0) {
25  return false;
26  }
27 
28  if (stale == head_) {
29  DataSampleElement* head = head_;
30  return dequeue_head(head);
31  }
32 
33  // Search from head_->next_writer_sample_.
34  bool found = false;
35 
36  for (DataSampleElement* item = head_->next_writer_sample_;
37  item != 0;
38  item = item->next_writer_sample_) {
39  if (item == stale) {
40  found = true;
41  break;
42  }
43  }
44 
45  if (found) {
46  // Adjust list size.
47  -- size_ ;
48 
49  //
50  // Remove from the previous element.
51  //
52  stale->previous_writer_sample_->next_writer_sample_ = stale->next_writer_sample_ ;
53 
54  //
55  // Remove from the next element.
56  //
57  if (stale->next_writer_sample_ != 0) {
58  // Remove the inside of the list.
59  stale->next_writer_sample_->previous_writer_sample_ = stale->previous_writer_sample_ ;
60 
61  } else {
62  // Remove from the tail of the list.
64  }
65 
66  stale->next_writer_sample_ = 0;
67  stale->previous_writer_sample_ = 0;
68  }
69 
70  return found;
71 }
ssize_t size_
Number of elements in the list.
bool dequeue_head(DataSampleElement *&stale)
DataSampleElement * next_writer_sample_
DataSampleElement * previous_writer_sample_
Thread of all data within a DataWriter.
DataSampleElement * head_
The first element of the list.
DataSampleElement * tail_
The last element of the list.

◆ dequeue_head()

ACE_INLINE bool OpenDDS::DCPS::WriterDataSampleList::dequeue_head ( DataSampleElement *&  stale)

Definition at line 81 of file WriterDataSampleList.inl.

References head_, OpenDDS::DCPS::DataSampleElement::next_writer_sample_, OPENDDS_END_VERSIONED_NAMESPACE_DECL, OpenDDS::DCPS::DataSampleElement::previous_writer_sample_, size_, and tail_.

Referenced by dequeue().

82 {
83  //
84  // Remove the oldest sample from the list.
85  //
86  stale = head_;
87 
88  if (head_ == 0) {
89  return false;
90 
91  } else {
92  --size_ ;
94 
95  if (head_ == 0) {
96  tail_ = 0;
97 
98  } else {
100  }
101 
102  stale->next_writer_sample_ = 0;
103  stale->previous_writer_sample_ = 0;
104  return true;
105  }
106 }
ssize_t size_
Number of elements in the list.
DataSampleElement * next_writer_sample_
DataSampleElement * previous_writer_sample_
Thread of all data within a DataWriter.
DataSampleElement * head_
The first element of the list.
DataSampleElement * tail_
The last element of the list.

◆ enqueue_tail()

ACE_INLINE void OpenDDS::DCPS::WriterDataSampleList::enqueue_tail ( const DataSampleElement element)

Definition at line 55 of file WriterDataSampleList.inl.

References ACE_INLINE, head_, OpenDDS::DCPS::DataSampleElement::next_writer_sample_, OpenDDS::DCPS::DataSampleElement::previous_writer_sample_, size_, and tail_.

Referenced by OpenDDS::DCPS::WriteDataContainer::obtain_buffer().

56 {
57  // const_cast here so that higher layers don't need to pass around so many
58  // non-const pointers to DataSampleElement. Ideally the design would be
59  // changed to accommodate const-correctness throughout.
60  DataSampleElement* mSample = const_cast<DataSampleElement*>(sample);
61 
62  mSample->next_writer_sample_ = 0;
63 
64  ++size_ ;
65 
66  if (head_ == 0) {
67  // First sample in the list.
68  head_ = tail_ = mSample ;
69  mSample->previous_writer_sample_ = 0;
70 
71  } else {
72  // Add to existing list.
73  tail_->next_writer_sample_ = mSample ;
74  mSample->previous_writer_sample_ = tail_;
75  tail_ = mSample;
76  }
77 }
ssize_t size_
Number of elements in the list.
DataSampleElement * next_writer_sample_
DataSampleElement * previous_writer_sample_
Thread of all data within a DataWriter.
DataSampleElement * head_
The first element of the list.
DataSampleElement * tail_
The last element of the list.

◆ head()

ACE_INLINE DataSampleElement * OpenDDS::DCPS::WriterDataSampleList::head ( void  ) const

Definition at line 41 of file WriterDataSampleList.inl.

References ACE_INLINE, and head_.

Referenced by dequeue().

42 {
43  return head_;
44 }
DataSampleElement * head_
The first element of the list.

◆ reset()

ACE_INLINE void OpenDDS::DCPS::WriterDataSampleList::reset ( void  )

Reset to initial state.

Definition at line 26 of file WriterDataSampleList.inl.

References ACE_INLINE, head_, size_, and tail_.

27 {
28  head_ = tail_ = 0;
29  size_ = 0;
30 }
ssize_t size_
Number of elements in the list.
DataSampleElement * head_
The first element of the list.
DataSampleElement * tail_
The last element of the list.

◆ size()

ACE_INLINE ssize_t OpenDDS::DCPS::WriterDataSampleList::size ( void  ) const

Definition at line 34 of file WriterDataSampleList.inl.

References ACE_INLINE, and size_.

35 {
36  return size_;
37 }
ssize_t size_
Number of elements in the list.

◆ tail()

ACE_INLINE DataSampleElement * OpenDDS::DCPS::WriterDataSampleList::tail ( void  ) const

Definition at line 48 of file WriterDataSampleList.inl.

References ACE_INLINE, and tail_.

49 {
50  return tail_;
51 }
DataSampleElement * tail_
The last element of the list.

Member Data Documentation

◆ head_

DataSampleElement* OpenDDS::DCPS::WriterDataSampleList::head_
protected

The first element of the list.

Definition at line 52 of file WriterDataSampleList.h.

Referenced by dequeue(), dequeue_head(), enqueue_tail(), head(), and reset().

◆ size_

ssize_t OpenDDS::DCPS::WriterDataSampleList::size_
protected

Number of elements in the list.

Definition at line 58 of file WriterDataSampleList.h.

Referenced by dequeue(), dequeue_head(), enqueue_tail(), reset(), and size().

◆ tail_

DataSampleElement* OpenDDS::DCPS::WriterDataSampleList::tail_
protected

The last element of the list.

Definition at line 55 of file WriterDataSampleList.h.

Referenced by dequeue(), dequeue_head(), enqueue_tail(), reset(), and tail().


The documentation for this class was generated from the following files: