SendStateDataSampleList.h

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 #ifndef OPENDDS_DCPS_SENDSTATEDATASAMPLELIST_H
00009 #define OPENDDS_DCPS_SENDSTATEDATASAMPLELIST_H
00010 
00011 #include "dds/DdsDcpsInfoUtilsC.h"
00012 #include "PoolAllocator.h"
00013 #include "Definitions.h"
00014 #include "transport/framework/TransportDefs.h"
00015 #include "Dynamic_Cached_Allocator_With_Overflow_T.h"
00016 
00017 #include <iterator>
00018 
00019 class DDS_TEST;
00020 
00021 namespace OpenDDS {
00022 namespace DCPS {
00023 
00024 class DataSampleElement;
00025 
00026 const int MAX_READERS_TO_RESEND = 5;
00027 
00028 /**
00029  * @struct SendStateDataSampleListIterator
00030  *
00031  * @brief @c SendStateDataSampleList STL-style iterator implementation.
00032  *
00033  * This class implements a STL-style iterator for the OpenDDS
00034  * @c SendStateDataSampleList class.  The resulting iterator may be used
00035  * @c with the STL generic algorithms.  It is meant for iteration
00036  * @c over the "send samples" in a @c SendStateDataSampleList.
00037  */
00038 class OpenDDS_Dcps_Export SendStateDataSampleListIterator
00039   : public std::iterator<std::bidirectional_iterator_tag, DataSampleElement>
00040 {
00041 public:
00042 
00043   /// Default constructor.
00044   /**
00045    * This constructor is used when constructing an "end" iterator.
00046    */
00047 
00048   SendStateDataSampleListIterator(DataSampleElement* head,
00049                          DataSampleElement* tail,
00050                          DataSampleElement* current);
00051 
00052   SendStateDataSampleListIterator& operator++();
00053   SendStateDataSampleListIterator  operator++(int);
00054   SendStateDataSampleListIterator& operator--();
00055   SendStateDataSampleListIterator  operator--(int);
00056 
00057   reference operator*();
00058   pointer operator->();
00059 
00060   bool
00061   operator==(const SendStateDataSampleListIterator& rhs) const {
00062     return this->head_ == rhs.head_
00063            && this->tail_ == rhs.tail_
00064            && this->current_ == rhs.current_;
00065   }
00066 
00067   bool
00068   operator!=(const SendStateDataSampleListIterator& rhs) const {
00069     return !(*this == rhs);
00070   }
00071 
00072 private:
00073   SendStateDataSampleListIterator();
00074 
00075   DataSampleElement* head_;
00076   DataSampleElement* tail_;
00077   DataSampleElement* current_;
00078 
00079   friend class SendStateDataSampleListConstIterator;
00080 };
00081 
00082 /**
00083  * @struct SendStateDataSampleListConstIterator
00084  *
00085  * @brief @c SendStateDataSampleList STL-style const iterator implementation.
00086  *
00087  * This class implements a STL-style const iterator for the OpenDDS
00088  * @c SendStateDataSampleList class.  The resulting iterator may be used
00089  * @c with the STL generic algorithms.  It is meant for iteration
00090  * @c over the "send samples" in a @c SendStateDataSampleList.
00091  */
00092 class OpenDDS_Dcps_Export SendStateDataSampleListConstIterator
00093 {
00094 public:
00095   typedef const DataSampleElement* pointer;
00096   typedef const DataSampleElement& reference;
00097 
00098 
00099   SendStateDataSampleListConstIterator(const DataSampleElement* head,
00100                                   const DataSampleElement* tail,
00101                                   const DataSampleElement* current);
00102 
00103   SendStateDataSampleListConstIterator(const SendStateDataSampleListIterator& iterator);
00104 
00105   SendStateDataSampleListConstIterator& operator++();
00106   SendStateDataSampleListConstIterator  operator++(int);
00107   SendStateDataSampleListConstIterator& operator--();
00108   SendStateDataSampleListConstIterator  operator--(int);
00109   reference operator*() const;
00110   pointer operator->() const;
00111 
00112   bool
00113   operator==(const SendStateDataSampleListConstIterator& rhs) const {
00114     return this->head_ == rhs.head_
00115            && this->tail_ == rhs.tail_
00116            && this->current_ == rhs.current_;
00117   }
00118 
00119   bool
00120   operator!=(const SendStateDataSampleListConstIterator& rhs) const {
00121     return !(*this == rhs);
00122   }
00123 
00124 private:
00125   SendStateDataSampleListConstIterator();
00126 
00127   const DataSampleElement* head_;
00128   const DataSampleElement* tail_;
00129   const DataSampleElement* current_;
00130 
00131 };
00132 
00133 /**
00134 * A list of DataSampleElement pointers to be queued by the order the
00135 * samples are to be transmitted over the transport layer.
00136 * Cache the number of elements in the list so that list traversal is
00137 * not required to find this information.
00138 * The Publisher may use this to maintain a list of samples to
00139 * be sent with PRESENTATION.access_scope==GROUP by obtaining
00140 * data from each DataWriter as it becomes available and
00141 * concatenating the data in the order in which it was written.
00142 * Manages DataSampleElement's previous_send_sample/next_send_sample pointers
00143 */
00144 class OpenDDS_Dcps_Export SendStateDataSampleList {
00145 
00146   friend class ::DDS_TEST;
00147 
00148  public:
00149 
00150   /// STL-style bidirectional iterator and const-iterator types.
00151   typedef SendStateDataSampleListIterator iterator;
00152   typedef SendStateDataSampleListConstIterator const_iterator;
00153 
00154   /// Default constructor clears the list.
00155   SendStateDataSampleList();
00156   ~SendStateDataSampleList(){};
00157 
00158   /// Returns a pointer to the SendStateDataSampleList containing a
00159   /// given DataSampleElement for use in the typical situation where
00160   /// the send state of a DataSampleElement is tracked by shifting
00161   /// it between distinct SendStateDataSampleLists, one for each state
00162   static const SendStateDataSampleList* send_list_containing_element(const DataSampleElement* element,
00163                                                                 OPENDDS_VECTOR(SendStateDataSampleList*) send_lists);
00164 
00165   /// Reset to initial state.
00166   void reset();
00167 
00168   ssize_t size() const;
00169   DataSampleElement* head() const;
00170   DataSampleElement* tail() const;
00171 
00172   void enqueue_tail(const DataSampleElement* element);
00173   void enqueue_tail(SendStateDataSampleList list);
00174 
00175   bool dequeue_head(DataSampleElement*& stale);
00176 
00177   bool dequeue(const DataSampleElement* stale);
00178 
00179   /// Return iterator to beginning of list.
00180   iterator begin();
00181   const_iterator begin() const;
00182 
00183   /// Return iterator to end of list.
00184   iterator end();
00185   const_iterator end() const;
00186 
00187  protected:
00188 
00189    /// The first element of the list.
00190    DataSampleElement* head_;
00191 
00192    /// The last element of the list.
00193    DataSampleElement* tail_;
00194 
00195    /// Number of elements in the list.
00196    ssize_t                size_;
00197    //TBD size is never negative so should be size_t but this ripples through
00198    // the transport code so leave it for now. SHH
00199 
00200 };
00201 
00202 } // namespace DCPS
00203 } // namespace OpenDDS
00204 
00205 #if defined(__ACE_INLINE__)
00206 #include "SendStateDataSampleList.inl"
00207 #endif /* __ACE_INLINE__ */
00208 
00209 #endif  /* OPENDDS_DCPS_SENDSTATEDATASAMPLELIST_H */

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