WriterDataSampleList.cpp

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 "DCPS/DdsDcps_pch.h" //Only the _pch include should start with DCPS/
00009 #include "WriterDataSampleList.h"
00010 #include "DataSampleElement.h"
00011 
00012 #if !defined (__ACE_INLINE__)
00013 #include "WriterDataSampleList.inl"
00014 #endif /* __ACE_INLINE__ */
00015 
00016 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
00017 
00018 namespace OpenDDS {
00019 namespace DCPS {
00020 
00021 bool
00022 WriterDataSampleList::dequeue(const DataSampleElement* stale)
00023 {
00024   if (head_ == 0) {
00025     return false;
00026   }
00027 
00028   if (stale == head_) {
00029     DataSampleElement* head = head_;
00030     return dequeue_head(head);
00031   }
00032 
00033   // Search from head_->next_writer_sample_.
00034   bool found = false;
00035 
00036   for (DataSampleElement* item = head_->next_writer_sample_ ;
00037        item != 0 ;
00038        item = item->next_writer_sample_) {
00039     if (item == stale) {
00040       found = true;
00041       break;
00042     }
00043   }
00044 
00045   if (found) {
00046     // Adjust list size.
00047     -- size_ ;
00048 
00049     //
00050     // Remove from the previous element.
00051     //
00052     if (stale->previous_writer_sample_ != 0) {
00053       // Remove from inside of the list.
00054       stale->previous_writer_sample_->next_writer_sample_ = stale->next_writer_sample_ ;
00055 
00056     } else {
00057       // Remove from the head of the list.
00058       head_ = stale->next_writer_sample_ ;
00059 
00060       if (head_ != 0) {
00061         head_->previous_writer_sample_ = 0;
00062       }
00063     }
00064 
00065     //
00066     // Remove from the next element.
00067     //
00068     if (stale->next_writer_sample_ != 0) {
00069       // Remove the inside of the list.
00070       stale->next_writer_sample_->previous_writer_sample_ = stale->previous_writer_sample_ ;
00071 
00072     } else {
00073       // Remove from the tail of the list.
00074       tail_ = stale->previous_writer_sample_ ;
00075     }
00076 
00077     stale->next_writer_sample_ = 0;
00078     stale->previous_writer_sample_ = 0;
00079   }
00080 
00081   return found;
00082 }
00083 
00084 
00085 } // namespace DCPS
00086 } // namespace OpenDDS
00087 
00088 OPENDDS_END_VERSIONED_NAMESPACE_DECL
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 10 Aug 2018 for OpenDDS by  doxygen 1.6.1