Public Member Functions | Private Types | Private Attributes

UIPMC_Message_Block_Data_Iterator Class Reference

This is a help class for iterating through ACE_Message_Blocks and to segment them into MIOP packets. More...

#include <UIPMC_Message_Block_Data_Iterator.h>

List of all members.

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_

Detailed Description

This is a help class for iterating through ACE_Message_Blocks and to segment them into MIOP packets.

Definition at line 34 of file UIPMC_Message_Block_Data_Iterator.h.


Member Enumeration Documentation

Enumerator:
INTER_BLOCK 
INTRA_BLOCK 

Definition at line 46 of file UIPMC_Message_Block_Data_Iterator.h.

  {
    INTER_BLOCK,
    INTRA_BLOCK
  };


Constructor & Destructor Documentation

UIPMC_Message_Block_Data_Iterator::UIPMC_Message_Block_Data_Iterator ( iovec *  iov,
int  iovcnt 
)

Constructor.

Definition at line 7 of file UIPMC_Message_Block_Data_Iterator.cpp.

                                                                                            :
  iov_ (iov),
  iovcnt_ (iovcnt),
  iov_ptr_ (0),
  iov_index_ (0),
  iov_len_left_ (0),
  state_ (INTER_BLOCK)
{
}


Member Function Documentation

size_t UIPMC_Message_Block_Data_Iterator::next_block ( size_t  max_length,
iovec &  block 
)

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.

{
  if (this->state_ == INTER_BLOCK)
    {
      // Check that there are some iovec buffers left.
      if (this->iov_index_ >= this->iovcnt_)
        return 0;


      size_t current_iov_len =
                    this->iov_[this->iov_index_].iov_len;

      if (current_iov_len <= max_length)
        {
          // Return the full data portion.
          block.iov_len = static_cast<u_long> (current_iov_len);
          block.iov_base = this->iov_[this->iov_index_].iov_base;

          // Go to the next block.
          this->iov_index_++;

          return current_iov_len;
        }
      else
        {
          // Let the caller use the first part of this
          // message block.
          block.iov_len = static_cast<u_long> (max_length);
          block.iov_base = this->iov_[this->iov_index_].iov_base;

          // Break up the block.
          this->iov_len_left_ = current_iov_len - max_length;
          this->iov_ptr_ =
            reinterpret_cast<char *> (reinterpret_cast<char *> (block.iov_base)
                                  + max_length);
          this->state_ = INTRA_BLOCK;

          return max_length;
        }
    }
  else
    {
      // Currently scanning a split block.
      if (this->iov_len_left_ <= max_length)
        {
          // Return everything that's left in the block.
          block.iov_len = static_cast<u_long> (this->iov_len_left_);
          block.iov_base = this->iov_ptr_;

          // Go to the next block.
          this->iov_index_++;

          // Update the state.
          this->state_ = INTER_BLOCK;

          return this->iov_len_left_;
        }
      else
        {
          // Split a little more off the block.
          block.iov_len = static_cast<u_long> (this->iov_len_left_);
          block.iov_base = this->iov_ptr_;

          this->iov_len_left_ -= max_length;
          this->iov_ptr_ += max_length;
          return max_length;
        }
    }
}


Member Data Documentation

Definition at line 52 of file UIPMC_Message_Block_Data_Iterator.h.

Definition at line 57 of file UIPMC_Message_Block_Data_Iterator.h.

Definition at line 60 of file UIPMC_Message_Block_Data_Iterator.h.

Definition at line 56 of file UIPMC_Message_Block_Data_Iterator.h.

Definition at line 53 of file UIPMC_Message_Block_Data_Iterator.h.

Definition at line 63 of file UIPMC_Message_Block_Data_Iterator.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines