#include <PacketFactory.h> [code]
Inherited by Protocols::Generics::Testing::PacketFactoryStub.
Inheritance diagram for Protocols::Generics::PacketFactory:

This is an abstract base class for Packet helper classes, which would provide functions for extracting packets from a raw bytes buffer or for creating objects of Packet derived classes from the extracted raw data.
According to the design of PacketFactory, extractPacket() looks into the raw bytes, which are probably read from a Connection, and tries to figure out the header/payload/trailer lengths of the first packet available in the raw buffer. After the packet is extracted, createPacket() can be called with the corresponding data. If it is possible to identify the type of the packet from the raw data, then a default-constructed Packet object of the correct dynamic type is created. After that PacketFactory tries to Packet::parse() the packet and if that fails a packet of type BadPacket is created and returned. A BadPacket object contains just the bad raw bytes, which could be dumped for debugging or diagnostic purposes.
Definition at line 51 of file PacketFactory.h.
Public Member Functions | |
| PacketFactory () | |
| Default constructor. | |
| virtual | ~PacketFactory () |
| Destructor. | |
| bool | extractPacket (const QByteArray &rawBytes, int &headerLength, int &payloadLength, int &trailerLength) |
| Tells whether a packet can be extracted from rawBytes. | |
| Packet | createPacket (const QByteArray &rawHeader, const QByteArray &rawPayload, const QByteArray &rawTrailer) |
| Creates an object of a Packet derive class after parsing the raw data bytes. | |
Protected Member Functions | |
| virtual bool | doExtractPacket (const QByteArray &rawBytes, int &headerLength, int &payloadLength, int &trailerLength)=0 |
| virtual Packet | doCreatePacket (const QByteArray &rawHeader, const QByteArray &rawPayload, const QByteArray &rawTrailer)=0 |
|
|
Default constructor.
Definition at line 30 of file PacketFactory.cpp. |
|
|
Destructor.
Definition at line 35 of file PacketFactory.cpp. |
|
||||||||||||||||
|
Creates an object of a Packet derive class after parsing the raw data bytes. The function tries to parse rawHeader, rawPayload and rawTrailer. If parsing them succeeds, an object of the corresponding dynamic type will be created and returned from the function. The caller owns the new object. If parsing fails, then an object of dynamic type BadPacket is created. It contains the raw bytes, which the caller may decide to dump, for example. Definition at line 64 of file PacketFactory.cpp. |
|
||||||||||||||||
|
Implemented in Protocols::Generics::Testing::PacketFactoryStub. |
|
||||||||||||||||||||
|
Implemented in Protocols::Generics::Testing::PacketFactoryStub. |
|
||||||||||||||||||||
|
Tells whether a packet can be extracted from rawBytes.
Definition at line 46 of file PacketFactory.cpp. |