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

GIOP_Message_Generator_Parser.cpp

Go to the documentation of this file.
00001 #include "tao_pch.h"
00002 #include "tao/GIOP_Message_Generator_Parser.h"
00003 #include "tao/Pluggable_Messaging_Utils.h"
00004 #include "tao/GIOP_Utils.h"
00005 #include "tao/CDR.h"
00006 #include "tao/Object_KeyC.h"
00007 #include "tao/IOPC.h"
00008 #include "tao/Tagged_Profile.h"
00009 #include "tao/debug.h"
00010 
00011 #if !defined (__ACE_INLINE__)
00012 # include "tao/GIOP_Message_Generator_Parser.inl"
00013 #endif /* __ACE_INLINE__ */
00014 
00015 ACE_RCSID(tao, GIOP_Message_Gen_Parser, "$Id: GIOP_Message_Generator_Parser.cpp,v 1.1.1.2.2.1 2003/03/14 16:05:12 chad Exp $")
00016 
00017 
00018 int
00019 TAO_GIOP_Message_Generator_Parser::parse_reply (
00020     TAO_InputCDR &stream,
00021     TAO_Pluggable_Reply_Params &params)
00022 {
00023 
00024   // Read the request id
00025   if (!stream.read_ulong (params.request_id_))
00026     {
00027       if (TAO_debug_level)
00028         ACE_ERROR ((LM_ERROR,
00029                     ACE_TEXT ("TAO (%P|%t) : TAO_GIOP_Message_Generator_Parser::parse_reply, \n ")
00030                     ACE_TEXT ("extracting request id")));
00031     }
00032 
00033   // and the reply status type.  status can be NO_EXCEPTION,
00034   // SYSTEM_EXCEPTION, USER_EXCEPTION, LOCATION_FORWARD
00035 
00036   // Cannot handle LOCATION_FORWARD_PERM here
00037   CORBA::ULong rep_stat = 0;
00038   if (!stream.read_ulong (rep_stat))
00039     {
00040       if (TAO_debug_level > 0)
00041         ACE_ERROR ((LM_ERROR,
00042                     ACE_TEXT ("TAO (%P|%t) : TAO_GIOP_Message_Generator_Parser::parse_reply, \n ")
00043                     ACE_TEXT ("extracting reply status")));
00044       return -1;
00045     }
00046 
00047 
00048   // Pass the right Pluggable interface code to the transport layer
00049   switch (rep_stat)
00050     {
00051       // Request completed successfully
00052     case TAO_GIOP_NO_EXCEPTION:
00053       params.reply_status_ =
00054         TAO_PLUGGABLE_MESSAGE_NO_EXCEPTION;
00055       break;
00056 
00057       // Request terminated with user exception
00058     case TAO_GIOP_USER_EXCEPTION:
00059       params.reply_status_ =
00060         TAO_PLUGGABLE_MESSAGE_USER_EXCEPTION;
00061       break;
00062       // Request terminated with system exception
00063     case TAO_GIOP_SYSTEM_EXCEPTION:
00064       params.reply_status_ =
00065         TAO_PLUGGABLE_MESSAGE_SYSTEM_EXCEPTION;
00066       break;
00067       // Reply is a location forward type
00068     case TAO_GIOP_LOCATION_FORWARD:
00069       params.reply_status_ =
00070         TAO_PLUGGABLE_MESSAGE_LOCATION_FORWARD;
00071       break;
00072       // Reply is a location forward perm type
00073       // @@For the time being the behaviour of the
00074       // LOCATION_FORWARD_PERM would be similar to the
00075       // LOCATION_FORWARD as there is a controversy surrounding the
00076       // usage of this in the OMG.
00077     case TAO_GIOP_LOCATION_FORWARD_PERM:
00078       params.reply_status_ =
00079         TAO_PLUGGABLE_MESSAGE_LOCATION_FORWARD;
00080       break;
00081       // Reply is a location forward type
00082     case TAO_GIOP_NEEDS_ADDRESSING_MODE:
00083       params.reply_status_ =
00084         TAO_PLUGGABLE_MESSAGE_NEEDS_ADDRESSING_MODE;
00085       break;
00086     default:
00087       if (TAO_debug_level > 0)
00088         ACE_DEBUG ((LM_DEBUG,
00089                     ACE_TEXT ("(%N|%l) Unknown reply status \n")));
00090     }
00091 
00092   return 0;
00093 }
00094 
00095 
00096 int
00097 TAO_GIOP_Message_Generator_Parser::parse_locate_reply (
00098     TAO_InputCDR &cdr,
00099     TAO_Pluggable_Reply_Params &params)
00100 {
00101   // Read the request id
00102   if (!cdr.read_ulong (params.request_id_))
00103     {
00104       if (TAO_debug_level > 0)
00105         ACE_ERROR ((LM_ERROR,
00106                     ACE_TEXT ("TAO (%P|%t|%N|%l):parse_locate_reply, ")
00107                     ACE_TEXT ("extracting request id \n")));
00108 
00109       return -1;
00110     }
00111 
00112   // and the reply status type.  status can be NO_EXCEPTION,
00113   // SYSTEM_EXCEPTION, USER_EXCEPTION, LOCATION_FORWARD
00114 
00115   // Cannot handle LOCATION_FORWARD_PERM here
00116 
00117   // Please note here that we are NOT converting to the Pluggable
00118   // messaging layer exception as this is GIOP specific. Not many
00119   // messaging protocols have the locate_* messages.
00120   if (!cdr.read_ulong (params.reply_status_))
00121     {
00122       if (TAO_debug_level > 0)
00123         ACE_ERROR ((LM_ERROR,
00124                     ACE_TEXT ("TAO N|(%P|%t|l) parse_locate_reply, ")
00125                     ACE_TEXT ("extracting reply  status\n")));
00126 
00127       return -1;
00128     }
00129 
00130   return 0;
00131 
00132 }
00133 
00134 
00135 int
00136 TAO_GIOP_Message_Generator_Parser::is_ready_for_bidirectional (void)
00137 {
00138   return 0;
00139 }
00140 
00141 void
00142 TAO_GIOP_Message_Generator_Parser::marshal_reply_status (
00143     TAO_OutputCDR &output,
00144     TAO_Pluggable_Reply_Params_Base &reply
00145   )
00146 {
00147   switch (reply.reply_status_)
00148     {
00149     case TAO_PLUGGABLE_MESSAGE_NO_EXCEPTION:
00150       output.write_ulong (TAO_GIOP_NO_EXCEPTION);
00151       break;
00152     case TAO_PLUGGABLE_MESSAGE_LOCATION_FORWARD:
00153       output.write_ulong (TAO_GIOP_LOCATION_FORWARD);
00154       break;
00155     case TAO_PLUGGABLE_MESSAGE_SYSTEM_EXCEPTION:
00156       output.write_ulong (TAO_GIOP_SYSTEM_EXCEPTION);
00157       break;
00158     case TAO_PLUGGABLE_MESSAGE_USER_EXCEPTION:
00159       output.write_ulong (TAO_GIOP_USER_EXCEPTION);
00160       break;
00161     default:
00162       // Some other specific exception
00163       output.write_ulong (reply.reply_status_);
00164       break;
00165     }
00166 }

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