Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
PdmlProtocol Class Reference

PdmlProtocol is the base class which provides the interface for all PDML decode helper protocols. More...

List of all members.

Public Member Functions

virtual ~PdmlProtocol ()
 Destroys the PdmlProtocol.
int ostProtoId () const
 Returns the protocol's field number as defined in message 'Protocol', enum 'k' (file: protocol.proto)
bool hasField (QString name) const
 Returns true if name is a 'known' field that can be directly mapped to the protobuf field.
int fieldId (QString name) const
 Returns the protocol's protobuf field number corresponding to name.
virtual void preProtocolHandler (QString name, const QXmlStreamAttributes &attributes, int expectedPos, OstProto::Protocol *pbProto, OstProto::Stream *stream)
 This method is called by PdmlReader before any fields within the protocol are processed.
virtual void prematureEndHandler (int pos, OstProto::Protocol *pbProto, OstProto::Stream *stream)
 This method is called by PdmlReader when it encounters a nested protocol in the PDML i.e.
virtual void postProtocolHandler (OstProto::Protocol *pbProto, OstProto::Stream *stream)
 This method is called by PdmlReader after all fields within the protocol are processed.
void fieldHandler (QString name, const QXmlStreamAttributes &attributes, OstProto::Protocol *pbProto, OstProto::Stream *stream)
 This method is called by PdmlReader for each field in the protocol.
void knownFieldHandler (QString name, QString valueHexStr, OstProto::Protocol *pbProto)
 Handles a 'known' field.
virtual void unknownFieldHandler (QString name, int pos, int size, const QXmlStreamAttributes &attributes, OstProto::Protocol *pbProto, OstProto::Stream *stream)
 Handles a 'unknown' field.

Static Public Member Functions

static PdmlProtocolcreateInstance ()
 Allocates and returns a new instance of the class.

Protected Member Functions

 PdmlProtocol ()
 Protocol's field number as defined in message 'Protocol', enum 'k'.

Protected Attributes

int ostProtoId_
 Map of PDML field names to protobuf field numbers for 'known' fields.
QMap< QString, int > fieldMap_

Detailed Description

PdmlProtocol is the base class which provides the interface for all PDML decode helper protocols.

All Pdml helper classes derived from PdmlProtocol MUST register themselves with PdmlReader. When PdmlReader encounters a 'proto' tag in the PDML during parsing, it instantiates the corresponding helper PdmlProtocol class and calls its methods to decode the protocol.

A subclass MUST initialize the following inherited protected variables in its constructor -

A subclass typically needs to reimplement the following methods -

Depending on certain conditions, subclasses may need to reimplement the following additional methods -

See the description of the methods for more information.

Use the SamplePdmlProtocol implementation as boilerplate code and for guidelines and tips


Constructor & Destructor Documentation

PdmlProtocol::~PdmlProtocol ( ) [virtual]

Destroys the PdmlProtocol.

PdmlProtocol::PdmlProtocol ( ) [protected]

Protocol's field number as defined in message 'Protocol', enum 'k'.

Constructs the PdmlProtocol.


Member Function Documentation

PdmlProtocol * PdmlProtocol::createInstance ( ) [static]

Allocates and returns a new instance of the class.

Caller is responsible for freeing up after use. Subclasses MUST implement this function and register it with PdmlReader

void PdmlProtocol::fieldHandler ( QString  name,
const QXmlStreamAttributes &  attributes,
OstProto::Protocol *  pbProto,
OstProto::Stream *  stream 
)

This method is called by PdmlReader for each field in the protocol.

Depending on whether it is a known or unknown field, the virtual methods knownFieldHandler() and unknownFieldHandler() are invoked

int PdmlProtocol::fieldId ( QString  name) const

Returns the protocol's protobuf field number corresponding to name.

bool PdmlProtocol::hasField ( QString  name) const

Returns true if name is a 'known' field that can be directly mapped to the protobuf field.

void PdmlProtocol::knownFieldHandler ( QString  name,
QString  valueHexStr,
OstProto::Protocol *  pbProto 
)

Handles a 'known' field.

Uses protobuf reflection interface to set the protobuf field name to valueHexStr as per the field's datatype

int PdmlProtocol::ostProtoId ( ) const

Returns the protocol's field number as defined in message 'Protocol', enum 'k' (file: protocol.proto)

void PdmlProtocol::postProtocolHandler ( OstProto::Protocol *  pbProto,
OstProto::Stream *  stream 
) [virtual]

This method is called by PdmlReader after all fields within the protocol are processed.

Use this method to do any special handling that may be required for postprocessing

void PdmlProtocol::prematureEndHandler ( int  pos,
OstProto::Protocol *  pbProto,
OstProto::Stream *  stream 
) [virtual]

This method is called by PdmlReader when it encounters a nested protocol in the PDML i.e.

a protocol within a protocol or a protocol within a field

This is a notification to the protocol that protocol processing will be ending prematurely. postProtocolHandler() will still be called in such cases.

void PdmlProtocol::preProtocolHandler ( QString  name,
const QXmlStreamAttributes &  attributes,
int  expectedPos,
OstProto::Protocol *  pbProto,
OstProto::Stream *  stream 
) [virtual]

This method is called by PdmlReader before any fields within the protocol are processed.

All attributes associated with the 'proto' tag in the PDML are passed to this method

Use this method to do any special handling that may be required for preprocessing

void PdmlProtocol::unknownFieldHandler ( QString  name,
int  pos,
int  size,
const QXmlStreamAttributes &  attributes,
OstProto::Protocol *  pbProto,
OstProto::Stream *  stream 
) [virtual]

Handles a 'unknown' field.

The default implementation does nothing. Subclasses may need to implement this if the protocol contains 'unknown' fields.


Member Data Documentation

int PdmlProtocol::ostProtoId_ [protected]

Map of PDML field names to protobuf field numbers for 'known' fields.


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