OpenDDS  Snapshot(2023/04/28-20:55)
InstanceDataSampleList.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 #include "DataSampleElement.h"
8 
9 #include <algorithm>
10 
12 
13 namespace OpenDDS {
14 namespace DCPS {
15 
18  : head_(0),
19  tail_(0),
20  size_(0)
21 {
22 }
23 
26 {
27  head_ = tail_ = 0;
28  size_ = 0;
29 }
30 
32 ssize_t
34 {
35  return size_;
36 }
37 
41 {
42  return head_;
43 }
44 
48 {
49  return tail_;
50 }
51 
55 {
56  return iter->next_instance_sample_;
57 }
58 
62 {
63  return iter->previous_instance_sample_;
64 }
65 
67 void
69 {
70  // const_cast here so that higher layers don't need to pass around so many
71  // non-const pointers to DataSampleElement. Ideally the design would be
72  // changed to accommodate const-correctness throughout.
73  DataSampleElement* mSample = const_cast<DataSampleElement*>(sample);
74 
75  mSample->next_instance_sample_ = 0;
76 
77  ++size_;
78 
79  if (head_ == 0) {
80  // First sample on queue.
81  head_ = tail_ = mSample;
82  mSample->previous_instance_sample_ = 0;
83 
84  } else {
85  // Another sample on an existing queue.
86  tail_->next_instance_sample_ = mSample;
88  tail_ = mSample;
89  }
90 }
91 
93 bool
95 {
96  //
97  // Remove the oldest sample from the instance list.
98  //
99  stale = head_;
100 
101  if (head_ == 0) {
102  // try to dequeue empty instance list.
103  return false;
104 
105  } else {
106  --size_;
108 
109  if (head_ == 0) {
110  tail_ = 0;
111  } else {
113  }
114 
115  stale->next_instance_sample_ = 0;
116  return true;
117  }
118 }
119 
120 } // namespace DCPS
121 } // namespace OpenDDS
122 
DataSampleElement * head_
The first element of the list.
DataSampleElement * tail_
The last element of the list.
ACE_Message_Block & head_
ssize_t size_
Number of elements in the list.
static DataSampleElement * next(const DataSampleElement *iter)
int ssize_t
DataSampleElement * previous_instance_sample_
DataSampleElement * next_instance_sample_
Thread of data within the instance.
size_t size_
bool dequeue_head(DataSampleElement *&stale)
void enqueue_tail(const DataSampleElement *element)
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
#define ACE_INLINE
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28
static DataSampleElement * prev(const DataSampleElement *iter)