OpenDDS  Snapshot(2023/04/28-20:55)
WriterDataSampleList.inl
Go to the documentation of this file.
1 /*
2  *
3  *
4  * Distributed under the OpenDDS License.
5  * See: http://www.opendds.org/license.html
6  */
7 
8 #include "DataSampleElement.h"
9 
10 #include <algorithm>
11 
13 
14 namespace OpenDDS {
15 namespace DCPS {
16 
19  : head_(0),
20  tail_(0),
21  size_(0)
22 {
23 }
24 
27 {
28  head_ = tail_ = 0;
29  size_ = 0;
30 }
31 
33 ssize_t
35 {
36  return size_;
37 }
38 
42 {
43  return head_;
44 }
45 
49 {
50  return tail_;
51 }
52 
54 void
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 }
78 
80 bool
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 }
107 
108 
109 } // namespace DCPS
110 } // namespace OpenDDS
111 
void reset()
Reset to initial state.
ACE_Message_Block & head_
ssize_t size_
Number of elements in the list.
int ssize_t
bool dequeue_head(DataSampleElement *&stale)
size_t size_
DataSampleElement * next_writer_sample_
WriterDataSampleList()
Default constructor clears the list.
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
#define ACE_INLINE
void enqueue_tail(const DataSampleElement *element)
DataSampleElement * previous_writer_sample_
Thread of all data within a DataWriter.
DataSampleElement * head_
The first element of the list.
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28
DataSampleElement * tail_
The last element of the list.