LCOV - code coverage report
Current view: top level - DCPS - InstanceDataSampleList.inl (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 33 0.0 %
Date: 2023-04-30 01:32:43 Functions: 0 6 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             : #include "DataSampleElement.h"
       8             : 
       9             : #include <algorithm>
      10             : 
      11             : OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
      12             : 
      13             : namespace OpenDDS {
      14             : namespace DCPS {
      15             : 
      16             : ACE_INLINE
      17           0 : InstanceDataSampleList::InstanceDataSampleList()
      18           0 :   : head_(0),
      19           0 :     tail_(0),
      20           0 :     size_(0)
      21             : {
      22           0 : }
      23             : 
      24             : ACE_INLINE
      25             : void InstanceDataSampleList::reset()
      26             : {
      27             :   head_ = tail_ = 0;
      28             :   size_ = 0;
      29             : }
      30             : 
      31             : ACE_INLINE
      32             : ssize_t
      33           0 : InstanceDataSampleList::size() const
      34             : {
      35           0 :   return size_;
      36             : }
      37             : 
      38             : ACE_INLINE
      39             : DataSampleElement*
      40             : InstanceDataSampleList::head() const
      41             : {
      42             :   return head_;
      43             : }
      44             : 
      45             : ACE_INLINE
      46             : DataSampleElement*
      47           0 : InstanceDataSampleList::tail() const
      48             : {
      49           0 :   return tail_;
      50             : }
      51             : 
      52             : ACE_INLINE
      53             : DataSampleElement*
      54             : InstanceDataSampleList::next(const DataSampleElement* iter)
      55             : {
      56             :   return iter->next_instance_sample_;
      57             : }
      58             : 
      59             : ACE_INLINE
      60             : DataSampleElement*
      61           0 : InstanceDataSampleList::prev(const DataSampleElement* iter)
      62             : {
      63           0 :   return iter->previous_instance_sample_;
      64             : }
      65             : 
      66             : ACE_INLINE
      67             : void
      68           0 : InstanceDataSampleList::enqueue_tail(const DataSampleElement* sample)
      69             : {
      70             :   // const_cast here so that higher layers don't need to pass around so many
      71             :   // non-const pointers to DataSampleElement.  Ideally the design would be
      72             :   // changed to accommodate const-correctness throughout.
      73           0 :   DataSampleElement* mSample = const_cast<DataSampleElement*>(sample);
      74             : 
      75           0 :   mSample->next_instance_sample_ = 0;
      76             : 
      77           0 :   ++size_;
      78             : 
      79           0 :   if (head_ == 0) {
      80             :     // First sample on queue.
      81           0 :     head_ = tail_ = mSample;
      82           0 :     mSample->previous_instance_sample_ = 0;
      83             : 
      84             :   } else {
      85             :     // Another sample on an existing queue.
      86           0 :     tail_->next_instance_sample_ = mSample;
      87           0 :     mSample->previous_instance_sample_ = tail_;
      88           0 :     tail_ = mSample;
      89             :   }
      90           0 : }
      91             : 
      92             : ACE_INLINE
      93             : bool
      94           0 : InstanceDataSampleList::dequeue_head(DataSampleElement*& stale)
      95             : {
      96             :   //
      97             :   // Remove the oldest sample from the instance list.
      98             :   //
      99           0 :   stale = head_;
     100             : 
     101           0 :   if (head_ == 0) {
     102             :     // try to dequeue empty instance list.
     103           0 :     return false;
     104             : 
     105             :   } else {
     106           0 :     --size_;
     107           0 :     head_ = head_->next_instance_sample_;
     108             : 
     109           0 :     if (head_ == 0) {
     110           0 :       tail_ = 0;
     111             :     } else {
     112           0 :       head_->previous_instance_sample_ = 0;
     113             :     }
     114             : 
     115           0 :     stale->next_instance_sample_ = 0;
     116           0 :     return true;
     117             :   }
     118             : }
     119             : 
     120             : } // namespace DCPS
     121             : } // namespace OpenDDS
     122             : 
     123             : OPENDDS_END_VERSIONED_NAMESPACE_DECL

Generated by: LCOV version 1.16