TransportSendControlElement.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_TRANSPORTSENDCONTROLELEMENT_H
00009 #define OPENDDS_DCPS_TRANSPORTSENDCONTROLELEMENT_H
00010 
00011 #include "dds/DCPS/dcps_export.h"
00012 #include "dds/DCPS/GuidUtils.h"
00013 #include "dds/DCPS/DataSampleHeader.h"
00014 #include "TransportDefs.h"
00015 #include "TransportQueueElement.h"
00016 
00017 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00018 class ACE_Message_Block;
00019 ACE_END_VERSIONED_NAMESPACE_DECL
00020 
00021 namespace OpenDDS {
00022 namespace DCPS {
00023 
00024 class TransportSendListener;
00025 
00026 class TransportSendControlElement;
00027 
00028 typedef Cached_Allocator_With_Overflow<TransportSendControlElement, ACE_SYNCH_NULL_MUTEX>
00029 TransportSendControlElementAllocator;
00030 
00031 class OpenDDS_Dcps_Export TransportSendControlElement : public TransportQueueElement {
00032 public:
00033 
00034   TransportSendControlElement(int initial_count,
00035                               const RepoId& publisher_id,
00036                               TransportSendListener* listener,
00037                               const DataSampleHeader& header,
00038                               ACE_Message_Block* msg_block,
00039                               TransportSendControlElementAllocator* allocator = 0);
00040 
00041   TransportSendControlElement(int initial_count,
00042                               const DataSampleElement* dcps_elem,
00043                               TransportSendControlElementAllocator* allocator);
00044 
00045   static TransportSendControlElement* alloc(int initial_count,
00046                                             const RepoId& publisher_id,
00047                                             TransportSendListener* listener,
00048                                             const DataSampleHeader& header,
00049                                             ACE_Message_Block* message,
00050                                             TransportSendControlElementAllocator* allocator);
00051 
00052   static TransportSendControlElement* alloc(int initial_count,
00053                                             const DataSampleElement* dcps_elem,
00054                                             TransportSendControlElementAllocator* allocator);
00055 
00056   virtual ~TransportSendControlElement();
00057 
00058   /// Overriden to always return true for Send Control elements.
00059   virtual bool requires_exclusive_packet() const;
00060 
00061   /// Accessor for the publisher id.
00062   virtual RepoId publication_id() const;
00063 
00064   /// Accessor for the ACE_Message_Block
00065   virtual const ACE_Message_Block* msg() const;
00066 
00067   const DataSampleHeader& header() const { return this->header_; }
00068   // Only allow const access to the header.  Modifying the header
00069   // would require remarshaling.
00070   //DataSampleHeader& header() { return this->header_; }
00071 
00072   const TransportSendListener* listener() const { return listener_; }
00073 
00074   virtual const ACE_Message_Block* msg_payload() const;
00075 
00076   virtual SequenceNumber sequence() const;
00077 
00078   /// Is the element a "control" sample from the specified pub_id?
00079   virtual bool is_control(RepoId pub_id) const;
00080   virtual bool owned_by_transport ();
00081 
00082 protected:
00083 
00084   virtual void release_element(bool dropped_by_transport);
00085 
00086 private:
00087 
00088   /// The publisher of the control message
00089   RepoId publisher_id_;
00090 
00091   /// The TransportSendListener object to call back upon.
00092   TransportSendListener* listener_;
00093 
00094   /// The OpenDDS DCPS header for this control message
00095   DataSampleHeader header_;
00096 
00097   /// The control message.
00098   ACE_Message_Block* msg_;
00099 
00100   /// If constructed from a DataSampleElement, keep it around for release
00101   const DataSampleElement* const dcps_elem_;
00102 
00103   /// Reference to the TransportSendControlElement
00104   /// allocator.
00105   TransportSendControlElementAllocator* allocator_;
00106 };
00107 
00108 } // namespace DCPS
00109 } // namespace OpenDDS
00110 
00111 #if defined (__ACE_INLINE__)
00112 #include "TransportSendControlElement.inl"
00113 #endif /* __ACE_INLINE__ */
00114 
00115 #endif  /* OPENDDS_DCPS_TRANSPORTSENDCONTROLELEMENT_H */

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