LCOV - code coverage report
Current view: top level - DCPS - WriterDataSampleList.inl (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 28 0.0 %
Date: 2023-04-30 01:32:43 Functions: 0 3 0.0 %

          Line data    Source code
       1             : /*
       2             :  *
       3             :  *
       4             :  * Distributed under the OpenDDS License.
       5             :  * See: http://www.opendds.org/license.html
       6             :  */
       7             : 
       8             : #include "DataSampleElement.h"
       9             : 
      10             : #include <algorithm>
      11             : 
      12             : OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
      13             : 
      14             : namespace OpenDDS {
      15             : namespace DCPS {
      16             : 
      17             : ACE_INLINE
      18           0 : WriterDataSampleList::WriterDataSampleList()
      19           0 :   : head_(0),
      20           0 :     tail_(0),
      21           0 :     size_(0)
      22             : {
      23           0 : }
      24             : 
      25             : ACE_INLINE
      26             : void WriterDataSampleList::reset()
      27             : {
      28             :   head_ = tail_ = 0;
      29             :   size_ = 0;
      30             : }
      31             : 
      32             : ACE_INLINE
      33             : ssize_t
      34             : WriterDataSampleList::size() const
      35             : {
      36             :   return size_;
      37             : }
      38             : 
      39             : ACE_INLINE
      40             : DataSampleElement*
      41             : WriterDataSampleList::head() const
      42             : {
      43             :   return head_;
      44             : }
      45             : 
      46             : ACE_INLINE
      47             : DataSampleElement*
      48             : WriterDataSampleList::tail() const
      49             : {
      50             :   return tail_;
      51             : }
      52             : 
      53             : ACE_INLINE
      54             : void
      55           0 : WriterDataSampleList::enqueue_tail(const DataSampleElement* sample)
      56             : {
      57             :   // const_cast here so that higher layers don't need to pass around so many
      58             :   // non-const pointers to DataSampleElement.  Ideally the design would be
      59             :   // changed to accommodate const-correctness throughout.
      60           0 :   DataSampleElement* mSample = const_cast<DataSampleElement*>(sample);
      61             : 
      62           0 :   mSample->next_writer_sample_ = 0;
      63             : 
      64           0 :   ++size_ ;
      65             : 
      66           0 :   if (head_ == 0) {
      67             :     // First sample in the list.
      68           0 :     head_ = tail_ = mSample ;
      69           0 :     mSample->previous_writer_sample_ = 0;
      70             : 
      71             :   } else {
      72             :     // Add to existing list.
      73           0 :     tail_->next_writer_sample_ = mSample ;
      74           0 :     mSample->previous_writer_sample_ = tail_;
      75           0 :     tail_ = mSample;
      76             :   }
      77           0 : }
      78             : 
      79             : ACE_INLINE
      80             : bool
      81           0 : WriterDataSampleList::dequeue_head(DataSampleElement*& stale)
      82             : {
      83             :   //
      84             :   // Remove the oldest sample from the list.
      85             :   //
      86           0 :   stale = head_;
      87             : 
      88           0 :   if (head_ == 0) {
      89           0 :     return false;
      90             : 
      91             :   } else {
      92           0 :     --size_ ;
      93           0 :     head_ = head_->next_writer_sample_;
      94             : 
      95           0 :     if (head_ == 0) {
      96           0 :       tail_ = 0;
      97             : 
      98             :     } else {
      99           0 :       head_->previous_writer_sample_ = 0;
     100             :     }
     101             : 
     102           0 :     stale->next_writer_sample_ = 0;
     103           0 :     stale->previous_writer_sample_ = 0;
     104           0 :     return true;
     105             :   }
     106             : }
     107             : 
     108             : 
     109             : } // namespace DCPS
     110             : } // namespace OpenDDS
     111             : 
     112             : OPENDDS_END_VERSIONED_NAMESPACE_DECL

Generated by: LCOV version 1.16