GIOP_Message_State.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file     GIOP_Message_State.h
00006  *
00007  *  $Id: GIOP_Message_State.h 79705 2007-09-24 07:45:37Z johnnyw $
00008  *
00009  *   GIOP utility definitions
00010  *
00011  *  @author  Chris Cleeland <cleeland@cs.wustl.edu>
00012  *  @author  Carlos O' Ryan <coryan@uci.edu>
00013  *  @author  Balachandran Natarajan <bala@cs.wustl.edu>
00014  *  @author  Johnny Willemsen <jwillemsen@remedy.nl>
00015  */
00016 //=============================================================================
00017 #ifndef TAO_GIOP_MESSAGE_STATE_H
00018 #define TAO_GIOP_MESSAGE_STATE_H
00019 
00020 #include /**/ "ace/pre.h"
00021 
00022 #include "tao/GIOP_Message_Version.h"
00023 
00024 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00025 # pragma once
00026 #endif /* ACE_LACKS_PRAGMA_ONCE */
00027 
00028 #include "tao/GIOPC.h"
00029 
00030 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00031 
00032 /**
00033  * @class TAO_GIOP_Message_State
00034  *
00035  * @brief Generic definitions for Message States.
00036  *
00037  *  This helps to establish the state of the incoming messages.
00038  */
00039 
00040 class TAO_Export TAO_GIOP_Message_State
00041 {
00042 public:
00043 
00044   /// Ctor
00045   TAO_GIOP_Message_State (void);
00046 
00047   /// Parse the message header.
00048   ///
00049   /// \return -1 There was some error parsing the GIOP header
00050   /// \return 0  The GIOP header was parsed correctly
00051   /// \return 1  There was not enough data in the message block to
00052   ///            parse the header
00053   int parse_message_header (ACE_Message_Block &incoming);
00054 
00055   /// Return the message size
00056   CORBA::ULong message_size (void) const;
00057 
00058   /// Return the message size
00059   CORBA::ULong payload_size (void) const;
00060 
00061   /// Return the byte order information
00062   CORBA::Octet byte_order (void) const;
00063 
00064   /// Return the message type
00065   GIOP::MsgType message_type (void) const;
00066 
00067   /// Return the more fragments
00068   CORBA::Octet more_fragments (void) const;
00069 
00070   void more_fragments (CORBA::Octet fragment);
00071 
00072   /// Get the GIOP version
00073   TAO_GIOP_Message_Version const &giop_version (void) const;
00074 
00075 private:
00076   /// Parse the message header.
00077   int parse_message_header_i (ACE_Message_Block &incoming);
00078 
00079   /// Get the message type.
00080   GIOP::MsgType message_type (CORBA::Octet type) const;
00081 
00082   /// Checks for the magic word 'GIOP' in the start of the incoing
00083   /// stream
00084   int parse_magic_bytes (char *buf);
00085 
00086   /// Extracts the version information from the incoming
00087   /// stream. Performs a check for  whether the version information is
00088   /// right and sets the information in the <state>
00089   int get_version_info (char *buf);
00090 
00091   /// Extracts the byte order information from the incoming
00092   /// stream. Performs a check for  whether the byte order information
00093   /// right and sets the information in the <state>
00094   int get_byte_order_info (char *buf);
00095 
00096   /// Gets the size of the payload and set the size in the <state>
00097   void get_payload_size (char *buf);
00098 
00099   /// Read the unsigned long from the buffer. The @a buf should just
00100   /// point to the next 4 bytes data that represent the ULong
00101   CORBA::ULong read_ulong (const char *buf) const;
00102 
00103 private:
00104   // GIOP version information..
00105   TAO_GIOP_Message_Version giop_version_;
00106 
00107   /// 0 = big, 1 = little
00108   CORBA::Octet byte_order_;
00109 
00110   /// MsgType above
00111   GIOP::MsgType message_type_;
00112 
00113   /// In byte_order!
00114   CORBA::ULong payload_size_;
00115 
00116   /// (Requests and Replys)
00117   /// A value of zero indicates that this message does not have any
00118   /// fragments.  A value of non-zero indicates that it does have
00119   /// fragments.
00120   CORBA::Octet more_fragments_;
00121 };
00122 
00123 TAO_END_VERSIONED_NAMESPACE_DECL
00124 
00125 static const size_t TAO_GIOP_MESSAGE_HEADER_LEN = 12;
00126 static const size_t TAO_GIOP_MESSAGE_SIZE_OFFSET = 8;
00127 static const size_t TAO_GIOP_MESSAGE_FLAGS_OFFSET = 6;
00128 static const size_t TAO_GIOP_MESSAGE_TYPE_OFFSET  = 7;
00129 static const size_t TAO_GIOP_VERSION_MINOR_OFFSET = 5;
00130 static const size_t TAO_GIOP_VERSION_MAJOR_OFFSET = 4;
00131 static const size_t TAO_GIOP_MESSAGE_FRAGMENT_HEADER = 4;
00132 
00133 #if defined (__ACE_INLINE__)
00134 # include "tao/GIOP_Message_State.inl"
00135 #endif /* __ACE_INLINE__ */
00136 
00137 #include /**/ "ace/post.h"
00138 #endif /*TAO_GIOP_MESSAGE_STATE_H*/

Generated on Tue Feb 2 17:37:52 2010 for TAO by  doxygen 1.4.7