OpenDDS::DCPS::InstanceDataSampleList Class Reference

#include <InstanceDataSampleList.h>

Collaboration diagram for OpenDDS::DCPS::InstanceDataSampleList:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 InstanceDataSampleList ()
 Default constructor clears the list.
 ~InstanceDataSampleList ()
void reset ()
 Reset to initial state.
ssize_t size () const
DataSampleElementhead () const
DataSampleElementtail () const
void enqueue_tail (const DataSampleElement *element)
bool dequeue_head (DataSampleElement *&stale)
bool dequeue (const DataSampleElement *stale)

Protected Attributes

DataSampleElementhead_
 The first element of the list.
DataSampleElementtail_
 The last element of the list.
ssize_t size_
 Number of elements in the list.

Detailed Description

A list of DataSampleElement pointers to be queued by the order the samples are written to the instance (within PRESENTAION.access_scope==INSTANCE). It is mainly used on the send side to count the depth of instance data and to allow the removal of elements by instance. Manages DataSampleElement's next_instance_sample pointer

Definition at line 32 of file InstanceDataSampleList.h.


Constructor & Destructor Documentation

ACE_INLINE OpenDDS::DCPS::InstanceDataSampleList::InstanceDataSampleList (  ) 

Default constructor clears the list.

Definition at line 15 of file InstanceDataSampleList.inl.

00016   : head_(0),
00017     tail_(0),
00018     size_(0)
00019 {
00020 }

OpenDDS::DCPS::InstanceDataSampleList::~InstanceDataSampleList (  )  [inline]

Definition at line 38 of file InstanceDataSampleList.h.

00038 {};


Member Function Documentation

bool OpenDDS::DCPS::InstanceDataSampleList::dequeue ( const DataSampleElement stale  ) 

Definition at line 25 of file InstanceDataSampleList.cpp.

References dequeue_head(), head_, OpenDDS::DCPS::DataSampleElement::next_instance_sample_, size_, and tail_.

00026 {
00027   if (head_ == 0) {
00028     return false;
00029   }
00030 
00031   // Same as dequeue from head.
00032   if (stale == head_) {
00033     DataSampleElement* tmp = head_;
00034     return dequeue_head(tmp);
00035   }
00036 
00037   // Search from head_->next_instance_sample_.
00038   DataSampleElement* previous = head_;
00039   DataSampleElement* item;
00040   for (item = head_->next_instance_sample_;
00041        item != 0;
00042        item = item->next_instance_sample_) {
00043     if (item == stale) {
00044       previous->next_instance_sample_ = item->next_instance_sample_;
00045       if (previous->next_instance_sample_ == 0) {
00046         tail_ = previous;
00047       }
00048       --size_ ;
00049       item->next_instance_sample_ = 0;
00050       break;
00051     }
00052 
00053     previous = item;
00054   }
00055 
00056   return item;
00057 }

ACE_INLINE bool OpenDDS::DCPS::InstanceDataSampleList::dequeue_head ( DataSampleElement *&  stale  ) 

Definition at line 76 of file InstanceDataSampleList.inl.

References head_, OpenDDS::DCPS::DataSampleElement::next_instance_sample_, size_, and tail_.

Referenced by dequeue(), OpenDDS::DCPS::WriteDataContainer::remove_oldest_historical_sample(), and OpenDDS::DCPS::WriteDataContainer::remove_oldest_sample().

00077 {
00078   //
00079   // Remove the oldest sample from the instance list.
00080   //
00081   stale = head_;
00082 
00083   if (head_ == 0) {
00084     // try to dequeue empty instance list.
00085     return false;
00086 
00087   } else {
00088     --size_ ;
00089     head_ = head_->next_instance_sample_ ;
00090 
00091     if (head_ == 0) {
00092       tail_ = 0;
00093     }
00094 
00095     stale->next_instance_sample_ = 0;
00096     return true;
00097   }
00098 }

ACE_INLINE void OpenDDS::DCPS::InstanceDataSampleList::enqueue_tail ( const DataSampleElement element  ) 

Definition at line 52 of file InstanceDataSampleList.inl.

References head_, OpenDDS::DCPS::DataSampleElement::next_instance_sample_, size_, and tail_.

Referenced by OpenDDS::DCPS::WriteDataContainer::enqueue().

00053 {
00054   // const_cast here so that higher layers don't need to pass around so many
00055   // non-const pointers to DataSampleElement.  Ideally the design would be
00056   // changed to accommodate const-correctness throughout.
00057   DataSampleElement* mSample = const_cast<DataSampleElement*>(sample);
00058 
00059   mSample->next_instance_sample_ = 0;
00060 
00061   ++ size_ ;
00062 
00063   if (head_ == 0) {
00064     // First sample on queue.
00065     head_ = tail_ = mSample ;
00066 
00067   } else {
00068     // Another sample on an existing queue.
00069     tail_->next_instance_sample_ = mSample ;
00070     tail_ = mSample ;
00071   }
00072 }

ACE_INLINE DataSampleElement * OpenDDS::DCPS::InstanceDataSampleList::head (  )  const

Definition at line 38 of file InstanceDataSampleList.inl.

References head_.

Referenced by OpenDDS::DCPS::WriteDataContainer::remove_oldest_historical_sample().

00039 {
00040   return head_;
00041 }

ACE_INLINE void OpenDDS::DCPS::InstanceDataSampleList::reset (  ) 

Reset to initial state.

Definition at line 23 of file InstanceDataSampleList.inl.

References head_, size_, and tail_.

00024 {
00025   head_ = tail_ = 0;
00026   size_ = 0;
00027 }

ACE_INLINE ssize_t OpenDDS::DCPS::InstanceDataSampleList::size (  )  const

Definition at line 31 of file InstanceDataSampleList.inl.

References size_.

Referenced by OpenDDS::DCPS::WriteDataContainer::dispose(), and OpenDDS::DCPS::WriteDataContainer::num_samples().

00032 {
00033   return size_;
00034 }

ACE_INLINE DataSampleElement * OpenDDS::DCPS::InstanceDataSampleList::tail (  )  const

Definition at line 45 of file InstanceDataSampleList.inl.

References tail_.

00046 {
00047   return tail_;
00048 }


Member Data Documentation

DataSampleElement* OpenDDS::DCPS::InstanceDataSampleList::head_ [protected]

The first element of the list.

Definition at line 56 of file InstanceDataSampleList.h.

Referenced by dequeue(), dequeue_head(), enqueue_tail(), head(), and reset().

ssize_t OpenDDS::DCPS::InstanceDataSampleList::size_ [protected]

Number of elements in the list.

Definition at line 62 of file InstanceDataSampleList.h.

Referenced by dequeue(), dequeue_head(), enqueue_tail(), reset(), and size().

DataSampleElement* OpenDDS::DCPS::InstanceDataSampleList::tail_ [protected]

The last element of the list.

Definition at line 59 of file InstanceDataSampleList.h.

Referenced by dequeue(), dequeue_head(), enqueue_tail(), reset(), and tail().


The documentation for this class was generated from the following files:
Generated on Fri Feb 12 20:06:19 2016 for OpenDDS by  doxygen 1.4.7