SendStateDataSampleList.inl
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #include "DataSampleElement.h"
00009 #include <algorithm>
00010
00011 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
00012
00013 namespace OpenDDS {
00014 namespace DCPS {
00015
00016 ACE_INLINE
00017 SendStateDataSampleList::SendStateDataSampleList()
00018 : head_(0),
00019 tail_(0),
00020 size_(0)
00021 {
00022 }
00023
00024 ACE_INLINE
00025 void SendStateDataSampleList::reset()
00026 {
00027 head_ = tail_ = 0;
00028 size_ = 0;
00029 }
00030
00031 ACE_INLINE
00032 ssize_t
00033 SendStateDataSampleList::size() const
00034 {
00035 return size_;
00036 }
00037
00038 ACE_INLINE
00039 DataSampleElement*
00040 SendStateDataSampleList::head() const
00041 {
00042 return head_;
00043 }
00044
00045 ACE_INLINE
00046 DataSampleElement*
00047 SendStateDataSampleList::tail() const
00048 {
00049 return tail_;
00050 }
00051
00052 ACE_INLINE
00053 void
00054 SendStateDataSampleList::enqueue_head(const DataSampleElement* sample)
00055 {
00056 ++size_;
00057
00058
00059
00060
00061 DataSampleElement* mSample = const_cast<DataSampleElement*>(sample);
00062
00063 if (head_ == 0) {
00064 head_ = tail_ = mSample;
00065 sample->next_send_sample_ = sample->previous_send_sample_ = 0;
00066
00067 } else {
00068 sample->next_send_sample_ = head_;
00069 sample->previous_send_sample_ = 0;
00070 head_->previous_send_sample_ = mSample;
00071 head_ = mSample;
00072 }
00073 }
00074
00075 ACE_INLINE
00076 void
00077 SendStateDataSampleList::enqueue_tail(const DataSampleElement* sample)
00078 {
00079 ++size_;
00080
00081
00082
00083
00084 DataSampleElement* mSample = const_cast<DataSampleElement*>(sample);
00085
00086 if (head_ == 0) {
00087 head_ = tail_ = mSample;
00088 sample->next_send_sample_ = sample->previous_send_sample_ = 0;
00089
00090 } else {
00091 sample->previous_send_sample_ = tail_;
00092 sample->next_send_sample_ = 0;
00093 tail_->next_send_sample_ = mSample;
00094 tail_ = mSample;
00095 }
00096 }
00097
00098 ACE_INLINE
00099 bool
00100 SendStateDataSampleList::dequeue_head(DataSampleElement*& stale)
00101 {
00102
00103
00104
00105 stale = head_;
00106
00107 if (head_ == 0) {
00108 return false;
00109
00110 } else {
00111 --size_;
00112
00113 head_ = head_->next_send_sample_;
00114
00115 if (head_ == 0) {
00116 tail_ = 0;
00117
00118 } else {
00119 head_->previous_send_sample_ = 0;
00120 }
00121
00122 stale->next_send_sample_ = 0;
00123 stale->previous_send_sample_ = 0;
00124
00125 return true;
00126 }
00127 }
00128
00129 ACE_INLINE
00130 void
00131 SendStateDataSampleList::remove(DataSampleElement* stale)
00132 {
00133 if (stale->previous_send_sample_)
00134 stale->previous_send_sample_->next_send_sample_ = stale->next_send_sample_;
00135 if (stale->next_send_sample_)
00136 stale->next_send_sample_->previous_send_sample_ = stale->previous_send_sample_;
00137 }
00138
00139 ACE_INLINE
00140 SendStateDataSampleList::iterator
00141 SendStateDataSampleList::begin()
00142 {
00143 return iterator(this->head_, this->tail_, this->head_);
00144 }
00145
00146 ACE_INLINE
00147 SendStateDataSampleList::iterator
00148 SendStateDataSampleList::end()
00149 {
00150 return iterator(this->head_, this->tail_, 0);
00151 }
00152
00153 ACE_INLINE
00154 SendStateDataSampleList::const_iterator
00155 SendStateDataSampleList::begin() const
00156 {
00157 return const_iterator(this->head_, this->tail_, this->head_);
00158 }
00159
00160 ACE_INLINE
00161 SendStateDataSampleList::const_iterator
00162 SendStateDataSampleList::end() const
00163 {
00164 return const_iterator(this->head_, this->tail_, 0);
00165 }
00166
00167 ACE_INLINE
00168 SendStateDataSampleList::reverse_iterator
00169 SendStateDataSampleList::rbegin()
00170 {
00171 return reverse_iterator(end());
00172 }
00173
00174 ACE_INLINE
00175 SendStateDataSampleList::reverse_iterator
00176 SendStateDataSampleList::rend()
00177 {
00178 return reverse_iterator(begin());
00179 }
00180
00181 ACE_INLINE
00182 SendStateDataSampleList::const_reverse_iterator
00183 SendStateDataSampleList::rbegin() const
00184 {
00185 return const_reverse_iterator(end());
00186 }
00187
00188 ACE_INLINE
00189 SendStateDataSampleList::const_reverse_iterator
00190 SendStateDataSampleList::rend() const
00191 {
00192 return const_reverse_iterator(begin());
00193 }
00194
00195 }
00196 }
00197
00198 OPENDDS_END_VERSIONED_NAMESPACE_DECL