CPN
Computational Process Networks
Public Member Functions | Private Attributes | List of all members
CPN::PacketDecoder Class Referenceabstract

#include <PacketDecoder.h>

+ Inheritance diagram for CPN::PacketDecoder:
+ Collaboration diagram for CPN::PacketDecoder:

Public Member Functions

 PacketDecoder ()
 
virtual ~PacketDecoder ()
 
void * GetDecoderBytes (unsigned &amount)
 
void ReleaseDecoderBytes (unsigned amount)
 
void Reset ()
 
unsigned NumBytes () const
 
void FirePacket (const Packet &packet)
 
virtual void EnqueuePacket (const Packet &packet)=0
 
virtual void DequeuePacket (const Packet &packet)=0
 
virtual void ReadBlockPacket (const Packet &packet)=0
 
virtual void WriteBlockPacket (const Packet &packet)=0
 
virtual void EndOfWritePacket (const Packet &packet)=0
 
virtual void EndOfReadPacket (const Packet &packet)=0
 
virtual void GrowPacket (const Packet &packet)=0
 
virtual void D4RTagPacket (const Packet &packet)=0
 
virtual void FlushPacket (const Packet &packet)=0
 
virtual void ResetPacket (const Packet &packet)=0
 
virtual void IDReaderPacket (const Packet &packet)=0
 
virtual void IDWriterPacket (const Packet &packet)=0
 

Private Attributes

Packet header
 
unsigned numbytes
 

Detailed Description

The packet decoder receives bytes through GetDecoderbytes and ReleaseDecoderBytes. When enough bytes have been recieved to call one of the Received event functions those events will be called and the internal state will remove the information. If the information is not delt with in the event function it will be lost. This class is ment to be enherited by some other class which implements the event functions.

Definition at line 40 of file PacketDecoder.h.

Constructor & Destructor Documentation

CPN::PacketDecoder::PacketDecoder ( )

Definition at line 30 of file PacketDecoder.cc.

31  : numbytes(0)
32  {
33  }
CPN::PacketDecoder::~PacketDecoder ( )
virtual

Definition at line 35 of file PacketDecoder.cc.

35 {}

Member Function Documentation

virtual void CPN::PacketHandler::D4RTagPacket ( const Packet packet)
pure virtualinherited

Implemented in CPN::RemoteQueue.

Referenced by CPN::PacketHandler::FirePacket().

+ Here is the caller graph for this function:

virtual void CPN::PacketHandler::DequeuePacket ( const Packet packet)
pure virtualinherited

Implemented in CPN::RemoteQueue.

Referenced by CPN::PacketHandler::FirePacket().

+ Here is the caller graph for this function:

virtual void CPN::PacketHandler::EndOfReadPacket ( const Packet packet)
pure virtualinherited

Implemented in CPN::RemoteQueue.

Referenced by CPN::PacketHandler::FirePacket().

+ Here is the caller graph for this function:

virtual void CPN::PacketHandler::EndOfWritePacket ( const Packet packet)
pure virtualinherited

Implemented in CPN::RemoteQueue.

Referenced by CPN::PacketHandler::FirePacket().

+ Here is the caller graph for this function:

virtual void CPN::PacketHandler::EnqueuePacket ( const Packet packet)
pure virtualinherited

Implemented in CPN::RemoteQueue.

Referenced by CPN::PacketHandler::FirePacket().

+ Here is the caller graph for this function:

void CPN::PacketHandler::FirePacket ( const Packet packet)
inherited

Definition at line 31 of file PacketHeader.cc.

References ASSERT, CPN::PacketHandler::D4RTagPacket(), CPN::PacketHandler::DequeuePacket(), CPN::PacketHandler::EndOfReadPacket(), CPN::PacketHandler::EndOfWritePacket(), CPN::PacketHandler::EnqueuePacket(), CPN::PacketHandler::FlushPacket(), CPN::PacketHandler::GrowPacket(), CPN::PacketHandler::IDReaderPacket(), CPN::PacketHandler::IDWriterPacket(), CPN::PACKET_D4RTAG, CPN::PACKET_DEQUEUE, CPN::PACKET_ENDOFREAD, CPN::PACKET_ENDOFWRITE, CPN::PACKET_ENQUEUE, CPN::PACKET_FLUSH, CPN::PACKET_GROW, CPN::PACKET_ID_READER, CPN::PACKET_ID_WRITER, CPN::PACKET_READBLOCK, CPN::PACKET_RESET, CPN::PACKET_WRITEBLOCK, CPN::PacketHandler::ReadBlockPacket(), CPN::PacketHandler::ResetPacket(), CPN::Packet::Type(), CPN::Packet::Valid(), and CPN::PacketHandler::WriteBlockPacket().

Referenced by ReleaseDecoderBytes().

31  {
32  ASSERT(packet.Valid(), "Invalid packet");
33  switch (packet.Type()) {
34  case PACKET_ENQUEUE:
35  EnqueuePacket(packet);
36  break;
37  case PACKET_DEQUEUE:
38  DequeuePacket(packet);
39  break;
40  case PACKET_READBLOCK:
41  ReadBlockPacket(packet);
42  break;
43  case PACKET_WRITEBLOCK:
44  WriteBlockPacket(packet);
45  break;
46  case PACKET_ENDOFWRITE:
47  EndOfWritePacket(packet);
48  break;
49  case PACKET_ENDOFREAD:
50  EndOfReadPacket(packet);
51  break;
52  case PACKET_GROW:
53  GrowPacket(packet);
54  break;
55  case PACKET_D4RTAG:
56  D4RTagPacket(packet);
57  break;
58  case PACKET_FLUSH:
59  FlushPacket(packet);
60  break;
61  case PACKET_RESET:
62  ResetPacket(packet);
63  break;
64  case PACKET_ID_READER:
65  IDReaderPacket(packet);
66  break;
67  case PACKET_ID_WRITER:
68  IDWriterPacket(packet);
69  break;
70  default:
71  ASSERT(false, "Invalid packet type.");
72  }
73  }
virtual void IDWriterPacket(const Packet &packet)=0
virtual void WriteBlockPacket(const Packet &packet)=0
virtual void D4RTagPacket(const Packet &packet)=0
virtual void FlushPacket(const Packet &packet)=0
virtual void EnqueuePacket(const Packet &packet)=0
virtual void IDReaderPacket(const Packet &packet)=0
virtual void ReadBlockPacket(const Packet &packet)=0
virtual void EndOfReadPacket(const Packet &packet)=0
virtual void GrowPacket(const Packet &packet)=0
virtual void ResetPacket(const Packet &packet)=0
virtual void EndOfWritePacket(const Packet &packet)=0
virtual void DequeuePacket(const Packet &packet)=0
#define ASSERT(exp,...)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

virtual void CPN::PacketHandler::FlushPacket ( const Packet packet)
pure virtualinherited

Implemented in CPN::RemoteQueue.

Referenced by CPN::PacketHandler::FirePacket().

+ Here is the caller graph for this function:

void * CPN::PacketDecoder::GetDecoderBytes ( unsigned &  amount)

Definition at line 37 of file PacketDecoder.cc.

References ASSERT, header, CPN::Packet::header, and numbytes.

Referenced by CPN::RemoteQueue::Read().

37  {
38  char *ptr = reinterpret_cast<char*>(&header.header);
39  amount = sizeof(header.header) - numbytes;
40  ASSERT(amount != 0, "Zero decoder bytes");
41  return ptr + numbytes;
42  }
PacketHeader header
Definition: PacketHeader.h:148
#define ASSERT(exp,...)

+ Here is the caller graph for this function:

virtual void CPN::PacketHandler::GrowPacket ( const Packet packet)
pure virtualinherited

Implemented in CPN::RemoteQueue.

Referenced by CPN::PacketHandler::FirePacket().

+ Here is the caller graph for this function:

virtual void CPN::PacketHandler::IDReaderPacket ( const Packet packet)
pure virtualinherited

Implemented in CPN::RemoteQueue.

Referenced by CPN::PacketHandler::FirePacket().

+ Here is the caller graph for this function:

virtual void CPN::PacketHandler::IDWriterPacket ( const Packet packet)
pure virtualinherited

Implemented in CPN::RemoteQueue.

Referenced by CPN::PacketHandler::FirePacket().

+ Here is the caller graph for this function:

unsigned CPN::PacketDecoder::NumBytes ( ) const
inline

Definition at line 48 of file PacketDecoder.h.

48 { return numbytes; }
virtual void CPN::PacketHandler::ReadBlockPacket ( const Packet packet)
pure virtualinherited

Implemented in CPN::RemoteQueue.

Referenced by CPN::PacketHandler::FirePacket().

+ Here is the caller graph for this function:

void CPN::PacketDecoder::ReleaseDecoderBytes ( unsigned  amount)

Definition at line 44 of file PacketDecoder.cc.

References ASSERT, CPN::PacketHandler::FirePacket(), header, CPN::Packet::header, numbytes, and CPN::Packet::Valid().

Referenced by CPN::RemoteQueue::Read().

44  {
45  ASSERT(numbytes + amount <= sizeof(header.header));
46  numbytes += amount;
47  if (numbytes == sizeof(header.header)) {
48  if (header.Valid()) {
50  numbytes = 0;
51  } else {
52  // If it is not valid, what do we do??
53  // Well, we can search for the header word
54  // wont always work...
55  char *ptr = reinterpret_cast<char*>(&header.header);
56  numbytes -= 1;
57  memmove(ptr, ptr + 1, numbytes);
58  }
59  }
60  }
PacketHeader header
Definition: PacketHeader.h:148
bool Valid() const
Definition: PacketHeader.h:134
void FirePacket(const Packet &packet)
Definition: PacketHeader.cc:31
#define ASSERT(exp,...)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CPN::PacketDecoder::Reset ( )

Definition at line 62 of file PacketDecoder.cc.

References numbytes.

62  {
63  numbytes = 0;
64  }
virtual void CPN::PacketHandler::ResetPacket ( const Packet packet)
pure virtualinherited

Implemented in CPN::RemoteQueue.

Referenced by CPN::PacketHandler::FirePacket().

+ Here is the caller graph for this function:

virtual void CPN::PacketHandler::WriteBlockPacket ( const Packet packet)
pure virtualinherited

Implemented in CPN::RemoteQueue.

Referenced by CPN::PacketHandler::FirePacket().

+ Here is the caller graph for this function:

Member Data Documentation

Packet CPN::PacketDecoder::header
private
unsigned CPN::PacketDecoder::numbytes
private

Definition at line 53 of file PacketDecoder.h.

Referenced by GetDecoderBytes(), ReleaseDecoderBytes(), and Reset().


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