#include <WriterDataSampleList.h>
Public Member Functions | |
WriterDataSampleList () | |
Default constructor clears the list. | |
~WriterDataSampleList () | |
void | reset () |
Reset to initial state. | |
ssize_t | size () const |
DataSampleElement * | head () const |
DataSampleElement * | tail () const |
void | enqueue_tail (const DataSampleElement *element) |
bool | dequeue_head (DataSampleElement *&stale) |
bool | dequeue (const DataSampleElement *stale) |
Protected Attributes | |
DataSampleElement * | head_ |
The first element of the list. | |
DataSampleElement * | tail_ |
The last element of the list. | |
ssize_t | size_ |
Number of elements in the list. |
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 28 of file WriterDataSampleList.h.
ACE_INLINE OpenDDS::DCPS::WriterDataSampleList::WriterDataSampleList | ( | ) |
Default constructor clears the list.
Definition at line 17 of file WriterDataSampleList.inl.
OpenDDS::DCPS::WriterDataSampleList::~WriterDataSampleList | ( | ) | [inline] |
Definition at line 34 of file WriterDataSampleList.h.
bool OpenDDS::DCPS::WriterDataSampleList::dequeue | ( | const DataSampleElement * | stale | ) |
Definition at line 22 of file WriterDataSampleList.cpp.
References dequeue_head(), head(), head_, item(), OpenDDS::DCPS::DataSampleElement::next_writer_sample_, OpenDDS::DCPS::DataSampleElement::previous_writer_sample_, size_, and tail_.
Referenced by OpenDDS::DCPS::WriteDataContainer::release_buffer().
00023 { 00024 if (head_ == 0) { 00025 return false; 00026 } 00027 00028 if (stale == head_) { 00029 DataSampleElement* head = head_; 00030 return dequeue_head(head); 00031 } 00032 00033 // Search from head_->next_writer_sample_. 00034 bool found = false; 00035 00036 for (DataSampleElement* item = head_->next_writer_sample_ ; 00037 item != 0 ; 00038 item = item->next_writer_sample_) { 00039 if (item == stale) { 00040 found = true; 00041 break; 00042 } 00043 } 00044 00045 if (found) { 00046 // Adjust list size. 00047 -- size_ ; 00048 00049 // 00050 // Remove from the previous element. 00051 // 00052 if (stale->previous_writer_sample_ != 0) { 00053 // Remove from inside of the list. 00054 stale->previous_writer_sample_->next_writer_sample_ = stale->next_writer_sample_ ; 00055 00056 } else { 00057 // Remove from the head of the list. 00058 head_ = stale->next_writer_sample_ ; 00059 00060 if (head_ != 0) { 00061 head_->previous_writer_sample_ = 0; 00062 } 00063 } 00064 00065 // 00066 // Remove from the next element. 00067 // 00068 if (stale->next_writer_sample_ != 0) { 00069 // Remove the inside of the list. 00070 stale->next_writer_sample_->previous_writer_sample_ = stale->previous_writer_sample_ ; 00071 00072 } else { 00073 // Remove from the tail of the list. 00074 tail_ = stale->previous_writer_sample_ ; 00075 } 00076 00077 stale->next_writer_sample_ = 0; 00078 stale->previous_writer_sample_ = 0; 00079 } 00080 00081 return found; 00082 }
ACE_INLINE bool OpenDDS::DCPS::WriterDataSampleList::dequeue_head | ( | DataSampleElement *& | stale | ) |
Definition at line 80 of file WriterDataSampleList.inl.
References head_, OpenDDS::DCPS::DataSampleElement::next_writer_sample_, OpenDDS::DCPS::DataSampleElement::previous_writer_sample_, size_, and tail_.
Referenced by dequeue().
00081 { 00082 // 00083 // Remove the oldest sample from the list. 00084 // 00085 stale = head_; 00086 00087 if (head_ == 0) { 00088 return false; 00089 00090 } else { 00091 --size_ ; 00092 head_ = head_->next_writer_sample_; 00093 00094 if (head_ == 0) { 00095 tail_ = 0; 00096 00097 } else { 00098 head_->previous_writer_sample_ = 0; 00099 } 00100 00101 stale->next_writer_sample_ = 0; 00102 stale->previous_writer_sample_ = 0; 00103 return true; 00104 } 00105 }
ACE_INLINE void OpenDDS::DCPS::WriterDataSampleList::enqueue_tail | ( | const DataSampleElement * | element | ) |
Definition at line 54 of file WriterDataSampleList.inl.
References head_, OpenDDS::DCPS::DataSampleElement::next_writer_sample_, OpenDDS::DCPS::DataSampleElement::previous_writer_sample_, size_, and tail_.
Referenced by OpenDDS::DCPS::WriteDataContainer::obtain_buffer().
00055 { 00056 // const_cast here so that higher layers don't need to pass around so many 00057 // non-const pointers to DataSampleElement. Ideally the design would be 00058 // changed to accommodate const-correctness throughout. 00059 DataSampleElement* mSample = const_cast<DataSampleElement*>(sample); 00060 00061 //sample->previous_writer_sample_ = 0; 00062 //sample->next_writer_sample_ = 0; 00063 00064 ++size_ ; 00065 00066 if (head_ == 0) { 00067 // First sample in the list. 00068 head_ = tail_ = mSample ; 00069 00070 } else { 00071 // Add to existing list. 00072 tail_->next_writer_sample_ = mSample ; 00073 mSample->previous_writer_sample_ = tail_; 00074 tail_ = mSample; 00075 } 00076 }
ACE_INLINE DataSampleElement * OpenDDS::DCPS::WriterDataSampleList::head | ( | void | ) | const |
Definition at line 40 of file WriterDataSampleList.inl.
References head_.
Referenced by dequeue().
00041 { 00042 return head_; 00043 }
ACE_INLINE void OpenDDS::DCPS::WriterDataSampleList::reset | ( | void | ) |
ACE_INLINE ssize_t OpenDDS::DCPS::WriterDataSampleList::size | ( | void | ) | const |
Definition at line 33 of file WriterDataSampleList.inl.
References size_.
00034 { 00035 return size_; 00036 }
ACE_INLINE DataSampleElement * OpenDDS::DCPS::WriterDataSampleList::tail | ( | void | ) | const |
Definition at line 47 of file WriterDataSampleList.inl.
References tail_.
00048 { 00049 return tail_; 00050 }
The first element of the list.
Definition at line 52 of file WriterDataSampleList.h.
Referenced by dequeue(), dequeue_head(), enqueue_tail(), head(), and reset().
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().
The last element of the list.
Definition at line 55 of file WriterDataSampleList.h.
Referenced by dequeue(), dequeue_head(), enqueue_tail(), reset(), and tail().