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 (ACE_Data_Block *data, int byte_order=ACE_CDR_BYTE_ORDER, ACE_Allocator *message_block_allocator=0, size_t memcpy_tradeoff=0, TAO_GIOP_Fragmentation_Strategy *fs=0, ACE_CDR::Octet major_version=TAO_DEF_GIOP_MAJOR, ACE_CDR::Octet minor_version=TAO_DEF_GIOP_MINOR)
 ~TAO_OutputCDR (void)
 Destructor.

void get_version (TAO_GIOP_Message_Version &giop_version)
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 84 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 57 of file CDR.cpp.

References ACE_FUNCTION_TIMEPROBE, ACE_OutputCDR::current(), ACE_OS::memset(), CORBA::Octet, and ACE_Message_Block::space().

00065   : ACE_OutputCDR (size,
00066                    byte_order,
00067                    buffer_allocator,
00068                    data_block_allocator,
00069                    message_block_allocator,
00070                    memcpy_tradeoff,
00071                    major_version,
00072                    minor_version)
00073   , fragmentation_strategy_ (0)
00074   , more_fragments_ (false)
00075   , request_id_ (0)
00076   , stub_ (0)
00077   , message_semantics_ (-1)
00078   , timeout_ (0)
00079 {
00080   ACE_FUNCTION_TIMEPROBE (TAO_OUTPUT_CDR_CTOR1_ENTER);
00081 
00082 #if defined (TAO_ZERO_TAO_OUTPUTCDR_ALLOCATED_BUFFERS)
00083   // Zero out the buffer if we allocated the buffer.
00084   if (size == 0)
00085     (void) ACE_OS::memset (this->current()->wr_ptr(),
00086                            0,
00087                            this->current()->space());
00088 #endif /* TAO_ZERO_TAO_OUTPUTCDR_ALLOCATED_BUFFERS */
00089 }

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 91 of file CDR.cpp.

References ACE_FUNCTION_TIMEPROBE, and CORBA::Octet.

00100   : ACE_OutputCDR (data,
00101                    size,
00102                    byte_order,
00103                    buffer_allocator,
00104                    data_block_allocator,
00105                    message_block_allocator,
00106                    memcpy_tradeoff,
00107                    major_version,
00108                    minor_version)
00109   , fragmentation_strategy_ (0)
00110   , more_fragments_ (false)
00111   , request_id_ (0)
00112   , stub_ (0)
00113   , message_semantics_ (-1)
00114   , timeout_ (0)
00115 {
00116   ACE_FUNCTION_TIMEPROBE (TAO_OUTPUT_CDR_CTOR2_ENTER);
00117 }

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 119 of file CDR.cpp.

References ACE_FUNCTION_TIMEPROBE, and CORBA::Octet.

00129   : ACE_OutputCDR (data,
00130                    size,
00131                    byte_order,
00132                    buffer_allocator,
00133                    data_block_allocator,
00134                    message_block_allocator,
00135                    memcpy_tradeoff,
00136                    major_version,
00137                    minor_version)
00138   , fragmentation_strategy_ (fs)
00139   , more_fragments_ (false)
00140   , request_id_ (0)
00141   , stub_ (0)
00142   , message_semantics_ (-1)
00143   , timeout_ (0)
00144 {
00145   ACE_FUNCTION_TIMEPROBE (TAO_OUTPUT_CDR_CTOR3_ENTER);
00146 }

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 148 of file CDR.cpp.

References ACE_FUNCTION_TIMEPROBE, and CORBA::Octet.

00153   : ACE_OutputCDR (data,
00154                    byte_order,
00155                    memcpy_tradeoff,
00156                    major_version,
00157                    minor_version)
00158   , fragmentation_strategy_ (0)
00159   , more_fragments_ (false)
00160   , request_id_ (0)
00161   , stub_ (0)
00162   , message_semantics_ (-1)
00163   , timeout_ (0)
00164 {
00165   ACE_FUNCTION_TIMEPROBE (TAO_OUTPUT_CDR_CTOR4_ENTER);
00166 }

TAO_OutputCDR::TAO_OutputCDR ACE_Data_Block data,
int  byte_order = ACE_CDR_BYTE_ORDER,
ACE_Allocator message_block_allocator = 0,
size_t  memcpy_tradeoff = 0,
TAO_GIOP_Fragmentation_Strategy fs = 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 data block, it will *not* remove , since it did not allocated it.

Definition at line 168 of file CDR.cpp.

References ACE_FUNCTION_TIMEPROBE, and CORBA::Octet.

00175   :  ACE_OutputCDR (data_block,
00176                     byte_order,
00177                     message_block_allocator,
00178                     memcpy_tradeoff,
00179                     major_version,
00180                     minor_version)
00181   , fragmentation_strategy_ (fs)
00182   , more_fragments_ (false)
00183   , request_id_ (0)
00184   , stub_ (0)
00185   , message_semantics_ (-1)
00186   , timeout_ (0)
00187 {
00188   ACE_FUNCTION_TIMEPROBE (TAO_OUTPUT_CDR_CTOR5_ENTER);
00189 }

TAO_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE TAO_OutputCDR::~TAO_OutputCDR void   ) 
 

Destructor.

Definition at line 8 of file CDR.inl.

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 246 of file CDR.cpp.

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

Referenced by operator<<().

00248 {
00249   if (this->fragmentation_strategy_)
00250     {
00251       return (this->fragmentation_strategy_->fragment (*this,
00252                                                        pending_alignment,
00253                                                        pending_length) == 0);
00254     }
00255 
00256   return true;  // Success.
00257 }

ACE_INLINE void TAO_OutputCDR::get_version TAO_GIOP_Message_Version giop_version  ) 
 

Definition at line 61 of file CDR.inl.

References TAO_GIOP_Message_Version::major, and TAO_GIOP_Message_Version::minor.

Referenced by TAO_On_Demand_Fragmentation_Strategy::fragment(), TAO_GIOP_Message_Base::generate_fragment_header(), TAO_GIOP_Message_Base::generate_locate_request_header(), TAO_GIOP_Message_Base::generate_reply_header(), TAO_GIOP_Message_Base::generate_request_header(), TAO_GIOP_Message_Base::is_ready_for_bidirectional(), TAO_ServerRequest::send_cached_reply(), TAO_ServerRequest::tao_send_reply_exception(), and TAO_GIOP_Message_Base::write_protocol_header().

00062 {
00063   giop_version.major = this->major_version_;
00064   giop_version.minor = this->minor_version_;
00065 }

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.inl.

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.inl.

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.inl.

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.inl.

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.inl.

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.inl.

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 216 of file CDR.cpp.

00217 {
00218   switch (error_num)
00219     {
00220     case 0 :
00221       break;
00222 
00223     case EINVAL : // wchar from a GIOP 1.0
00224       throw ::CORBA::MARSHAL (CORBA::OMGVMCID | 5, CORBA::COMPLETED_YES);
00225       ACE_NOTREACHED (break);
00226 
00227     case EACCES : // wchar but no codeset
00228       throw ::CORBA::BAD_PARAM (CORBA::OMGVMCID | 23,
00229                                    CORBA::COMPLETED_YES);
00230       ACE_NOTREACHED (break);
00231 
00232 #if (ERANGE != EINVAL)
00233     case ERANGE : // untranslatable character
00234       throw ::CORBA::DATA_CONVERSION (CORBA::OMGVMCID | 1,
00235                                          CORBA::COMPLETED_YES);
00236       ACE_NOTREACHED (break);
00237 #endif
00238 
00239     default :
00240       throw ::CORBA::MARSHAL (0, CORBA::COMPLETED_YES);
00241 
00242     }
00243 }

void TAO_OutputCDR::throw_stub_exception int  error_num  )  [static]
 

Definition at line 192 of file CDR.cpp.

00193 {
00194   switch (error_num)
00195     {
00196     case 0 :
00197       break;
00198     case EINVAL : // wchar from a GIOP 1.0
00199       throw ::CORBA::MARSHAL (CORBA::OMGVMCID | 5, CORBA::COMPLETED_NO);
00200       ACE_NOTREACHED (break);
00201 #if (ERANGE != EINVAL)
00202     case ERANGE : // untranslatable character
00203       throw ::CORBA::DATA_CONVERSION (CORBA::OMGVMCID | 1,
00204                                          CORBA::COMPLETED_NO);
00205       ACE_NOTREACHED (break);
00206 #endif
00207     case EACCES : // wchar but no codeset
00208       throw ::CORBA::INV_OBJREF (CORBA::OMGVMCID | 2, CORBA::COMPLETED_NO);
00209       ACE_NOTREACHED (break);
00210     default :
00211       throw ::CORBA::MARSHAL ();
00212     }
00213 }

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.inl.

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 88 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 219 of file CDR.h.

Referenced by fragment_stream().

int TAO_OutputCDR::message_semantics_ [private]
 

Twoway, oneway, reply?

See also:
TAO_Transport

Definition at line 234 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 222 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 225 of file CDR.h.

TAO_Stub* TAO_OutputCDR::stub_ [private]
 

Stub object associated with the request.

Definition at line 228 of file CDR.h.

Referenced by message_attributes(), and stub().

ACE_Time_Value* TAO_OutputCDR::timeout_ [private]
 

Request/reply send timeout.

Definition at line 237 of file CDR.h.


The documentation for this class was generated from the following files:
Generated on Sun Jan 27 13:15:46 2008 for TAO by doxygen 1.3.6