00001
00002
00003
00004
00005
00006
00007
00008 #include "DCPS/DdsDcps_pch.h"
00009 #include "SendStateDataSampleList.h"
00010 #include "DataSampleElement.h"
00011 #include "Definitions.h"
00012 #include "PublicationInstance.h"
00013
00014 #include "dds/DCPS/transport/framework/TransportSendListener.h"
00015
00016 #if !defined (__ACE_INLINE__)
00017 #include "SendStateDataSampleList.inl"
00018 #endif
00019
00020 namespace OpenDDS {
00021 namespace DCPS {
00022
00023
00024 const SendStateDataSampleList*
00025 SendStateDataSampleList::send_list_containing_element(const DataSampleElement* element,
00026 OPENDDS_VECTOR(SendStateDataSampleList*) send_lists)
00027 {
00028 DataSampleElement* head = const_cast<DataSampleElement*>(element);
00029
00030 while (head->previous_send_sample_ != 0) {
00031 head = head->previous_send_sample_;
00032 }
00033
00034 SendStateDataSampleList* list_containing_element = 0;
00035
00036 for(OPENDDS_VECTOR(SendStateDataSampleList*)::iterator it = send_lists.begin(); it != send_lists.end(); ++it) {
00037 if ((*it)->head_ == head) {
00038 list_containing_element = *it;
00039 break;
00040 }
00041 }
00042 return list_containing_element;
00043 }
00044
00045
00046 bool
00047 SendStateDataSampleList::dequeue(const DataSampleElement* stale)
00048 {
00049 if (head_ == 0) {
00050 return false;
00051 }
00052
00053
00054 if (stale == head_) {
00055 DataSampleElement* tmp = head_;
00056 return dequeue_head(tmp);
00057 }
00058
00059
00060 DataSampleElement* toRemove = 0;
00061 for (DataSampleElement* item = head_->next_send_sample_;
00062 item != 0 && toRemove == 0;
00063 item = item->next_send_sample_) {
00064 if (item == stale) {
00065 toRemove = item;
00066 }
00067 }
00068
00069 if (toRemove) {
00070 size_ --;
00071
00072 toRemove->previous_send_sample_->next_send_sample_ = toRemove->next_send_sample_ ;
00073
00074
00075 if (toRemove->next_send_sample_ != 0) {
00076
00077 toRemove->next_send_sample_->previous_send_sample_ = toRemove->previous_send_sample_ ;
00078
00079 } else {
00080 toRemove->previous_send_sample_->next_send_sample_ = 0;
00081
00082 tail_ = toRemove->previous_send_sample_ ;
00083 }
00084
00085 toRemove->next_send_sample_ = 0;
00086 toRemove->previous_send_sample_ = 0;
00087 }
00088
00089 return toRemove;
00090 }
00091
00092 void
00093 SendStateDataSampleList::enqueue_tail(SendStateDataSampleList list)
00094 {
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107 if (head_ == 0) {
00108 head_ = list.head_;
00109 tail_ = list.tail_;
00110 size_ = list.size_;
00111
00112 } else {
00113 tail_->next_send_sample_
00114
00115 = list.head_;
00116 list.head_->previous_send_sample_ = tail_;
00117
00118 tail_ = list.tail_;
00119 size_ = size_ + list.size_;
00120 }
00121 }
00122
00123
00124
00125 SendStateDataSampleListIterator::SendStateDataSampleListIterator(
00126 DataSampleElement* head,
00127 DataSampleElement* tail,
00128 DataSampleElement* current)
00129 : head_(head)
00130 , tail_(tail)
00131 , current_(current)
00132 {
00133 }
00134
00135 SendStateDataSampleListIterator&
00136 SendStateDataSampleListIterator::operator++()
00137 {
00138 if (this->current_)
00139 this->current_ = this->current_->next_send_sample_;
00140
00141 return *this;
00142 }
00143
00144 SendStateDataSampleListIterator
00145 SendStateDataSampleListIterator::operator++(int)
00146 {
00147 SendStateDataSampleListIterator tmp(*this);
00148 ++(*this);
00149 return tmp;
00150 }
00151
00152 SendStateDataSampleListIterator&
00153 SendStateDataSampleListIterator::operator--()
00154 {
00155 if (this->current_)
00156 this->current_ = this->current_->previous_send_sample_;
00157
00158 else
00159 this->current_ = this->tail_;
00160
00161 return *this;
00162 }
00163
00164 SendStateDataSampleListIterator
00165 SendStateDataSampleListIterator::operator--(int)
00166 {
00167 SendStateDataSampleListIterator tmp(*this);
00168 --(*this);
00169 return tmp;
00170 }
00171
00172 SendStateDataSampleListIterator::reference
00173 SendStateDataSampleListIterator::operator*()
00174 {
00175
00176
00177
00178
00179
00180 return *(this->current_);
00181 }
00182
00183 SendStateDataSampleListIterator::pointer
00184 SendStateDataSampleListIterator::operator->()
00185 {
00186 return this->current_;
00187 }
00188
00189 SendStateDataSampleListConstIterator::SendStateDataSampleListConstIterator(
00190 const DataSampleElement* head,
00191 const DataSampleElement* tail,
00192 const DataSampleElement* current)
00193 : head_(head)
00194 , tail_(tail)
00195 , current_(current)
00196 {
00197 }
00198
00199 SendStateDataSampleListConstIterator::SendStateDataSampleListConstIterator(
00200 const SendStateDataSampleListIterator& iterator)
00201 : head_(iterator.head_)
00202 , tail_(iterator.tail_)
00203 , current_(iterator.current_)
00204 {
00205 }
00206
00207 SendStateDataSampleListConstIterator&
00208 SendStateDataSampleListConstIterator::operator++()
00209 {
00210 if (this->current_)
00211 this->current_ = this->current_->next_send_sample_;
00212
00213 return *this;
00214 }
00215
00216 SendStateDataSampleListConstIterator
00217 SendStateDataSampleListConstIterator::operator++(int)
00218 {
00219 SendStateDataSampleListConstIterator tmp(*this);
00220 ++(*this);
00221 return tmp;
00222 }
00223
00224 SendStateDataSampleListConstIterator&
00225 SendStateDataSampleListConstIterator::operator--()
00226 {
00227 if (this->current_)
00228 this->current_ = this->current_->previous_send_sample_;
00229
00230 else
00231 this->current_ = this->tail_;
00232
00233 return *this;
00234 }
00235
00236 SendStateDataSampleListConstIterator
00237 SendStateDataSampleListConstIterator::operator--(int)
00238 {
00239 SendStateDataSampleListConstIterator tmp(*this);
00240 --(*this);
00241 return tmp;
00242 }
00243
00244 SendStateDataSampleListConstIterator::reference
00245 SendStateDataSampleListConstIterator::operator*() const
00246 {
00247
00248
00249
00250
00251
00252 return *(this->current_);
00253 }
00254
00255 SendStateDataSampleListConstIterator::pointer
00256 SendStateDataSampleListConstIterator::operator->() const
00257 {
00258 return this->current_;
00259 }
00260
00261 }
00262 }