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 22 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.

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


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 Sun Jan 27 13:03:05 2008 for ACE_RMCast by doxygen 1.3.6