#include <InstanceDataSampleList.h>
Collaboration diagram for OpenDDS::DCPS::InstanceDataSampleList:
Public Member Functions | |
InstanceDataSampleList () | |
Default constructor clears the list. | |
~InstanceDataSampleList () | |
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 32 of file InstanceDataSampleList.h.
ACE_INLINE OpenDDS::DCPS::InstanceDataSampleList::InstanceDataSampleList | ( | ) |
OpenDDS::DCPS::InstanceDataSampleList::~InstanceDataSampleList | ( | ) | [inline] |
bool OpenDDS::DCPS::InstanceDataSampleList::dequeue | ( | const DataSampleElement * | stale | ) |
Definition at line 25 of file InstanceDataSampleList.cpp.
References dequeue_head(), head_, OpenDDS::DCPS::DataSampleElement::next_instance_sample_, size_, and tail_.
00026 { 00027 if (head_ == 0) { 00028 return false; 00029 } 00030 00031 // Same as dequeue from head. 00032 if (stale == head_) { 00033 DataSampleElement* tmp = head_; 00034 return dequeue_head(tmp); 00035 } 00036 00037 // Search from head_->next_instance_sample_. 00038 DataSampleElement* previous = head_; 00039 DataSampleElement* item; 00040 for (item = head_->next_instance_sample_; 00041 item != 0; 00042 item = item->next_instance_sample_) { 00043 if (item == stale) { 00044 previous->next_instance_sample_ = item->next_instance_sample_; 00045 if (previous->next_instance_sample_ == 0) { 00046 tail_ = previous; 00047 } 00048 --size_ ; 00049 item->next_instance_sample_ = 0; 00050 break; 00051 } 00052 00053 previous = item; 00054 } 00055 00056 return item; 00057 }
ACE_INLINE bool OpenDDS::DCPS::InstanceDataSampleList::dequeue_head | ( | DataSampleElement *& | stale | ) |
Definition at line 76 of file InstanceDataSampleList.inl.
References head_, OpenDDS::DCPS::DataSampleElement::next_instance_sample_, size_, and tail_.
Referenced by dequeue(), OpenDDS::DCPS::WriteDataContainer::remove_oldest_historical_sample(), and OpenDDS::DCPS::WriteDataContainer::remove_oldest_sample().
00077 { 00078 // 00079 // Remove the oldest sample from the instance list. 00080 // 00081 stale = head_; 00082 00083 if (head_ == 0) { 00084 // try to dequeue empty instance list. 00085 return false; 00086 00087 } else { 00088 --size_ ; 00089 head_ = head_->next_instance_sample_ ; 00090 00091 if (head_ == 0) { 00092 tail_ = 0; 00093 } 00094 00095 stale->next_instance_sample_ = 0; 00096 return true; 00097 } 00098 }
ACE_INLINE void OpenDDS::DCPS::InstanceDataSampleList::enqueue_tail | ( | const DataSampleElement * | element | ) |
Definition at line 52 of file InstanceDataSampleList.inl.
References head_, OpenDDS::DCPS::DataSampleElement::next_instance_sample_, size_, and tail_.
Referenced by OpenDDS::DCPS::WriteDataContainer::enqueue().
00053 { 00054 // const_cast here so that higher layers don't need to pass around so many 00055 // non-const pointers to DataSampleElement. Ideally the design would be 00056 // changed to accommodate const-correctness throughout. 00057 DataSampleElement* mSample = const_cast<DataSampleElement*>(sample); 00058 00059 mSample->next_instance_sample_ = 0; 00060 00061 ++ size_ ; 00062 00063 if (head_ == 0) { 00064 // First sample on queue. 00065 head_ = tail_ = mSample ; 00066 00067 } else { 00068 // Another sample on an existing queue. 00069 tail_->next_instance_sample_ = mSample ; 00070 tail_ = mSample ; 00071 } 00072 }
ACE_INLINE DataSampleElement * OpenDDS::DCPS::InstanceDataSampleList::head | ( | ) | const |
Definition at line 38 of file InstanceDataSampleList.inl.
References head_.
Referenced by OpenDDS::DCPS::WriteDataContainer::remove_oldest_historical_sample().
00039 { 00040 return head_; 00041 }
ACE_INLINE void OpenDDS::DCPS::InstanceDataSampleList::reset | ( | ) |
ACE_INLINE ssize_t OpenDDS::DCPS::InstanceDataSampleList::size | ( | ) | const |
Definition at line 31 of file InstanceDataSampleList.inl.
References size_.
Referenced by OpenDDS::DCPS::WriteDataContainer::dispose(), and OpenDDS::DCPS::WriteDataContainer::num_samples().
00032 { 00033 return size_; 00034 }
ACE_INLINE DataSampleElement * OpenDDS::DCPS::InstanceDataSampleList::tail | ( | ) | const |
Definition at line 45 of file InstanceDataSampleList.inl.
References tail_.
00046 { 00047 return tail_; 00048 }
The first element of the list.
Definition at line 56 of file InstanceDataSampleList.h.
Referenced by dequeue(), dequeue_head(), enqueue_tail(), head(), and reset().
ssize_t OpenDDS::DCPS::InstanceDataSampleList::size_ [protected] |
Number of elements in the list.
Definition at line 62 of file InstanceDataSampleList.h.
Referenced by dequeue(), dequeue_head(), enqueue_tail(), reset(), and size().
The last element of the list.
Definition at line 59 of file InstanceDataSampleList.h.
Referenced by dequeue(), dequeue_head(), enqueue_tail(), reset(), and tail().