ACE_RMCast::Fragment Class Reference

#include <Fragment.h>

Inheritance diagram for ACE_RMCast::Fragment:

Inheritance graph
[legend]
Collaboration diagram for ACE_RMCast::Fragment:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Fragment (Parameters const &params)
virtual void send (Message_ptr m)

Public Attributes

Parameters const & params_

Private Attributes

Mutex mutex_
u64 sn_

Constructor & Destructor Documentation

ACE_RMCast::Fragment::Fragment Parameters const &  params  ) 
 

Definition at line 16 of file Fragment.cpp.

00017       : params_ (params),
00018         sn_ (1)
00019   {
00020   }


Member Function Documentation

void ACE_RMCast::Fragment::send Message_ptr  m  )  [virtual]
 

Reimplemented from ACE_RMCast::Out_Element.

Definition at line 23 of file Fragment.cpp.

References ACE_RMCast::Data::buf(), ACE_RMCast::Lock, ACE_RMCast::Parameters::max_packet_size(), ACE_RMCast::max_service_size, ACE_RMCast::Message_ptr, ACE_RMCast::Profile_ptr, ACE_RMCast::Data::size(), ACE_RMCast::u32, and ACE_RMCast::u64.

00024   {
00025     if (Data const* data = static_cast<Data const*> (m->find (Data::id)))
00026     {
00027       size_t max_payload_size (
00028         params_.max_packet_size () - max_service_size);
00029 
00030       if (data->size () <= max_payload_size)
00031       {
00032         u64 sn;
00033         {
00034           Lock l (mutex_);
00035           sn = sn_++;
00036         }
00037 
00038         m->add (Profile_ptr (new SN (sn)));
00039 
00040         out_->send (m);
00041         return;
00042       }
00043 
00044       char const* p = data->buf ();
00045       size_t size (data->size ());
00046 
00047       // Need fragmentation.
00048       //
00049       u32 packets (size / max_payload_size + (size % max_payload_size ? 1 : 0));
00050 
00051       // cerr << "size : " << size << endl
00052       //      << "packs: " << packets << endl;
00053 
00054       for (u32 i (1); i <= packets; ++i)
00055       {
00056         Message_ptr part (new Message);
00057 
00058         size_t s (i == packets ? size % max_payload_size : max_payload_size);
00059 
00060         // cerr << "pack: " << s << endl;
00061 
00062         u64 sn;
00063         {
00064           Lock l (mutex_);
00065           sn = sn_++;
00066         }
00067 
00068         part->add (Profile_ptr (new SN (sn)));
00069         part->add (Profile_ptr (new Part (i, packets, size)));
00070         part->add (Profile_ptr (new Data (p, s)));
00071 
00072         out_->send (part);
00073 
00074         p += s;
00075       }
00076     }
00077   }


Member Data Documentation

Mutex ACE_RMCast::Fragment::mutex_ [private]
 

Definition at line 27 of file Fragment.h.

Parameters const& ACE_RMCast::Fragment::params_
 

Definition at line 24 of file Fragment.h.

u64 ACE_RMCast::Fragment::sn_ [private]
 

Definition at line 28 of file Fragment.h.


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 11:41:06 2006 for ACE_RMCast by doxygen 1.3.6