SendStateDataSampleList.inl

Go to the documentation of this file.
00001 /*
00002  *
00003  *
00004  * Distributed under the OpenDDS License.
00005  * See: http://www.opendds.org/license.html
00006  */
00007 
00008 #include "DataSampleElement.h"
00009 #include <algorithm>
00010 
00011 namespace OpenDDS {
00012 namespace DCPS {
00013 
00014 
00015 ACE_INLINE
00016 SendStateDataSampleList::SendStateDataSampleList()
00017   : head_(0),
00018     tail_(0),
00019     size_(0)
00020 {
00021 }
00022 
00023 ACE_INLINE
00024 void SendStateDataSampleList::reset()
00025 {
00026   head_ = tail_ = 0;
00027   size_ = 0;
00028 }
00029 
00030 ACE_INLINE
00031 ssize_t
00032 SendStateDataSampleList::size() const
00033 {
00034   return size_;
00035 }
00036 
00037 ACE_INLINE
00038 DataSampleElement*
00039 SendStateDataSampleList::head() const
00040 {
00041   return head_;
00042 }
00043 
00044 ACE_INLINE
00045 DataSampleElement*
00046 SendStateDataSampleList::tail() const
00047 {
00048   return tail_;
00049 }
00050 
00051 ACE_INLINE
00052 void
00053 SendStateDataSampleList::enqueue_tail(const DataSampleElement* sample)
00054 {
00055   ++size_;
00056 
00057   // const_cast here so that higher layers don't need to pass around so many
00058   // non-const pointers to DataSampleElement.  Ideally the design would be
00059   // changed to accommodate const-correctness throughout.
00060   DataSampleElement* mSample = const_cast<DataSampleElement*>(sample);
00061 
00062   if (head_ == 0) {
00063     // First sample in list.
00064     head_ = tail_ = mSample;
00065 
00066   } else {
00067     // Add to existing list.
00068     //sample->previous_writer_sample_ = tail_;
00069     //tail_->next_writer_sample_ = sample;
00070     mSample->previous_send_sample_ = tail_;
00071     tail_->next_send_sample_ = mSample;
00072     tail_ = mSample;
00073   }
00074 }
00075 
00076 ACE_INLINE
00077 bool
00078 SendStateDataSampleList::dequeue_head(DataSampleElement*& stale)
00079 {
00080   //
00081   // Remove the oldest sample from the instance list.
00082   //
00083   stale = head_;
00084 
00085   if (head_ == 0) {
00086     return false;
00087 
00088   } else {
00089     --size_ ;
00090 
00091     head_ = head_->next_send_sample_ ;
00092 
00093     if (head_ == 0) {
00094       tail_ = 0;
00095 
00096     } else {
00097       head_->previous_send_sample_ = 0;
00098     }
00099 
00100     //else
00101     //  {
00102     //    head_->previous_writer_sample_ = 0;
00103     //  }
00104 
00105     stale->next_send_sample_ = 0 ;
00106     stale->previous_send_sample_ = 0 ;
00107 
00108     return true;
00109   }
00110 }
00111 
00112 ACE_INLINE
00113 SendStateDataSampleList::iterator
00114 SendStateDataSampleList::begin()
00115 {
00116   return iterator(this->head_, this->tail_, this->head_);
00117 }
00118 
00119 ACE_INLINE
00120 SendStateDataSampleList::iterator
00121 SendStateDataSampleList::end()
00122 {
00123   return iterator(this->head_, this->tail_, 0);
00124 }
00125 
00126 ACE_INLINE
00127 SendStateDataSampleList::const_iterator
00128 SendStateDataSampleList::begin() const
00129 {
00130   return const_iterator(this->head_, this->tail_, this->head_);
00131 }
00132 
00133 ACE_INLINE
00134 SendStateDataSampleList::const_iterator
00135 SendStateDataSampleList::end() const
00136 {
00137   return const_iterator(this->head_, this->tail_, 0);
00138 }
00139 
00140 } // namespace DCPS
00141 } // namespace OpenDDS

Generated on Fri Feb 12 20:05:26 2016 for OpenDDS by  doxygen 1.4.7