#include <ValueBase.h>
Public Member Functions | |
TAO_ChunkInfo (CORBA::Boolean do_chunking=0, CORBA::Long init_level=0) | |
CORBA::Boolean | start_chunk (TAO_OutputCDR &strm) |
Methods for marshalling a valuetype. | |
CORBA::Boolean | end_chunk (TAO_OutputCDR &strm) |
CORBA::Boolean | handle_chunking (TAO_InputCDR &strm) |
Methods for unmarshalling a valuetype. | |
CORBA::Boolean | skip_chunks (TAO_InputCDR &strm) |
CORBA::Boolean | write_previous_chunk_size (TAO_OutputCDR &strm) |
CORBA::Boolean | reserve_chunk_size (TAO_OutputCDR &strm) |
Public Attributes | |
CORBA::Boolean | chunking_ |
CORBA::Long | value_nesting_level_ |
The level of nesting valuetypes. | |
char * | chunk_size_pos_ |
The starting position of the size of current chunk. | |
size_t | length_to_chunk_octets_pos_ |
char * | chunk_octets_end_pos_ |
The end position of current chunk. |
Definition at line 46 of file ValueBase.h.
TAO_ChunkInfo::TAO_ChunkInfo | ( | CORBA::Boolean | do_chunking = 0 , |
|
CORBA::Long | init_level = 0 | |||
) |
Definition at line 61 of file ValueBase.cpp.
: chunking_(do_chunking), value_nesting_level_(init_level), chunk_size_pos_ (0), length_to_chunk_octets_pos_ (0), chunk_octets_end_pos_ (0) { }
CORBA::Boolean TAO_ChunkInfo::end_chunk | ( | TAO_OutputCDR & | strm | ) |
This is called in the _tao_marshal_state (). This method writes the actual chunk size to the reserved chunk size space and writes an end tag with the negation value of current nesting level. A start_chunk() needs an end_chunk() to close the current chunk. It's also needed for writing the outmost endtag to the stream.
Definition at line 878 of file ValueBase.cpp.
{ if (this->chunking_) { // Write actual chunk size at the reserved chunk size place. if (! this->write_previous_chunk_size(strm)) { return false; } // Write an end tag which is negation of value_nesting_level_. if (! strm.write_long(- this->value_nesting_level_)) { return false; } // -- this->value_nesting_level_; if ( -- this->value_nesting_level_ == 0 ) { // ending chunk for outermost value this->chunking_ = 0; } } return true; }
CORBA::Boolean TAO_ChunkInfo::handle_chunking | ( | TAO_InputCDR & | strm | ) |
Methods for unmarshalling a valuetype.
This is called in the _tao_unmarshal_state () to read the chunk size or an end tag.
Definition at line 971 of file ValueBase.cpp.
{ if (!this->chunking_) { return 1; } char* the_rd_ptr = strm.start()->rd_ptr (); //This case could happen if a handle_chunking() reads a chunk size //and then calls the handle_chunking() again without reading the chunk data. //The handle_chunking() called continuously without reading the chunk data //only happens at the beginning of _tao_unmarshal_state() in a valuetype //that has parents. if (the_rd_ptr < this->chunk_octets_end_pos_) { ++this->value_nesting_level_; return 1; } //Safty check if reading is out of range of current chunk. if (this->chunk_octets_end_pos_ != 0 && the_rd_ptr > this->chunk_octets_end_pos_) { return 0; } // Read a long value that might be an endtag, the chunk size or the value tag // of the nested valuetype. CORBA::Long tag; if (!strm.read_long (tag)) { return 0; } if (tag < 0) { // tag is an end tag if (-tag > this->value_nesting_level_) { ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("TAO (%P|%t) - TAO_ChunkInfo::handle_chunking, received end tag ") ACE_TEXT ("%d > value_nesting_level %d\n"), -tag, this->value_nesting_level_), 0); } this->value_nesting_level_ = - tag; --this->value_nesting_level_; this->chunk_octets_end_pos_ = 0; // Continue reading so that we can read the outmost endtag. This // would simplify the implementation in the derived valuetype. if (this->value_nesting_level_ > 0) { this->handle_chunking(strm); } } else if (tag < TAO_OBV_GIOP_Flags::Value_tag_base) { // Read the chunk size of another chunk. this->chunk_octets_end_pos_ = strm.rd_ptr () + tag; ++this->value_nesting_level_; } else // (tag >= 0x7fffff00) { // This should not happen since the valuetag of the nested // values are always unmarshalled in the // ValueBase::_tao_unmarshal_pre(). return 0; } return 1; }
CORBA::Boolean TAO_ChunkInfo::reserve_chunk_size | ( | TAO_OutputCDR & | strm | ) |
Reserve space for chunk size. The memory in the stream will be overwritten after all the chunk data is written. This method only allows the reservasion being made once if the reserved space has not been overwritten.
Definition at line 939 of file ValueBase.cpp.
{ // This is called in the start_chunk(). // Reserve the chunk size the first time the start_chunk () is called // if there are several start_chunk () called continuously without // calling end_chunk (). This could happen in the _tao_marshal_state() // in the most derived valuetype. if (this->chunk_size_pos_ == 0) { // Align the wr_ptr before we reserve the space for chunk size. strm.align_write_ptr (ACE_CDR::LONG_SIZE); // Remember begin of the chunk (at chunk size position) that is needed // when we write back actual chunk size to the stream. this->chunk_size_pos_ = strm.current ()->wr_ptr (); // Insert four bytes here as a place-holder, we need to go back // later and write the actual size. if (! strm.write_long (0)) { return 0; } // Remember length before writing chunk data. This is used to calculate // the actual size of the chunk. this->length_to_chunk_octets_pos_ = strm.total_length (); } return 1; }
CORBA::Boolean TAO_ChunkInfo::skip_chunks | ( | TAO_InputCDR & | strm | ) |
This is called in the _tao_unmarshal_state () to skip the rest chunks until the outmost endtag (-1) if the value is truncated to its truncatable parent.
Definition at line 1051 of file ValueBase.cpp.
{ if (!this->chunking_) { return 1; } // This function is called after reading data of the truncated parent and // skips the remaining chunks until the outmost endtag (-1). // The tag read here is suppoused to be an endtag. CORBA::Long tag; if (!strm.read_long(tag)) { return 0; } // end of the whole valuetype. if (tag == -1) { return 1; } else if (tag < 0) { // continue skip the chunk. return this->skip_chunks (strm); } else if (tag < TAO_OBV_GIOP_Flags::Value_tag_base) { // Read the chunk size and move forward to skip the data. ACE_Message_Block* current = const_cast<ACE_Message_Block*>(strm.start ()); current->rd_ptr (tag); return this->skip_chunks (strm); } else return 0; }
CORBA::Boolean TAO_ChunkInfo::start_chunk | ( | TAO_OutputCDR & | strm | ) |
Methods for marshalling a valuetype.
Methods to support chunking. Note: These methods are called for both chunking and non-chunking valuetype. These methods checks the chunking_ flag. If it's set to be false the methods return true rightaway. This is called in the _tao_marshal_state (). This method reserves space for the chunk size of the next chunk and also increments the nesting level. The reservasion actually occurs the first time that the start_chunk is called if there are multiple continuous start_chunk() calls without the close_chunk() called in between.
Definition at line 859 of file ValueBase.cpp.
{ // If chunking, reserve the space for the chunk size of next chunk // and increase the nesting level. if (this->chunking_) { if (! reserve_chunk_size(strm)) { return false; } ++this->value_nesting_level_; } return true; }
CORBA::Boolean TAO_ChunkInfo::write_previous_chunk_size | ( | TAO_OutputCDR & | strm | ) |
This is called in end_chunk(). It writes the actual chunk size to the reserved chunk size space.
Definition at line 906 of file ValueBase.cpp.
{ if (this->chunk_size_pos_ != 0) { // Calculate the chunk size. CORBA::Long const chunk_size = strm.total_length () - this->length_to_chunk_octets_pos_; // This should not happen since this is called in end_chunk() and // the idl generated code always have the matched start_chunk() and // end_chunk() pair. There is always data written to the stream between // the start_chunk() and end_chunk() calls. if (chunk_size == 0) { return false; } // Write the actual chunk size to the reserved chunk size position // in the stream. if (!strm.replace (chunk_size, this->chunk_size_pos_)) { return false; } // We finish writing the actual chunk size, now we need reset the state. this->chunk_size_pos_ = 0; this->length_to_chunk_octets_pos_ = 0; } return true; }
The end position of current chunk.
Definition at line 104 of file ValueBase.h.
The starting position of the size of current chunk.
Definition at line 98 of file ValueBase.h.
A flag to indicate that this instance is actually involved in a chunked or truncatable valuetype.
Definition at line 93 of file ValueBase.h.
The length of CDR stream from the begining to the current chunk data starting position. Used to calculate the chunk size across multiple chained ACE_Message_Blocks.
Definition at line 102 of file ValueBase.h.
The level of nesting valuetypes.
Definition at line 96 of file ValueBase.h.