Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

GIOP_Message_Base.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // ===================================================================
00004 /**
00005  *  @file GIOP_Message_Base.h
00006  *
00007  *  $Id: GIOP_Message_Base.h,v 1.1.1.3.2.1 2003/03/20 20:20:29 cleeland Exp $
00008  *
00009  *  @author Initially Copyrighted by Sun Microsystems Inc., 1994-1995,
00010  *  @author modified by Balachandran Natarajan <bala@cs.wustl.edu>
00011  */
00012 // ===================================================================
00013 
00014 #ifndef TAO_GIOP_MESSAGE_BASE_H
00015 #define TAO_GIOP_MESSAGE_BASE_H
00016 #include "ace/pre.h"
00017 #include "tao/Pluggable_Messaging.h"
00018 
00019 
00020 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00021 # pragma once
00022 #endif /* ACE_LACKS_PRAGMA_ONCE */
00023 
00024 #include "tao/GIOP_Message_Generator_Parser_Impl.h"
00025 #include "tao/GIOP_Utils.h"
00026 #include "tao/GIOP_Message_State.h"
00027 
00028 
00029 class TAO_Pluggable_Reply_Params;
00030 class TAO_Queued_Data;
00031 
00032 /**
00033  * @class TAO_GIOP_Message_Base
00034  *
00035  * @brief Definitions of the GIOP specific stuff.
00036  *
00037  * This class will hold the specific details common to all the GIOP
00038  * versions. Some of them which are here may be shifted if things
00039  * start changing between versions. This class uses the
00040  * TAO_GIOP_Message_Reactive_Handler to read and parse messages.
00041  */
00042 
00043 class TAO_Export TAO_GIOP_Message_Base : public TAO_Pluggable_Messaging
00044 {
00045 public:
00046   //  friend class TAO_GIOP_Message_Reactive_Handler;
00047 
00048   /// Constructor
00049   TAO_GIOP_Message_Base (TAO_ORB_Core *orb_core,
00050                          size_t input_cdr_size = ACE_CDR::DEFAULT_BUFSIZE);
00051 
00052   /// Dtor
00053   virtual ~TAO_GIOP_Message_Base (void);
00054 
00055   /// Initialize the underlying state object based on the <major> and
00056   /// <minor> revision numbers
00057   virtual void init (CORBA::Octet major,
00058                      CORBA::Octet minor);
00059 
00060   /// Reset the messaging the object
00061   virtual void reset (void);
00062 
00063   /// Write the RequestHeader in to the <cdr> stream. The underlying
00064   /// implementation of the mesaging should do the right thing.
00065   virtual int generate_request_header (TAO_Operation_Details &op,
00066                                        TAO_Target_Specification &spec,
00067                                        TAO_OutputCDR &cdr);
00068 
00069   /// Write the RequestHeader in to the <cdr> stream.
00070   virtual int generate_locate_request_header (
00071       TAO_Operation_Details &op,
00072       TAO_Target_Specification &spec,
00073       TAO_OutputCDR &cdr
00074     );
00075 
00076   /// Write the reply header
00077   virtual int generate_reply_header (
00078       TAO_OutputCDR &cdr,
00079       TAO_Pluggable_Reply_Params_Base &params
00080     );
00081 
00082   /// This method reads the message on the connection. Returns 0 when
00083   /// there is short read on the connection. Returns 1 when the full
00084   /// message is read and handled. Returns -1 on errors. If <block> is
00085   /// 1, then reply is read in a blocking manner.
00086   virtual int read_message (TAO_Transport *transport,
00087                             int block = 0,
00088                             ACE_Time_Value *max_wait_time = 0);
00089 
00090 
00091   /// Format the message. As we have not written the message length in
00092   /// the header, we make use of this oppurtunity to insert and format
00093   /// the message.
00094   virtual int format_message (TAO_OutputCDR &cdr);
00095 
00096   /// Process the request message that we have received on the
00097   /// connection
00098   virtual int process_request_message (TAO_Transport *transport,
00099                                        TAO_Queued_Data *qd);
00100 
00101   /*!
00102     \brief Inspects the bytes in \param mb to see if they "look like" the beginning of a message.
00103 
00104     Inspects the bytes in \param mb, beginning at \code mb.rd_ptr, to
00105     see if they look like the beginning of a message.  Does
00106    */
00107   virtual int check_for_valid_header (const ACE_Message_Block &mb) const;
00108 
00109   /*!
00110     \brief Set fields in \param qd based on values derived from \param mb.
00111 
00112     This function sets fields in \param qd based on values derived
00113     from \param mb.  It assumes that if the length of \param mb is
00114     enough to hold a header, then the data in there can be trusted to
00115     make sense.
00116    */
00117   virtual void set_queued_data_from_message_header (
00118     TAO_Queued_Data *,
00119     const ACE_Message_Block &mb) const;
00120 
00121 
00122 
00123   /// Parse the reply message that we received and return the reply
00124   /// information though <reply_info>
00125   virtual int process_reply_message (
00126       TAO_Pluggable_Reply_Params &reply_info,
00127       TAO_Queued_Data *qd);
00128 
00129 
00130 
00131   /// Generate a reply message with the exception <ex>.
00132   virtual int generate_exception_reply (
00133       TAO_OutputCDR &cdr,
00134       TAO_Pluggable_Reply_Params_Base &params,
00135       CORBA::Exception &x
00136     );
00137 
00138   /// Header length
00139   virtual size_t header_length (void) const;
00140 
00141 protected:
00142 
00143   /// Processes the <GIOP_REQUEST> messages
00144   int process_request (TAO_Transport *transport,
00145                        TAO_InputCDR &input,
00146                        TAO_OutputCDR &output,
00147                        TAO_GIOP_Message_Generator_Parser *);
00148 
00149   /// Processes the <GIOP_LOCATE_REQUEST> messages
00150   int process_locate_request (TAO_Transport *transport,
00151                               TAO_InputCDR &input,
00152                               TAO_OutputCDR &output,
00153                               TAO_GIOP_Message_Generator_Parser *);
00154 
00155   /// Set the state
00156   void set_state (CORBA::Octet major,
00157                   CORBA::Octet minor,
00158                   TAO_GIOP_Message_Generator_Parser *&);
00159 
00160   /// Print out a debug messages..
00161   void dump_msg (const char *label,
00162                  const u_char *ptr,
00163                  size_t len);
00164 
00165   /// Get the message type. The return value would be one of the
00166   /// following:
00167   /// TAO_PLUGGABLE_MESSAGE_REQUEST,
00168   /// TAO_PLUGGABLE_MESSAGE_REPLY,
00169   /// TAO_PLUGGABLE_MESSAGE_CLOSECONNECTION,
00170   /// TAO_PLUGGABLE_MESSAGE_MESSAGE_ERROR.
00171   static TAO_Pluggable_Message_Type message_type (TAO_GIOP_Message_State &state);
00172 
00173 private:
00174 
00175   /// Writes the GIOP header in to <msg>
00176   /// NOTE: If the GIOP header happens to change in the future, we can
00177   /// push this method in to the generator_parser classes.
00178   int write_protocol_header (TAO_GIOP_Message_Type t,
00179                              TAO_OutputCDR &msg);
00180 
00181   /// Make a <GIOP_LOCATEREPLY> and hand that over to the transport so
00182   /// that it can be sent over the connection.
00183   /// NOTE:As on date 1.1 & 1.2 seem to have similar headers. Till an
00184   /// unmanageable difference comes let them be implemented here.
00185   int make_send_locate_reply (TAO_Transport *transport,
00186                               TAO_GIOP_Locate_Request_Header &request,
00187                               TAO_GIOP_Locate_Status_Msg &status,
00188                               TAO_OutputCDR &output,
00189                               TAO_GIOP_Message_Generator_Parser *);
00190 
00191   /// Send error messages
00192   int  send_error (TAO_Transport *transport);
00193 
00194   /// Close a connection, first sending GIOP::CloseConnection.
00195   void send_close_connection (const TAO_GIOP_Message_Version &version,
00196                               TAO_Transport *transport,
00197                               void *ctx);
00198 
00199   /// We must send a LocateReply through <transport>, this request
00200   /// resulted in some kind of exception.
00201   int send_reply_exception (TAO_Transport *transport,
00202                             TAO_OutputCDR &cdr,
00203                             CORBA::ULong request_id,
00204                             IOP::ServiceContextList *svc_info,
00205                             CORBA::Exception *x);
00206 
00207 
00208   /// Write the locate reply header
00209   virtual int generate_locate_reply_header (
00210       TAO_OutputCDR & /*cdr*/,
00211       TAO_Pluggable_Reply_Params_Base & /*params*/);
00212 
00213   /// Is the messaging object ready for processing BiDirectional
00214   /// request/response?
00215   virtual int is_ready_for_bidirectional (TAO_OutputCDR &msg);
00216 
00217   /// Creates a new node for the queue with a message block in the
00218   /// node of size <sz>..
00219   TAO_Queued_Data *make_queued_data (size_t sz);
00220 
00221 private:
00222 
00223   /// Cached ORB_Core pointer...
00224   TAO_ORB_Core *orb_core_;
00225 
00226   /// Thr message handler object that does reading and parsing of the
00227   /// incoming messages
00228   TAO_GIOP_Message_State message_state_;
00229 
00230   /// All the implementations of GIOP message generator and parsers
00231   TAO_GIOP_Message_Generator_Parser_Impl tao_giop_impl_;
00232 
00233 protected:
00234   /// The generator and parser state.
00235   // TAO_GIOP_Message_Generator_Parser *generator_parser_;
00236 
00237 };
00238 
00239 
00240 
00241 
00242 #if defined (__ACE_INLINE__)
00243 # include "tao/GIOP_Message_Base.i"
00244 #endif /* __ACE_INLINE__ */
00245 
00246 #include "ace/post.h"
00247 #endif /*TAO_GIOP_MESSAGE_BASE_H*/

Generated on Mon Jun 16 13:48:24 2003 for TAO by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002