TAO_OutputCDR Class Reference

A CDR stream for writing, i.e. for marshalling. More...

#include <CDR.h>

Inheritance diagram for TAO_OutputCDR:

Inheritance graph
[legend]
Collaboration diagram for TAO_OutputCDR:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TAO_OutputCDR (size_t size=0, int byte_order=ACE_CDR_BYTE_ORDER, ACE_Allocator *buffer_allocator=0, ACE_Allocator *data_block_allocator=0, ACE_Allocator *message_block_allocator=0, size_t memcpy_tradeoff=0, ACE_CDR::Octet major_version=TAO_DEF_GIOP_MAJOR, ACE_CDR::Octet minor_version=TAO_DEF_GIOP_MINOR)
 TAO_OutputCDR (char *data, size_t size, int byte_order=ACE_CDR_BYTE_ORDER, ACE_Allocator *buffer_allocator=0, ACE_Allocator *data_block_allocator=0, ACE_Allocator *message_block_allocator=0, size_t memcpy_tradeoff=0, ACE_CDR::Octet major_version=TAO_DEF_GIOP_MAJOR, ACE_CDR::Octet minor_version=TAO_DEF_GIOP_MINOR)
 TAO_OutputCDR (char *data, size_t size, int byte_order, ACE_Allocator *buffer_allocator, ACE_Allocator *data_block_allocator, ACE_Allocator *message_block_allocator, size_t memcpy_tradeoff, TAO_GIOP_Fragmentation_Strategy *fs, ACE_CDR::Octet major_version, ACE_CDR::Octet minor_version)
 TAO_OutputCDR (ACE_Message_Block *data, int byte_order=ACE_CDR_BYTE_ORDER, size_t memcpy_tradeoff=0, ACE_CDR::Octet major_version=TAO_DEF_GIOP_MAJOR, ACE_CDR::Octet minor_version=TAO_DEF_GIOP_MINOR)
 ~TAO_OutputCDR (void)
 Destructor.

Outgoing GIOP Fragment Related Methods
These methods are only used when fragmenting outgoing GIOP requests and replies.

bool fragment_stream (ACE_CDR::ULong pending_alignment, ACE_CDR::ULong pending_length)
 Fragment this output CDR stream if necessary.

bool more_fragments (void) const
 Are there more data fragments to come?

void more_fragments (bool more)
 Specify whether there are more data fragments to come.

void message_attributes (CORBA::ULong request_id, TAO_Stub *stub, int message_semantics, ACE_Time_Value *timeout)
 Set fragmented message attributes.

CORBA::ULong request_id (void) const
 Fragmented message request ID.

TAO_Stubstub (void) const
 Stub object associated with the request.

int message_semantics (void) const
 Message semantics (twoway, oneway, reply).

ACE_Time_Valuetimeout (void) const
 Maximum time to wait for outgoing message to be sent.


Static Public Member Functions

void throw_stub_exception (int error_num)
void throw_skel_exception (int error_num)

Private Member Functions

 TAO_OutputCDR (const TAO_OutputCDR &rhs)
TAO_OutputCDRoperator= (const TAO_OutputCDR &rhs)

Private Attributes

Outgoing GIOP Fragment Related Attributes
These attributes are only used when fragmenting outgoing GIOP requests and replies.

TAO_GIOP_Fragmentation_Strategy
*const  
fragmentation_strategy_
bool more_fragments_
 Are there more data fragments to come?

CORBA::ULong request_id_
 Request ID for the request currently being marshaled.

TAO_Stubstub_
 Stub object associated with the request.

int message_semantics_
 Twoway, oneway, reply?

ACE_Time_Valuetimeout_
 Request/reply send timeout.


Friends

class TAO_InputCDR
 For reading from a output CDR stream.


Detailed Description

A CDR stream for writing, i.e. for marshalling.

This class is based on the the CORBA spec for Java (98-02-29), java class omg.org.CORBA.portable.OutputStream. It diverts in a few ways: + Operations taking arrays don't have offsets, because in C++ it is easier to describe an array starting from x+offset. + Operations return an error status, because exceptions are not widely available in C++ (yet). A particularly useful static member function for this buffer is an interpretive encoding routine, usable as a typecode interpreter callback. Ditto for decoding. These are used to support all OMG-IDL datatypes, even those not supported directly by put/get primitives.

Definition at line 89 of file CDR.h.


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_OutputCDR::TAO_OutputCDR size_t  size = 0,
int  byte_order = ACE_CDR_BYTE_ORDER,
ACE_Allocator buffer_allocator = 0,
ACE_Allocator data_block_allocator = 0,
ACE_Allocator message_block_allocator = 0,
size_t  memcpy_tradeoff = 0,
ACE_CDR::Octet  major_version = TAO_DEF_GIOP_MAJOR,
ACE_CDR::Octet  minor_version = TAO_DEF_GIOP_MINOR
 

Default constructor, allocates bytes in the internal buffer, if == 0 it allocates the default size.

Definition at line 54 of file CDR.cpp.

References ACE_FUNCTION_TIMEPROBE, and CORBA::Octet.

00062   : ACE_OutputCDR (size,
00063                    byte_order,
00064                    buffer_allocator,
00065                    data_block_allocator,
00066                    message_block_allocator,
00067                    memcpy_tradeoff,
00068                    major_version,
00069                    minor_version)
00070   , fragmentation_strategy_ (0)
00071   , more_fragments_ (false)
00072   , request_id_ (0)
00073   , stub_ (0)
00074   , message_semantics_ (-1)
00075   , timeout_ (0)
00076 {
00077   ACE_FUNCTION_TIMEPROBE (TAO_OUTPUT_CDR_CTOR1_ENTER);
00078 }

TAO_OutputCDR::TAO_OutputCDR char *  data,
size_t  size,
int  byte_order = ACE_CDR_BYTE_ORDER,
ACE_Allocator buffer_allocator = 0,
ACE_Allocator data_block_allocator = 0,
ACE_Allocator message_block_allocator = 0,
size_t  memcpy_tradeoff = 0,
ACE_CDR::Octet  major_version = TAO_DEF_GIOP_MAJOR,
ACE_CDR::Octet  minor_version = TAO_DEF_GIOP_MINOR
 

Build a CDR stream with an initial buffer, it will *not* remove , since it did not allocated it.

Definition at line 80 of file CDR.cpp.

References ACE_FUNCTION_TIMEPROBE, and CORBA::Octet.

00089   : ACE_OutputCDR (data,
00090                    size,
00091                    byte_order,
00092                    buffer_allocator,
00093                    data_block_allocator,
00094                    message_block_allocator,
00095                    memcpy_tradeoff,
00096                    major_version,
00097                    minor_version)
00098   , fragmentation_strategy_ (0)
00099   , more_fragments_ (false)
00100   , request_id_ (0)
00101   , stub_ (0)
00102   , message_semantics_ (-1)
00103   , timeout_ (0)
00104 {
00105   ACE_FUNCTION_TIMEPROBE (TAO_OUTPUT_CDR_CTOR2_ENTER);
00106 }

TAO_OutputCDR::TAO_OutputCDR char *  data,
size_t  size,
int  byte_order,
ACE_Allocator buffer_allocator,
ACE_Allocator data_block_allocator,
ACE_Allocator message_block_allocator,
size_t  memcpy_tradeoff,
TAO_GIOP_Fragmentation_Strategy fs,
ACE_CDR::Octet  major_version,
ACE_CDR::Octet  minor_version
 

Build a CDR stream with an initial buffer, it will *not* remove data since it did not allocated it, and enable fragmentation support.

Definition at line 108 of file CDR.cpp.

References ACE_FUNCTION_TIMEPROBE, and CORBA::Octet.

00118   : ACE_OutputCDR (data,
00119                    size,
00120                    byte_order,
00121                    buffer_allocator,
00122                    data_block_allocator,
00123                    message_block_allocator,
00124                    memcpy_tradeoff,
00125                    major_version,
00126                    minor_version)
00127   , fragmentation_strategy_ (fs)
00128   , more_fragments_ (false)
00129   , request_id_ (0)
00130   , stub_ (0)
00131   , message_semantics_ (-1)
00132   , timeout_ (0)
00133 {
00134   ACE_FUNCTION_TIMEPROBE (TAO_OUTPUT_CDR_CTOR3_ENTER);
00135 }

TAO_OutputCDR::TAO_OutputCDR ACE_Message_Block data,
int  byte_order = ACE_CDR_BYTE_ORDER,
size_t  memcpy_tradeoff = 0,
ACE_CDR::Octet  major_version = TAO_DEF_GIOP_MAJOR,
ACE_CDR::Octet  minor_version = TAO_DEF_GIOP_MINOR
 

Build a CDR stream with an initial Message_Block chain, it will *not* remove , since it did not allocate it.

Definition at line 137 of file CDR.cpp.

References ACE_FUNCTION_TIMEPROBE, and CORBA::Octet.

00142   : ACE_OutputCDR (data,
00143                    byte_order,
00144                    memcpy_tradeoff,
00145                    major_version,
00146                    minor_version)
00147   , fragmentation_strategy_ (0)
00148   , more_fragments_ (false)
00149   , request_id_ (0)
00150   , stub_ (0)
00151   , message_semantics_ (-1)
00152   , timeout_ (0)
00153 {
00154   ACE_FUNCTION_TIMEPROBE (TAO_OUTPUT_CDR_CTOR4_ENTER);
00155 }

TAO_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE TAO_OutputCDR::~TAO_OutputCDR void   ) 
 

Destructor.

Definition at line 8 of file CDR.i.

00009 {
00010 }

TAO_OutputCDR::TAO_OutputCDR const TAO_OutputCDR rhs  )  [private]
 


Member Function Documentation

bool TAO_OutputCDR::fragment_stream ACE_CDR::ULong  pending_alignment,
ACE_CDR::ULong  pending_length
 

Fragment this output CDR stream if necessary.

Fragmentation will done through GIOP fragments when the length of the CDR stream length will exceed the configured threshold.

Definition at line 212 of file CDR.cpp.

References TAO_GIOP_Fragmentation_Strategy::fragment(), fragmentation_strategy_, and CORBA::ULong.

Referenced by operator<<().

00214 {
00215   if (this->fragmentation_strategy_)
00216     {
00217       return (this->fragmentation_strategy_->fragment (*this,
00218                                                        pending_alignment,
00219                                                        pending_length) == 0);
00220     }
00221 
00222   return true;  // Success.
00223 }

ACE_INLINE void TAO_OutputCDR::message_attributes CORBA::ULong  request_id,
TAO_Stub stub,
int  message_semantics,
ACE_Time_Value timeout
 

Set fragmented message attributes.

Definition at line 25 of file CDR.i.

References message_semantics_, and stub_.

Referenced by TAO_ServerRequest::init_reply(), TAO_GIOP_Message_Base::process_request(), TAO::Synch_Oneway_Invocation::remote_oneway(), TAO::Synch_Twoway_Invocation::remote_twoway(), TAO_ServerRequest::send_cached_reply(), and TAO_ServerRequest::send_no_exception_reply().

00029 {
00030   this->request_id_        = request_id;
00031   this->stub_              = stub;
00032   this->message_semantics_ = message_semantics;
00033   this->timeout_           = timeout;
00034 }

ACE_INLINE int TAO_OutputCDR::message_semantics void   )  const
 

Message semantics (twoway, oneway, reply).

Definition at line 49 of file CDR.i.

References message_semantics_.

Referenced by TAO_On_Demand_Fragmentation_Strategy::fragment().

00050 {
00051   return this->message_semantics_;
00052 }

ACE_INLINE void TAO_OutputCDR::more_fragments bool  more  ) 
 

Specify whether there are more data fragments to come.

Definition at line 19 of file CDR.i.

References more_fragments_.

00020 {
00021   this->more_fragments_ = more;
00022 }

ACE_INLINE bool TAO_OutputCDR::more_fragments void   )  const
 

Are there more data fragments to come?

Definition at line 13 of file CDR.i.

References more_fragments_.

Referenced by TAO_On_Demand_Fragmentation_Strategy::fragment(), TAO_GIOP_Message_Base::make_send_locate_reply(), TAO_Operation_Details::marshal_args(), TAO_GIOP_Message_Base::process_request(), TAO_ServerRequest::send_cached_reply(), TAO_ServerRequest::send_no_exception_reply(), TAO_GIOP_Message_Base::send_reply_exception(), TAO_GIOP_Message_Base::set_giop_flags(), TAO_ServerRequest::tao_send_reply(), and TAO_ServerRequest::tao_send_reply_exception().

00014 {
00015   return this->more_fragments_;
00016 }

TAO_OutputCDR& TAO_OutputCDR::operator= const TAO_OutputCDR rhs  )  [private]
 

ACE_INLINE CORBA::ULong TAO_OutputCDR::request_id void   )  const
 

Fragmented message request ID.

Definition at line 37 of file CDR.i.

Referenced by TAO_On_Demand_Fragmentation_Strategy::fragment().

00038 {
00039   return this->request_id_;
00040 }

ACE_INLINE TAO_Stub * TAO_OutputCDR::stub void   )  const
 

Stub object associated with the request.

Definition at line 43 of file CDR.i.

References stub_.

Referenced by TAO_On_Demand_Fragmentation_Strategy::fragment().

00044 {
00045   return this->stub_;
00046 }

void TAO_OutputCDR::throw_skel_exception int  error_num  )  [static]
 

Definition at line 182 of file CDR.cpp.

References ACE_THROW.

00183 {
00184   switch (error_num)
00185     {
00186     case 0 :
00187       break;
00188 
00189     case EINVAL : // wchar from a GIOP 1.0
00190       ACE_THROW (CORBA::MARSHAL (CORBA::OMGVMCID | 5, CORBA::COMPLETED_YES));
00191       ACE_NOTREACHED (break);
00192 
00193     case EACCES : // wchar but no codeset
00194       ACE_THROW (CORBA::BAD_PARAM (CORBA::OMGVMCID | 23,
00195                                    CORBA::COMPLETED_YES));
00196       ACE_NOTREACHED (break);
00197 
00198 #if (ERANGE != EINVAL)
00199     case ERANGE : // untranslatable character
00200       ACE_THROW (CORBA::DATA_CONVERSION (CORBA::OMGVMCID | 1,
00201                                          CORBA::COMPLETED_YES));
00202       ACE_NOTREACHED (break);
00203 #endif
00204 
00205     default :
00206       ACE_THROW (CORBA::MARSHAL (0, CORBA::COMPLETED_YES));
00207 
00208     }
00209 }

void TAO_OutputCDR::throw_stub_exception int  error_num  )  [static]
 

Definition at line 158 of file CDR.cpp.

References ACE_THROW.

00159 {
00160   switch (error_num)
00161     {
00162     case 0 :
00163       break;
00164     case EINVAL : // wchar from a GIOP 1.0
00165       ACE_THROW (CORBA::MARSHAL (CORBA::OMGVMCID | 5, CORBA::COMPLETED_NO));
00166       ACE_NOTREACHED (break);
00167 #if (ERANGE != EINVAL)
00168     case ERANGE : // untranslatable character
00169       ACE_THROW (CORBA::DATA_CONVERSION (CORBA::OMGVMCID | 1,
00170                                          CORBA::COMPLETED_NO));
00171       ACE_NOTREACHED (break);
00172 #endif
00173     case EACCES : // wchar but no codeset
00174       ACE_THROW (CORBA::INV_OBJREF (CORBA::OMGVMCID | 2, CORBA::COMPLETED_NO));
00175       ACE_NOTREACHED (break);
00176     default :
00177       ACE_THROW (CORBA::MARSHAL ());
00178     }
00179 }

ACE_INLINE ACE_Time_Value * TAO_OutputCDR::timeout void   )  const
 

Maximum time to wait for outgoing message to be sent.

Definition at line 55 of file CDR.i.

Referenced by TAO_On_Demand_Fragmentation_Strategy::fragment().

00056 {
00057   return this->timeout_;
00058 }


Friends And Related Function Documentation

friend class TAO_InputCDR [friend]
 

For reading from a output CDR stream.

Definition at line 93 of file CDR.h.


Member Data Documentation

TAO_GIOP_Fragmentation_Strategy* const TAO_OutputCDR::fragmentation_strategy_ [private]
 

Strategy that sends data currently marshaled into this TAO_OutputCDR stream if necessary.

Definition at line 218 of file CDR.h.

Referenced by fragment_stream().

int TAO_OutputCDR::message_semantics_ [private]
 

Twoway, oneway, reply?

See also:
TAO_Transport

Definition at line 233 of file CDR.h.

Referenced by message_attributes(), and message_semantics().

bool TAO_OutputCDR::more_fragments_ [private]
 

Are there more data fragments to come?

Definition at line 221 of file CDR.h.

Referenced by more_fragments().

CORBA::ULong TAO_OutputCDR::request_id_ [private]
 

Request ID for the request currently being marshaled.

Definition at line 224 of file CDR.h.

TAO_Stub* TAO_OutputCDR::stub_ [private]
 

Stub object associated with the request.

Definition at line 227 of file CDR.h.

Referenced by message_attributes(), and stub().

ACE_Time_Value* TAO_OutputCDR::timeout_ [private]
 

Request/reply send timeout.

Definition at line 236 of file CDR.h.


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 12:22:56 2006 for TAO by doxygen 1.3.6