#include <UIPMC_Message_Block_Data_Iterator.h>
Collaboration diagram for UIPMC_Message_Block_Data_Iterator:
Public Member Functions | |
UIPMC_Message_Block_Data_Iterator (iovec *iov, int iovcnt) | |
Constructor. | |
size_t | next_block (size_t max_length, iovec &block) |
Private Types | |
enum | State { INTER_BLOCK, INTRA_BLOCK } |
Private Attributes | |
iovec * | iov_ |
int | iovcnt_ |
char * | iov_ptr_ |
int | iov_index_ |
size_t | iov_len_left_ |
State | state_ |
Definition at line 34 of file UIPMC_Message_Block_Data_Iterator.h.
|
Definition at line 46 of file UIPMC_Message_Block_Data_Iterator.h.
00047 { 00048 INTER_BLOCK, 00049 INTRA_BLOCK 00050 }; |
|
Constructor.
Definition at line 7 of file UIPMC_Message_Block_Data_Iterator.cpp.
00007 : 00008 iov_ (iov), 00009 iovcnt_ (iovcnt), 00010 iov_ptr_ (0), 00011 iov_index_ (0), 00012 iov_len_left_ (0), 00013 state_ (INTER_BLOCK) 00014 { 00015 } |
|
Get the next data block that has a size less than or equal to max_length. Return the length of the block returned. Definition at line 18 of file UIPMC_Message_Block_Data_Iterator.cpp. References INTER_BLOCK, INTRA_BLOCK, iov_, iovec::iov_base, iov_index_, iovec::iov_len, iov_len_left_, iov_ptr_, and iovcnt_. Referenced by TAO_UIPMC_Transport::send().
00020 { 00021 if (this->state_ == INTER_BLOCK) 00022 { 00023 // Check that there are some iovec buffers left. 00024 if (this->iov_index_ >= this->iovcnt_) 00025 return 0; 00026 00027 00028 size_t current_iov_len = 00029 this->iov_[this->iov_index_].iov_len; 00030 00031 if (current_iov_len <= max_length) 00032 { 00033 // Return the full data portion. 00034 block.iov_len = static_cast<u_long> (current_iov_len); 00035 block.iov_base = this->iov_[this->iov_index_].iov_base; 00036 00037 // Go to the next block. 00038 this->iov_index_++; 00039 00040 return current_iov_len; 00041 } 00042 else 00043 { 00044 // Let the caller use the first part of this 00045 // message block. 00046 block.iov_len = static_cast<u_long> (max_length); 00047 block.iov_base = this->iov_[this->iov_index_].iov_base; 00048 00049 // Break up the block. 00050 this->iov_len_left_ = current_iov_len - max_length; 00051 this->iov_ptr_ = 00052 reinterpret_cast<char *> (reinterpret_cast<char *> (block.iov_base) 00053 + max_length); 00054 this->state_ = INTRA_BLOCK; 00055 00056 return max_length; 00057 } 00058 } 00059 else 00060 { 00061 // Currently scanning a split block. 00062 if (this->iov_len_left_ <= max_length) 00063 { 00064 // Return everything that's left in the block. 00065 block.iov_len = static_cast<u_long> (this->iov_len_left_); 00066 block.iov_base = this->iov_ptr_; 00067 00068 // Go to the next block. 00069 this->iov_index_++; 00070 00071 // Update the state. 00072 this->state_ = INTER_BLOCK; 00073 00074 return this->iov_len_left_; 00075 } 00076 else 00077 { 00078 // Split a little more off the block. 00079 block.iov_len = static_cast<u_long> (this->iov_len_left_); 00080 block.iov_base = this->iov_ptr_; 00081 00082 this->iov_len_left_ -= max_length; 00083 this->iov_ptr_ += max_length; 00084 return max_length; 00085 } 00086 } 00087 } |
|
Definition at line 52 of file UIPMC_Message_Block_Data_Iterator.h. Referenced by next_block(). |
|
Definition at line 57 of file UIPMC_Message_Block_Data_Iterator.h. Referenced by next_block(). |
|
Definition at line 60 of file UIPMC_Message_Block_Data_Iterator.h. Referenced by next_block(). |
|
Definition at line 56 of file UIPMC_Message_Block_Data_Iterator.h. Referenced by next_block(). |
|
Definition at line 53 of file UIPMC_Message_Block_Data_Iterator.h. Referenced by next_block(). |
|
Definition at line 63 of file UIPMC_Message_Block_Data_Iterator.h. |