A CDR stream for writing, i.e. for marshalling. More...
#include <CDR.h>
Public Types | |
typedef ACE_Hash_Map_Manager < ACE_CString, char *, ACE_Null_Mutex > | Repo_Id_Map |
typedef Repo_Id_Map | Codebase_URL_Map |
typedef ACE_Hash_Map_Manager < void *, char *, ACE_Null_Mutex > | Value_Map |
typedef TAO_Intrusive_Ref_Count_Object < Repo_Id_Map, ACE_Null_Mutex > | RC_Repo_Id_Map |
typedef TAO_Intrusive_Ref_Count_Object < Codebase_URL_Map, ACE_Null_Mutex > | RC_Codebase_URL_Map |
typedef TAO_Intrusive_Ref_Count_Object < Value_Map, ACE_Null_Mutex > | RC_Value_Map |
typedef TAO_Intrusive_Ref_Count_Handle < RC_Repo_Id_Map > | Repo_Id_Map_Handle |
typedef TAO_Intrusive_Ref_Count_Handle < RC_Codebase_URL_Map > | Codebase_URL_Map_Handle |
typedef TAO_Intrusive_Ref_Count_Handle < RC_Value_Map > | Value_Map_Handle |
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) |
Repo_Id_Map_Handle & | get_repo_id_map () |
Value_Map_Handle & | get_value_map () |
void | set_repo_id_map (Repo_Id_Map_Handle &map) |
void | set_value_map (Value_Map_Handle &map) |
void | reset_vt_indirect_maps () |
int | offset (char *pos) |
Calculate the offset between pos and current wr_ptr. | |
Outgoing GIOP Fragment Related Methods | |
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, TAO_Message_Semantics message_semantics, ACE_Time_Value *timeout) |
Set fragmented message attributes. | |
CORBA::ULong | request_id (void) const |
Fragmented message request ID. | |
TAO_Stub * | stub (void) const |
Stub object associated with the request. | |
TAO_Message_Semantics | message_semantics (void) const |
Message semantics (twoway, oneway, reply). | |
ACE_Time_Value * | timeout (void) const |
Maximum time to wait for outgoing message to be sent. | |
Static Public Member Functions | |
static void | throw_stub_exception (int error_num) |
static void | throw_skel_exception (int error_num) |
Private Member Functions | |
TAO_OutputCDR (const TAO_OutputCDR &rhs) | |
TAO_OutputCDR & | operator= (const TAO_OutputCDR &rhs) |
Private Attributes | |
Repo_Id_Map_Handle | repo_id_map_ |
These maps are used by valuetype indirection support. | |
Value_Map_Handle | value_map_ |
Outgoing GIOP Fragment Related Attributes | |
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_Stub * | stub_ |
Stub object associated with the request. | |
TAO_Message_Semantics | message_semantics_ |
Twoway, oneway, reply? | |
ACE_Time_Value * | timeout_ |
Request/reply send timeout. | |
Friends | |
class | TAO_InputCDR |
For reading from a output CDR stream. |
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 91 of file CDR.h.
typedef ACE_Hash_Map_Manager<ACE_CString, char*, ACE_Null_Mutex> TAO_OutputCDR::Repo_Id_Map |
typedef ACE_Hash_Map_Manager<void*, char*, ACE_Null_Mutex> TAO_OutputCDR::Value_Map |
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 size bytes in the internal buffer, if size == 0 it allocates the default size.
Definition at line 57 of file CDR.cpp.
: ACE_OutputCDR (size, byte_order, buffer_allocator, data_block_allocator, message_block_allocator, memcpy_tradeoff, major_version, minor_version) , fragmentation_strategy_ (0) , more_fragments_ (false) , request_id_ (0) , stub_ (0) , message_semantics_ (TAO_TWOWAY_REQUEST) , timeout_ (0) { ACE_FUNCTION_TIMEPROBE (TAO_OUTPUT_CDR_CTOR1_ENTER); #if defined (TAO_ZERO_TAO_OUTPUTCDR_ALLOCATED_BUFFERS) // Zero out the buffer if we allocated the buffer. if (size == 0) (void) ACE_OS::memset (this->current()->wr_ptr(), 0, this->current()->space()); #endif /* TAO_ZERO_TAO_OUTPUTCDR_ALLOCATED_BUFFERS */ }
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 data, since it did not allocated it.
Definition at line 91 of file CDR.cpp.
: ACE_OutputCDR (data, size, byte_order, buffer_allocator, data_block_allocator, message_block_allocator, memcpy_tradeoff, major_version, minor_version) , fragmentation_strategy_ (0) , more_fragments_ (false) , request_id_ (0) , stub_ (0) , message_semantics_ (TAO_TWOWAY_REQUEST) , timeout_ (0) { ACE_FUNCTION_TIMEPROBE (TAO_OUTPUT_CDR_CTOR2_ENTER); }
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.
: ACE_OutputCDR (data, size, byte_order, buffer_allocator, data_block_allocator, message_block_allocator, memcpy_tradeoff, major_version, minor_version) , fragmentation_strategy_ (fs) , more_fragments_ (false) , request_id_ (0) , stub_ (0) , message_semantics_ (TAO_TWOWAY_REQUEST) , timeout_ (0) { ACE_FUNCTION_TIMEPROBE (TAO_OUTPUT_CDR_CTOR3_ENTER); }
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 data, since it did not allocate it.
Definition at line 148 of file CDR.cpp.
: ACE_OutputCDR (data, byte_order, memcpy_tradeoff, major_version, minor_version) , fragmentation_strategy_ (0) , more_fragments_ (false) , request_id_ (0) , stub_ (0) , message_semantics_ (TAO_TWOWAY_REQUEST) , timeout_ (0) { ACE_FUNCTION_TIMEPROBE (TAO_OUTPUT_CDR_CTOR4_ENTER); }
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 data, since it did not allocated it.
Definition at line 168 of file CDR.cpp.
: ACE_OutputCDR (data_block, byte_order, message_block_allocator, memcpy_tradeoff, major_version, minor_version) , fragmentation_strategy_ (fs) , more_fragments_ (false) , request_id_ (0) , stub_ (0) , message_semantics_ (TAO_TWOWAY_REQUEST) , timeout_ (0) { ACE_FUNCTION_TIMEPROBE (TAO_OUTPUT_CDR_CTOR5_ENTER); }
TAO_OutputCDR::TAO_OutputCDR | ( | const TAO_OutputCDR & | rhs | ) | [private] |
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.
{ if (this->fragmentation_strategy_) { return (this->fragmentation_strategy_->fragment (*this, pending_alignment, pending_length) == 0); } return true; // Success. }
TAO_OutputCDR::Repo_Id_Map_Handle & TAO_OutputCDR::get_repo_id_map | ( | ) |
These methods are used by valuetype indirection support. Accessor to the indirect maps.
Definition at line 70 of file CDR.inl.
{ return this->repo_id_map_; }
TAO_OutputCDR::Value_Map_Handle & TAO_OutputCDR::get_value_map | ( | ) |
Definition at line 84 of file CDR.inl.
{ return this->value_map_; }
void TAO_OutputCDR::get_version | ( | TAO_GIOP_Message_Version & | giop_version | ) |
Definition at line 63 of file CDR.inl.
{ giop_version.major = this->major_version_; giop_version.minor = this->minor_version_; }
void TAO_OutputCDR::message_attributes | ( | CORBA::ULong | request_id, | |
TAO_Stub * | stub, | |||
TAO_Message_Semantics | message_semantics, | |||
ACE_Time_Value * | timeout | |||
) |
Set fragmented message attributes.
Definition at line 27 of file CDR.inl.
{ this->request_id_ = request_id; this->stub_ = stub; this->message_semantics_ = message_semantics; this->timeout_ = timeout; }
TAO_Message_Semantics TAO_OutputCDR::message_semantics | ( | void | ) | const |
Message semantics (twoway, oneway, reply).
Definition at line 51 of file CDR.inl.
{ return this->message_semantics_; }
bool TAO_OutputCDR::more_fragments | ( | void | ) | const |
Are there more data fragments to come?
Definition at line 15 of file CDR.inl.
{ return this->more_fragments_; }
void TAO_OutputCDR::more_fragments | ( | bool | more | ) |
Specify whether there are more data fragments to come.
Definition at line 21 of file CDR.inl.
{ this->more_fragments_ = more; }
int TAO_OutputCDR::offset | ( | char * | pos | ) |
Calculate the offset between pos and current wr_ptr.
Definition at line 262 of file CDR.cpp.
{ int offset = 0; const ACE_Message_Block * cur_mb = this->begin (); char* wr_ptr = this->current ()->wr_ptr (); bool found = false; while (cur_mb != this->end ()) { if (pos >= cur_mb->rd_ptr () && pos <= cur_mb->wr_ptr ()) { offset += (cur_mb->wr_ptr () - pos); found = true; } else if (found) { offset += cur_mb->length (); } if (wr_ptr == cur_mb->wr_ptr ()) break; cur_mb = cur_mb->cont(); } if (!found || wr_ptr != cur_mb->wr_ptr ()) { throw ::CORBA::INTERNAL (); } return offset; }
TAO_OutputCDR& TAO_OutputCDR::operator= | ( | const TAO_OutputCDR & | rhs | ) | [private] |
CORBA::ULong TAO_OutputCDR::request_id | ( | void | ) | const |
void TAO_OutputCDR::reset_vt_indirect_maps | ( | ) |
If indirect map is not nil and not empty, unbind all entries. Called after marshalling.
Definition at line 110 of file CDR.inl.
{ if (! this->repo_id_map_.is_nil () && this->repo_id_map_->get()->current_size () != 0) { this->repo_id_map_->get()->unbind_all (); } #ifdef TAO_HAS_VALUETYPE_CODEBASE if (! this->codebase_map_.is_nil () && this->codebase_map_->get()->current_size () != 0) { this->codebase_map_->get()->unbind_all (); } #endif if (! this->value_map_.is_nil () && this->value_map_->get()->current_size () != 0) { this->value_map_->get()->unbind_all (); } }
void TAO_OutputCDR::set_repo_id_map | ( | TAO_OutputCDR::Repo_Id_Map_Handle & | map | ) |
Updater of the maps. These updaters are used to make indirect maps in original stream take effect even during marshalling/demarshalling a redirected stream.
Definition at line 90 of file CDR.inl.
{ this->repo_id_map_ = map; }
void TAO_OutputCDR::set_value_map | ( | TAO_OutputCDR::Value_Map_Handle & | map | ) |
Definition at line 104 of file CDR.inl.
{ this->value_map_ = map; }
TAO_Stub * TAO_OutputCDR::stub | ( | void | ) | const |
void TAO_OutputCDR::throw_skel_exception | ( | int | error_num | ) | [static] |
Definition at line 216 of file CDR.cpp.
{ switch (error_num) { case 0 : break; case EINVAL : // wchar from a GIOP 1.0 throw ::CORBA::MARSHAL (CORBA::OMGVMCID | 5, CORBA::COMPLETED_YES); ACE_NOTREACHED (break); case EACCES : // wchar but no codeset throw ::CORBA::BAD_PARAM (CORBA::OMGVMCID | 23, CORBA::COMPLETED_YES); ACE_NOTREACHED (break); #if (ERANGE != EINVAL) case ERANGE : // untranslatable character throw ::CORBA::DATA_CONVERSION (CORBA::OMGVMCID | 1, CORBA::COMPLETED_YES); ACE_NOTREACHED (break); #endif default : throw ::CORBA::MARSHAL (0, CORBA::COMPLETED_YES); } }
void TAO_OutputCDR::throw_stub_exception | ( | int | error_num | ) | [static] |
Definition at line 192 of file CDR.cpp.
{ switch (error_num) { case 0 : break; case EINVAL : // wchar from a GIOP 1.0 throw ::CORBA::MARSHAL (CORBA::OMGVMCID | 5, CORBA::COMPLETED_NO); ACE_NOTREACHED (break); #if (ERANGE != EINVAL) case ERANGE : // untranslatable character throw ::CORBA::DATA_CONVERSION (CORBA::OMGVMCID | 1, CORBA::COMPLETED_NO); ACE_NOTREACHED (break); #endif case EACCES : // wchar but no codeset throw ::CORBA::INV_OBJREF (CORBA::OMGVMCID | 2, CORBA::COMPLETED_NO); ACE_NOTREACHED (break); default : throw ::CORBA::MARSHAL (); } }
ACE_Time_Value * TAO_OutputCDR::timeout | ( | void | ) | const |
friend class TAO_InputCDR [friend] |
TAO_GIOP_Fragmentation_Strategy* const TAO_OutputCDR::fragmentation_strategy_ [private] |
Strategy that sends data currently marshaled into this TAO_OutputCDR stream if necessary.
bool TAO_OutputCDR::more_fragments_ [private] |
CORBA::ULong TAO_OutputCDR::request_id_ [private] |
TAO_Stub* TAO_OutputCDR::stub_ [private] |
ACE_Time_Value* TAO_OutputCDR::timeout_ [private] |
Value_Map_Handle TAO_OutputCDR::value_map_ [private] |