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

TAO_GIOP_Message_Lite Class Reference

Definitions of GIOPLite specific stuff. More...

#include <GIOP_Message_Lite.h>

Inheritance diagram for TAO_GIOP_Message_Lite:

Inheritance graph
[legend]
Collaboration diagram for TAO_GIOP_Message_Lite:

Collaboration graph
[legend]
List of all members.

Public Methods

 TAO_GIOP_Message_Lite (TAO_ORB_Core *orb_core, size_t input_cdr_size=ACE_CDR::DEFAULT_BUFSIZE)
 Constructor. More...

virtual ~TAO_GIOP_Message_Lite (void)
 Dtor. More...

virtual void init (CORBA::Octet, CORBA::Octet)
 Initialize the object -- this is a dummy for GIOPlite. More...

virtual void reset (void)
 Reset the messaging the object. More...

virtual int generate_request_header (TAO_Operation_Details &op, TAO_Target_Specification &spec, TAO_OutputCDR &cdr)
 Write the RequestHeader in to the <cdr> stream. The underlying implementation of the mesaging should do the right thing. More...

virtual int generate_locate_request_header (TAO_Operation_Details &op, TAO_Target_Specification &spec, TAO_OutputCDR &cdr)
 Write the RequestHeader in to the <cdr> stream. More...

virtual int generate_reply_header (TAO_OutputCDR &cdr, TAO_Pluggable_Reply_Params_Base &params)
 Write the reply header. More...

virtual int read_message (TAO_Transport *transport, int block=0, ACE_Time_Value *max_wait_time=0)
 Dummy method to .. More...

virtual int format_message (TAO_OutputCDR &cdr)
 Format the message. As we have not written the message length in the header, we make use of this oppurtunity to insert and format the message. More...

virtual int process_request_message (TAO_Transport *transport, TAO_Queued_Data *qd)
 Process the request message that we have received on the connection. More...


Detailed Description

Definitions of GIOPLite specific stuff.

This protocol is a modified version of GIOP. This is more suited for homogenous platforms.

Definition at line 42 of file GIOP_Message_Lite.h.


Constructor & Destructor Documentation

TAO_GIOP_Message_Lite::TAO_GIOP_Message_Lite TAO_ORB_Core   orb_core,
size_t    input_cdr_size = ACE_CDR::DEFAULT_BUFSIZE
 

Constructor.

Definition at line 32 of file GIOP_Message_Lite.cpp.

References ACE_CDR_BYTE_ORDER.

00034   : orb_core_ (orb_core),
00035     message_type_ (0),
00036     message_size_ (0),
00037     byte_order_ (ACE_CDR_BYTE_ORDER)
00038 {
00039 }

TAO_GIOP_Message_Lite::~TAO_GIOP_Message_Lite void    [virtual]
 

Dtor.

Definition at line 42 of file GIOP_Message_Lite.cpp.

00043 {
00044 }


Member Function Documentation

int TAO_GIOP_Message_Lite::format_message TAO_OutputCDR   cdr [virtual]
 

Format the message. As we have not written the message length in the header, we make use of this oppurtunity to insert and format the message.

Implements TAO_Pluggable_Messaging.

Definition at line 174 of file GIOP_Message_Lite.cpp.

References ACE_OutputCDR::begin, ACE_OutputCDR::buffer, ACE_CDR::consolidate, ACE_Message_Block::cont, ACE_OutputCDR::do_byte_swap, ACE_OutputCDR::length, ACE_Message_Block::rd_ptr, ACE_CDR::swap_4, TAO_GIOP_LITE_HEADER_LEN, TAO_GIOP_LITE_MESSAGE_SIZE_OFFSET, and ACE_OutputCDR::total_length.

00175 {
00176   // Get the header length
00177   const size_t header_len = TAO_GIOP_LITE_HEADER_LEN ;
00178 
00179   // Get the message size offset
00180   const size_t offset = TAO_GIOP_LITE_MESSAGE_SIZE_OFFSET;
00181 
00182   // Ptr to first buffer.
00183   char *buf = (char *) stream.buffer ();
00184 
00185   // Length of all buffers.
00186   size_t total_len =
00187     stream.total_length ();
00188 
00189   // NOTE: Here would also be a fine place to calculate a digital
00190   // signature for the message and place it into a preallocated slot
00191   // in the "ServiceContext".  Similarly, this is a good spot to
00192   // encrypt messages (or just the message bodies) if that's needed in
00193   // this particular environment and that isn't handled by the
00194   // networking infrastructure (e.g., IPSEC).
00195 
00196   CORBA::ULong bodylen = ACE_static_cast(CORBA::ULong,
00197                                          total_len - header_len);
00198 
00199 #if !defined (ACE_ENABLE_SWAP_ON_WRITE)
00200   *ACE_reinterpret_cast (CORBA::ULong *, buf + offset) = bodylen;
00201 #else
00202   if (!stream.do_byte_swap ())
00203     *ACE_reinterpret_cast (CORBA::ULong *,
00204                            buf + offset) = bodylen;
00205   else
00206     ACE_CDR::swap_4 (ACE_reinterpret_cast (char *,
00207                                            &bodylen),
00208                      buf + offset);
00209 #endif /* ACE_ENABLE_SWAP_ON_WRITE */
00210 
00211   // Strictly speaking, should not need to loop here because the
00212   // socket never gets set to a nonblocking mode ... some Linux
00213   // versions seem to need it though.  Leaving it costs little.
00214   if (TAO_debug_level > 2)
00215     {
00216       // Check whether the output cdr stream is build up of multiple
00217       // messageblocks. If so, consolidate them to one block that can be
00218       // dumped
00219       ACE_Message_Block* consolidated_block = 0;
00220       if (stream.begin()->cont() != 0)
00221         {
00222           consolidated_block = new ACE_Message_Block;
00223           ACE_CDR::consolidate(consolidated_block, stream.begin());
00224           buf = (char *) (consolidated_block->rd_ptr ());
00225         }
00226       ///
00227 
00228       this->dump_msg ("send",
00229                       ACE_reinterpret_cast (u_char *,
00230                                             buf),
00231                       stream.length ());
00232 
00233       //
00234       delete consolidated_block;
00235       consolidated_block = 0;
00236       //
00237     }
00238 
00239   return 0;
00240 }

int TAO_GIOP_Message_Lite::generate_locate_request_header TAO_Operation_Details   op,
TAO_Target_Specification   spec,
TAO_OutputCDR   cdr
[virtual]
 

Write the RequestHeader in to the <cdr> stream.

Implements TAO_Pluggable_Messaging.

Definition at line 99 of file GIOP_Message_Lite.cpp.

References ACE_ERROR, ACE_TEXT, LM_ERROR, TAO_Operation_Details::request_id, and TAO_GIOP_LOCATEREQUEST.

00104 {
00105   // Write the GIOPLite header first
00106   if (!this->write_protocol_header (TAO_GIOP_LOCATEREQUEST,
00107                                     cdr))
00108     {
00109       if (TAO_debug_level > 3)
00110         ACE_ERROR ((LM_ERROR,
00111                     ACE_TEXT ("(%P|%t) Error in writing GIOPLite header \n")));
00112 
00113       return -1;
00114     }
00115 
00116   // Now call the implementation for the rest of the header
00117   if (!this->write_locate_request_header (op.request_id (),
00118                                           spec,
00119                                           cdr))
00120     {
00121       if (TAO_debug_level > 4)
00122         ACE_ERROR ((LM_ERROR,
00123                     ACE_TEXT ("(%P|%t) Error in writing locate request header \n")));
00124 
00125       return -1;
00126     }
00127 
00128   return 0;
00129 }

int TAO_GIOP_Message_Lite::generate_reply_header TAO_OutputCDR   cdr,
TAO_Pluggable_Reply_Params_Base   params
[virtual]
 

Write the reply header.

Implements TAO_Pluggable_Messaging.

Definition at line 133 of file GIOP_Message_Lite.cpp.

References ACE_ERROR, ACE_TEXT, LM_ERROR, and TAO_GIOP_REPLY.

00137 {
00138   // Write the GIOPLite header first
00139   if (!this->write_protocol_header (TAO_GIOP_REPLY,
00140                                     cdr))
00141     {
00142       if (TAO_debug_level > 3)
00143         ACE_ERROR ((LM_ERROR,
00144                     ACE_TEXT ("(%P|%t) Error in writing GIOPLite header \n")));
00145 
00146       return -1;
00147     }
00148 
00149   // Now call the implementation for the rest of the header
00150   if (!this->write_reply_header (cdr,
00151                                  params))
00152     {
00153       if (TAO_debug_level > 4)
00154         ACE_ERROR ((LM_ERROR,
00155                     ACE_TEXT ("(%P|%t) Error in writing reply header \n")));
00156 
00157       return -1;
00158     }
00159 
00160   return 0;
00161 }

int TAO_GIOP_Message_Lite::generate_request_header TAO_Operation_Details   op,
TAO_Target_Specification   spec,
TAO_OutputCDR   cdr
[virtual]
 

Write the RequestHeader in to the <cdr> stream. The underlying implementation of the mesaging should do the right thing.

Implements TAO_Pluggable_Messaging.

Definition at line 63 of file GIOP_Message_Lite.cpp.

References ACE_ERROR, ACE_TEXT, LM_ERROR, and TAO_GIOP_REQUEST.

00068 {
00069   // Write the GIOPLite header first
00070   if (!this->write_protocol_header (TAO_GIOP_REQUEST,
00071                                     cdr))
00072     {
00073       if (TAO_debug_level)
00074         ACE_ERROR ((LM_ERROR,
00075                     ACE_TEXT ("(%P|%t) Error in writing GIOP header \n")));
00076 
00077 
00078       return -1;
00079     }
00080 
00081   // Now call the implementation for the rest of the header
00082   if (!this->write_request_header (op,
00083                                    spec,
00084                                    cdr))
00085     {
00086       if (TAO_debug_level)
00087         ACE_ERROR ((LM_ERROR,
00088                     ACE_TEXT ("(%P|%t) Error in writing request header \n")));
00089 
00090       return -1;
00091     }
00092 
00093   return 0;
00094 
00095 }

void TAO_GIOP_Message_Lite::init CORBA::Octet   ,
CORBA::Octet   
[virtual]
 

Initialize the object -- this is a dummy for GIOPlite.

Implements TAO_Pluggable_Messaging.

Definition at line 48 of file GIOP_Message_Lite.cpp.

00050 {
00051   return;
00052 }

int TAO_GIOP_Message_Lite::process_request_message TAO_Transport   transport,
TAO_Queued_Data   qd
[virtual]
 

Process the request message that we have received on the connection.

Implements TAO_Pluggable_Messaging.

Definition at line 505 of file GIOP_Message_Lite.cpp.

References TAO_Transport::assign_translators, ACE_Message_Block::base, TAO_Queued_Data::byte_order_, ACE_Message_Block::data_block, ACE_CDR::DEFAULT_BUFSIZE, ACE_Message_Block::DONT_DELETE, ACE_Message_Block::length, TAO_Queued_Data::major_version_, ACE_OS_String::memset, TAO_Queued_Data::minor_version_, TAO_Queued_Data::msg_block_, TAO_Queued_Data::msg_type_, ACE_Message_Block::rd_ptr, TAO_ENCAP_BYTE_ORDER, TAO_GIOP_LITE_HEADER_LEN, TAO_PLUGGABLE_MESSAGE_LOCATEREQUEST, TAO_PLUGGABLE_MESSAGE_REQUEST, and ACE_Message_Block::wr_ptr.

00507 {
00508   // Set the upcall thread
00509   this->orb_core_->lf_strategy ().set_upcall_thread (
00510       this->orb_core_->leader_follower ());
00511 
00512   // A buffer that we will use to initialise the CDR stream
00513   char repbuf[ACE_CDR::DEFAULT_BUFSIZE];
00514 
00515 #if defined(ACE_HAS_PURIFY)
00516   (void) ACE_OS::memset (repbuf,
00517                          '\0',
00518                          sizeof repbuf);
00519 #endif /* ACE_HAS_PURIFY */
00520 
00521   // Initialze an output CDR on the stack
00522   TAO_OutputCDR output (repbuf,
00523                         sizeof repbuf,
00524                         TAO_ENCAP_BYTE_ORDER,
00525                         this->orb_core_->output_cdr_buffer_allocator (),
00526                         this->orb_core_->output_cdr_dblock_allocator (),
00527                         this->orb_core_->output_cdr_msgblock_allocator (),
00528                         this->orb_core_->orb_params ()->cdr_memcpy_tradeoff (),
00529                         qd->major_version_,
00530                         qd->minor_version_);
00531 
00532   transport->assign_translators(0,&output);
00533 
00534   // Get the read and write positions before we steal data.
00535   size_t rd_pos = qd->msg_block_->rd_ptr () - qd->msg_block_->base ();
00536   size_t wr_pos = qd->msg_block_->wr_ptr () - qd->msg_block_->base ();
00537   rd_pos += TAO_GIOP_LITE_HEADER_LEN;
00538 
00539   this->dump_msg ("recv",
00540                   ACE_reinterpret_cast (u_char *,
00541                                         qd->msg_block_->rd_ptr ()),
00542                   qd->msg_block_->length ());
00543 
00544 
00545   // Create a input CDR stream.
00546   // NOTE: We use the same data block in which we read the message and
00547   // we pass it on to the higher layers of the ORB. So we dont to any
00548   // copies at all here. The same is also done in the higher layers.
00549 
00550   TAO_InputCDR input_cdr (qd->msg_block_->data_block (),
00551                           ACE_Message_Block::DONT_DELETE,
00552                           rd_pos,
00553                           wr_pos,
00554                           qd->byte_order_,
00555                           qd->major_version_,
00556                           qd->minor_version_,
00557                           this->orb_core_);
00558 
00559 
00560   // We know we have some request message. Check whether it is a
00561   // GIOP_REQUEST or GIOP_LOCATE_REQUEST to take action.
00562   switch (qd->msg_type_)
00563     {
00564     case TAO_PLUGGABLE_MESSAGE_REQUEST:
00565       // Should be taken care by the state specific invocations. They
00566       // could raise an exception or write things in the output CDR
00567       // stream
00568       return this->process_request (transport,
00569                                     input_cdr,
00570                                     output);
00571     case TAO_PLUGGABLE_MESSAGE_LOCATEREQUEST:
00572       return this->process_locate_request (transport,
00573                                            input_cdr,
00574                                            output);
00575     default:
00576       return -1;
00577     }
00578 }

int TAO_GIOP_Message_Lite::read_message TAO_Transport   transport,
int    block = 0,
ACE_Time_Value   max_wait_time = 0
[virtual]
 

Dummy method to ..

Implements TAO_Pluggable_Messaging.

Definition at line 165 of file GIOP_Message_Lite.cpp.

00168 {
00169   return 1;
00170 }

void TAO_GIOP_Message_Lite::reset void    [virtual]
 

Reset the messaging the object.

Definition at line 55 of file GIOP_Message_Lite.cpp.

00056 {
00057   this->message_type_ = 0;
00058   this->message_size_ = 0;
00059 }


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 15:16:53 2003 for TAO by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002