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