CPN
Computational Process Networks
PacketHeader.cc
Go to the documentation of this file.
1 //=============================================================================
2 // Computational Process Networks class library
3 // Copyright (C) 1997-2006 Gregory E. Allen and The University of Texas
4 //
5 // This library is free software; you can redistribute it and/or modify it
6 // under the terms of the GNU Library General Public License as published
7 // by the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Library General Public License for more details.
14 //
15 // The GNU Public License is available in the file LICENSE, or you
16 // can write to the Free Software Foundation, Inc., 59 Temple Place -
17 // Suite 330, Boston, MA 02111-1307, USA, or you can find it on the
18 // World Wide Web at http://www.fsf.org.
19 //=============================================================================
23 #include "common_priv.h"
24 #include "PacketHeader.h"
26 
27 namespace CPN {
28 
30 
31  void PacketHandler::FirePacket(const Packet &packet) {
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  }
74 }
75 
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
PacketType_t Type() const
Definition: PacketHeader.h:125
virtual void EndOfReadPacket(const Packet &packet)=0
virtual ~PacketHandler()
Definition: PacketHeader.cc:29
virtual void GrowPacket(const Packet &packet)=0
Declarations of a generic binary packet format.
virtual void ResetPacket(const Packet &packet)=0
virtual void EndOfWritePacket(const Packet &packet)=0
bool Valid() const
Definition: PacketHeader.h:134
virtual void DequeuePacket(const Packet &packet)=0
void FirePacket(const Packet &packet)
Definition: PacketHeader.cc:31
#define ASSERT(exp,...)