RtpsSampleHeader.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 DCPS_RTPSSAMPLEHEADER_H
00009 #define DCPS_RTPSSAMPLEHEADER_H
00010 
00011 #include "Rtps_Udp_Export.h"
00012 
00013 #include "ace/Basic_Types.h"
00014 #include "dds/DCPS/RTPS/RtpsCoreC.h"
00015 #include "dds/DCPS/transport/framework/TransportSendControlElement.h"
00016 #include "dds/DCPS/transport/framework/TransportSendListener.h"
00017 
00018 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00019 class ACE_Message_Block;
00020 ACE_END_VERSIONED_NAMESPACE_DECL
00021 
00022 namespace OpenDDS {
00023 namespace DCPS {
00024 
00025 class ReceivedDataSample;
00026 class DataSampleElement;
00027 class DisjointSequence;
00028 
00029 /// Adapt the TransportReceiveStrategy for RTPS's "sample" (submessage) Header
00030 class OpenDDS_Rtps_Udp_Export RtpsSampleHeader {
00031 public:
00032 
00033   // This is not really the max_marshaled_size, but it's used for determining
00034   // how much of the submessage to show in debugging hexdumps.  Since we don't
00035   // know which kind of submessage we have, we can only count on the 4-byte
00036   // SubmessageHeader being present.
00037   static size_t max_marshaled_size() { return 4; }
00038 
00039   // We never have partial "sample" headers since this is UDP.
00040   // (The header could fail to parse in init(), but unlike the TCP case we
00041   // never want to go back to the reactor and wait for more bytes to arrive.)
00042   static bool partial(const ACE_Message_Block&) { return false; }
00043 
00044   /// Create two new serialized headers (owned by caller), the "head" having at
00045   /// most "size" bytes (header + data) and the "tail" having the rest.
00046   /// Returns a pair containing the largest fragment number in each new header.
00047   static SequenceRange split(const ACE_Message_Block& orig, size_t size,
00048                              ACE_Message_Block*& head,
00049                              ACE_Message_Block*& tail);
00050 
00051   RtpsSampleHeader();
00052   explicit RtpsSampleHeader(ACE_Message_Block& mb);
00053   RtpsSampleHeader& operator=(ACE_Message_Block& mn);
00054 
00055   void pdu_remaining(size_t size);
00056   size_t marshaled_size();
00057   ACE_UINT32 message_length();
00058 
00059   bool valid() const;
00060 
00061   bool into_received_data_sample(ReceivedDataSample& rds);
00062 
00063   bool more_fragments() const;
00064 
00065   RTPS::Submessage submessage_;
00066 
00067 private:
00068   void init(ACE_Message_Block& mb);
00069 
00070   bool valid_, frag_;
00071   size_t marshaled_size_, message_length_;
00072 
00073 public:
00074   // Unlike the rest of this class, which is used with the
00075   // TransportReceiveStrategy, these functions do the inverse of
00076   // into_received_data_sample() so they are used on the sending side:
00077   // translating from an OpenDDS data structure to the RTPS format.
00078   static void populate_data_sample_submessages(RTPS::SubmessageSeq& subm,
00079                                                const DataSampleElement& dsle,
00080                                                bool requires_inline_qos);
00081   static void populate_data_control_submessages(RTPS::SubmessageSeq& subm,
00082                                                 const TransportSendControlElement& tsce,
00083                                                 bool requires_inline_qos);
00084   static void populate_inline_qos(const TransportSendListener::InlineQosData& qos_data,
00085                                   RTPS::ParameterList& plist);
00086   static bool control_message_supported(char message_id);
00087 
00088   // All of the fragments we generate will use the FRAG_SIZE of 1024, which may
00089   // be the smallest allowed by the spec (8.4.14.1.1).  There is no practical
00090   // advantage to increasing this constant, since any number of 1024-byte
00091   // fragments may appear in a single DATA_FRAG submessage.  The spec is
00092   // ambiguous in its use of KB to mean either 1000 or 1024, and uses < instead
00093   // of <= (see issue 16966).
00094   static const ACE_CDR::UShort FRAG_SIZE = 1024;
00095 
00096 private:
00097   static void process_iqos(DataSampleHeader& opendds,
00098                            const OpenDDS::RTPS::ParameterList& iqos);
00099 };
00100 
00101 }
00102 }
00103 
00104 #ifdef __ACE_INLINE__
00105 #include "RtpsSampleHeader.inl"
00106 #endif
00107 
00108 #endif

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