TAO_ECG_UDP_Request_Entry Class Reference

Keeps information about an incomplete request. More...

#include <ECG_CDR_Message_Receiver.h>

Collaboration diagram for TAO_ECG_UDP_Request_Entry:

Collaboration graph
[legend]
List of all members.

Public Types

enum  { ECG_DEFAULT_FRAGMENT_BUFSIZ = 8 }

Public Member Functions

 TAO_ECG_UDP_Request_Entry (CORBA::Boolean byte_order, CORBA::ULong request_id, CORBA::ULong request_size, CORBA::ULong fragment_count)
 Initialize the fragment, allocating memory, etc.

 ~TAO_ECG_UDP_Request_Entry (void)
int validate_fragment (CORBA::Boolean byte_order, CORBA::ULong request_size, CORBA::ULong fragment_size, CORBA::ULong fragment_offset, CORBA::ULong fragment_id, CORBA::ULong fragment_count) const
 Validate a fragment, it should be rejected if it is invalid..

int test_received (CORBA::ULong fragment_id) const
 Has fragment_id been received?

void mark_received (CORBA::ULong fragment_id)
 Mark fragment_id as received, reset timeout counter...

int complete (void) const
 Is the message complete?

char * fragment_buffer (CORBA::ULong fragment_offset)
 Return a buffer for the fragment at offset fragment_offset.


Private Member Functions

 TAO_ECG_UDP_Request_Entry (const TAO_ECG_UDP_Request_Entry &rhs)
TAO_ECG_UDP_Request_Entryoperator= (const TAO_ECG_UDP_Request_Entry &rhs)

Private Attributes

CORBA::Boolean byte_order_
CORBA::ULong request_id_
CORBA::ULong request_size_
CORBA::ULong fragment_count_
ACE_Message_Block payload_
CORBA::ULongreceived_fragments_
 This is a bit vector, used to keep track of the received buffers.

int own_received_fragments_
CORBA::ULong received_fragments_size_
CORBA::ULong default_received_fragments_ [ECG_DEFAULT_FRAGMENT_BUFSIZ]

Detailed Description

Keeps information about an incomplete request.

When a request arrives in fragments this object is used to keep track of the incoming data.

Definition at line 56 of file ECG_CDR_Message_Receiver.h.


Member Enumeration Documentation

anonymous enum
 

Enumeration values:
ECG_DEFAULT_FRAGMENT_BUFSIZ 

Definition at line 59 of file ECG_CDR_Message_Receiver.h.

00059        {
00060     ECG_DEFAULT_FRAGMENT_BUFSIZ = 8
00061   };


Constructor & Destructor Documentation

TAO_ECG_UDP_Request_Entry::TAO_ECG_UDP_Request_Entry CORBA::Boolean  byte_order,
CORBA::ULong  request_id,
CORBA::ULong  request_size,
CORBA::ULong  fragment_count
 

Initialize the fragment, allocating memory, etc.

Definition at line 37 of file ECG_CDR_Message_Receiver.cpp.

References ACE_NEW, default_received_fragments_, ECG_DEFAULT_FRAGMENT_BUFSIZ, fragment_count_, ACE_CDR::grow(), own_received_fragments_, payload_, received_fragments_, received_fragments_size_, request_size_, and ACE_Message_Block::wr_ptr().

00041   : byte_order_ (byte_order)
00042   , request_id_ (request_id)
00043   , request_size_ (request_size)
00044   , fragment_count_ (fragment_count)
00045 {
00046   ACE_CDR::grow (&this->payload_, this->request_size_);
00047   this->payload_.wr_ptr (request_size_);
00048 
00049   this->received_fragments_ = this->default_received_fragments_;
00050   this->own_received_fragments_ = 0;
00051   const int bits_per_ulong = sizeof(CORBA::ULong) * CHAR_BIT;
00052   this->received_fragments_size_ =
00053     this->fragment_count_ / bits_per_ulong + 1;
00054   if (this->received_fragments_size_ > ECG_DEFAULT_FRAGMENT_BUFSIZ)
00055     {
00056       ACE_NEW (this->received_fragments_,
00057                CORBA::ULong[this->received_fragments_size_]);
00058       this->own_received_fragments_ = 1;
00059     }
00060 
00061   for (CORBA::ULong i = 0; i < this->received_fragments_size_; ++i)
00062     this->received_fragments_[i] = 0;
00063   CORBA::ULong idx = this->fragment_count_ / bits_per_ulong;
00064   CORBA::ULong bit = this->fragment_count_ % bits_per_ulong;
00065   this->received_fragments_[idx] = (0xFFFFFFFF << bit);
00066 }

TAO_ECG_UDP_Request_Entry::~TAO_ECG_UDP_Request_Entry void   ) 
 

Definition at line 27 of file ECG_CDR_Message_Receiver.cpp.

References own_received_fragments_, and received_fragments_.

00028 {
00029   if (this->own_received_fragments_)
00030     {
00031       this->own_received_fragments_ = 0;
00032       delete[] this->received_fragments_;
00033     }
00034 }

TAO_ECG_UDP_Request_Entry::TAO_ECG_UDP_Request_Entry const TAO_ECG_UDP_Request_Entry rhs  )  [private]
 


Member Function Documentation

int TAO_ECG_UDP_Request_Entry::complete void   )  const
 

Is the message complete?

Definition at line 115 of file ECG_CDR_Message_Receiver.cpp.

References received_fragments_, and received_fragments_size_.

00116 {
00117   for (CORBA::ULong i = 0;
00118        i < this->received_fragments_size_;
00119        ++i)
00120     {
00121       if (this->received_fragments_[i] != 0xFFFFFFFF)
00122         return 0;
00123     }
00124   return 1;
00125 }

char * TAO_ECG_UDP_Request_Entry::fragment_buffer CORBA::ULong  fragment_offset  ) 
 

Return a buffer for the fragment at offset fragment_offset.

Definition at line 128 of file ECG_CDR_Message_Receiver.cpp.

References payload_, and ACE_Message_Block::rd_ptr().

00129 {
00130   return this->payload_.rd_ptr () + fragment_offset;
00131 }

void TAO_ECG_UDP_Request_Entry::mark_received CORBA::ULong  fragment_id  ) 
 

Mark fragment_id as received, reset timeout counter...

Definition at line 102 of file ECG_CDR_Message_Receiver.cpp.

References ACE_SET_BITS, and fragment_count_.

00103 {
00104   // Assume out-of-range fragments as received, so they are dropped...
00105   if (fragment_id > this->fragment_count_)
00106     return;
00107 
00108   const int bits_per_ulong = sizeof(CORBA::ULong) * CHAR_BIT;
00109   CORBA::ULong idx = fragment_id / bits_per_ulong;
00110   CORBA::ULong bit = fragment_id % bits_per_ulong;
00111   ACE_SET_BITS (this->received_fragments_[idx], 1<<bit);
00112 }

TAO_ECG_UDP_Request_Entry& TAO_ECG_UDP_Request_Entry::operator= const TAO_ECG_UDP_Request_Entry rhs  )  [private]
 

int TAO_ECG_UDP_Request_Entry::test_received CORBA::ULong  fragment_id  )  const
 

Has fragment_id been received?

Definition at line 89 of file ECG_CDR_Message_Receiver.cpp.

References ACE_BIT_ENABLED, and fragment_count_.

00090 {
00091   // Assume out-of-range fragments as received, so they are dropped...
00092   if (fragment_id > this->fragment_count_)
00093     return 1;
00094 
00095   const int bits_per_ulong = sizeof(CORBA::ULong) * CHAR_BIT;
00096   CORBA::ULong idx = fragment_id / bits_per_ulong;
00097   CORBA::ULong bit = fragment_id % bits_per_ulong;
00098   return ACE_BIT_ENABLED (this->received_fragments_[idx], 1<<bit);
00099 }

int TAO_ECG_UDP_Request_Entry::validate_fragment CORBA::Boolean  byte_order,
CORBA::ULong  request_size,
CORBA::ULong  fragment_size,
CORBA::ULong  fragment_offset,
CORBA::ULong  fragment_id,
CORBA::ULong  fragment_count
const
 

Validate a fragment, it should be rejected if it is invalid..

Definition at line 69 of file ECG_CDR_Message_Receiver.cpp.

References fragment_count_, and request_size_.

00075 {
00076   if (byte_order != this->byte_order_
00077       || request_size != this->request_size_
00078       || fragment_count != this->fragment_count_)
00079     return 0;
00080 
00081   if (fragment_offset >= request_size
00082       || fragment_offset + fragment_size > request_size)
00083     return 0;
00084 
00085   return 1;
00086 }


Member Data Documentation

CORBA::Boolean TAO_ECG_UDP_Request_Entry::byte_order_ [private]
 

This attributes should remain constant in all the fragments, used for validation....

Definition at line 99 of file ECG_CDR_Message_Receiver.h.

CORBA::ULong TAO_ECG_UDP_Request_Entry::default_received_fragments_[ECG_DEFAULT_FRAGMENT_BUFSIZ] [private]
 

Definition at line 110 of file ECG_CDR_Message_Receiver.h.

Referenced by TAO_ECG_UDP_Request_Entry().

CORBA::ULong TAO_ECG_UDP_Request_Entry::fragment_count_ [private]
 

Definition at line 102 of file ECG_CDR_Message_Receiver.h.

Referenced by mark_received(), TAO_ECG_UDP_Request_Entry(), test_received(), and validate_fragment().

int TAO_ECG_UDP_Request_Entry::own_received_fragments_ [private]
 

Definition at line 108 of file ECG_CDR_Message_Receiver.h.

Referenced by TAO_ECG_UDP_Request_Entry(), and ~TAO_ECG_UDP_Request_Entry().

ACE_Message_Block TAO_ECG_UDP_Request_Entry::payload_ [private]
 

Definition at line 104 of file ECG_CDR_Message_Receiver.h.

Referenced by fragment_buffer(), and TAO_ECG_UDP_Request_Entry().

CORBA::ULong* TAO_ECG_UDP_Request_Entry::received_fragments_ [private]
 

This is a bit vector, used to keep track of the received buffers.

Definition at line 107 of file ECG_CDR_Message_Receiver.h.

Referenced by complete(), TAO_ECG_UDP_Request_Entry(), and ~TAO_ECG_UDP_Request_Entry().

CORBA::ULong TAO_ECG_UDP_Request_Entry::received_fragments_size_ [private]
 

Definition at line 109 of file ECG_CDR_Message_Receiver.h.

Referenced by complete(), and TAO_ECG_UDP_Request_Entry().

CORBA::ULong TAO_ECG_UDP_Request_Entry::request_id_ [private]
 

Definition at line 100 of file ECG_CDR_Message_Receiver.h.

CORBA::ULong TAO_ECG_UDP_Request_Entry::request_size_ [private]
 

Definition at line 101 of file ECG_CDR_Message_Receiver.h.

Referenced by TAO_ECG_UDP_Request_Entry(), and validate_fragment().


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 13:16:27 2006 for TAO_RTEvent by doxygen 1.3.6