Generator Class Reference

#include <aggreg.h>

List of all members.

Public Member Functions

 Generator (void)
virtual ~Generator ()
void Reset (void)
int32s GetPackets (void)
bytestamp_t GetBytes (void)
bytestamp_t GetTime (void)
bytestamp_t GetByteStamp (void)
DOUBLE GetLoad (void)
int32s GetSources (void)
void AddSource (Source *pSrc)
void RemoveSource (Source *pSrc)
SourceRemoveSource (void)
void SetLoad (DOUBLE load)
Trace PeekNextPacket (void)
Trace GetNextPacket (void)

Public Attributes

int16u Preamble

Private Member Functions

SourceInsertInOrder (Source *pSrc)

Private Attributes

DList SRC
Trace NextPacket
bytestamp_t TotalBytes
int32s TotalPackets
bytestamp_t Elapsed
bytestamp_t ByteStamp


Detailed Description

Definition at line 24 of file aggreg.h.


Constructor & Destructor Documentation

Generator::Generator ( void   )  [inline]

Definition at line 66 of file aggreg.h.

00067     { 
00068         Preamble  = PREAMBLE;
00069         Reset();
00070     }

virtual Generator::~Generator (  )  [inline, virtual]

Definition at line 77 of file aggreg.h.

00077 {}


Member Function Documentation

void Generator::AddSource ( Source pSrc  )  [inline]

Definition at line 116 of file aggreg.h.

00116 { if(pSrc) InsertInOrder( pSrc ); }

bytestamp_t Generator::GetBytes ( void   )  [inline]

Definition at line 105 of file aggreg.h.

00105 { return TotalBytes;   }

bytestamp_t Generator::GetByteStamp ( void   )  [inline]

Definition at line 107 of file aggreg.h.

00107 { return ByteStamp;     }

DOUBLE Generator::GetLoad ( void   )  [inline]

Definition at line 108 of file aggreg.h.

00108 { return TotalBytes / Elapsed; }

Trace Generator::GetNextPacket ( void   )  [inline]

Definition at line 153 of file aggreg.h.

00154     {
00155         Trace trc = NextPacket;
00156         if( SRC.GetHead() )
00157         {
00158             Elapsed       = NextPacket.ByteStamp;
00159                 //ev<<"Elapsed de GetNextPacket: "<<Elapsed<<endl;
00160             TotalBytes   += NextPacket.PacketSize;
00161                 //ev<<"TotalBytes: "<<TotalBytes<<endl;
00162             TotalPackets++;
00163                 //ev<<"TotalPackets: "<<TotalPackets<<endl; // TOTAL DE PAQUETES QUE GENERA LA FUENTE
00164 
00165             Source* pSrc = (Source*)SRC.RemoveHead(); /* Extract packet from the first source */
00166             pSrc->ExtractPacket();                    /* receive new packet */
00167             InsertInOrder( pSrc );                    /* place the source in the linked list */
00168         }
00169         return trc;
00170     }

int32s Generator::GetPackets ( void   )  [inline]

Definition at line 104 of file aggreg.h.

00104 { return TotalPackets; }

int32s Generator::GetSources ( void   )  [inline]

Definition at line 109 of file aggreg.h.

00109 { return SRC.GetCount(); }

bytestamp_t Generator::GetTime ( void   )  [inline]

Definition at line 106 of file aggreg.h.

00106 { return Elapsed;      }

Source* Generator::InsertInOrder ( Source pSrc  )  [inline, private]

Definition at line 41 of file aggreg.h.

00042     {
00043         bytestamp_t arrival = pSrc->GetArrival();
00044         //ev<<"arrival de InsertInOrder: "<<arrival<<endl;
00045         DLinkable*  pPrv    = NULL;
00046         DLinkable*  pNxt    = SRC.GetHead();
00047        
00048         for( ; pNxt && arrival > ((Source*)pNxt)->GetArrival(); pNxt = pNxt->GetNext())
00049             pPrv = pNxt;
00050 
00051         SRC.Insert( pPrv, pSrc, pNxt );                     /* insert new source   */
00052         NextPacket = ((Source*)SRC.GetHead())->GetTrace();  /* get the next packet */ 
00053         ByteStamp= NextPacket.Append( Elapsed + Preamble );            /* prevent overlap with previous packet */
00054         return pSrc;
00055     }

Trace Generator::PeekNextPacket ( void   )  [inline]

Definition at line 146 of file aggreg.h.

00146 { return NextPacket; }

Source* Generator::RemoveSource ( void   )  [inline]

Definition at line 124 of file aggreg.h.

00124 { return (Source*)SRC.RemoveHead(); }

void Generator::RemoveSource ( Source pSrc  )  [inline]

Definition at line 123 of file aggreg.h.

00123 { SRC.Remove(pSrc); }

void Generator::Reset ( void   )  [inline]

Definition at line 85 of file aggreg.h.

00086     {
00087         TotalBytes   = 0.0;
00088         Elapsed      = 0.0;
00089         TotalPackets = 0;
00090 
00091         DList lst = SRC;
00092         SRC.Clear();
00093 
00094         Source* ptr;
00095         while( ( ptr = (Source*)lst.RemoveHead() ) != NULL )
00096         {
00097             ptr->Reset();
00098             InsertInOrder( ptr );
00099         }
00100     }

void Generator::SetLoad ( DOUBLE  load  )  [inline]

Definition at line 131 of file aggreg.h.

00132     {
00133         if( SRC.GetCount() > 0 ) 
00134         {
00135             load /= SRC.GetCount();
00136             for( DLinkable* ptr = SRC.GetHead(); ptr; ptr = ptr->GetNext())
00137                 ((Source*)ptr)->SetLoad( load );
00138         }
00139     }


Member Data Documentation

Definition at line 33 of file aggreg.h.

Definition at line 31 of file aggreg.h.

Definition at line 28 of file aggreg.h.

Definition at line 60 of file aggreg.h.

DList Generator::SRC [private]

Definition at line 27 of file aggreg.h.

Definition at line 29 of file aggreg.h.

Definition at line 30 of file aggreg.h.


The documentation for this class was generated from the following file:

Generated on Thu Nov 28 14:47:23 2013 for red_wireless by  doxygen 1.5.7.1