Heart 1.3.842.34c2ab5
Heart is base back end library for your c++ Qt projects.
QH::AbstractNodeParser Class Reference

The AbstractNodeParser class is main parser of the abstract level of the hear lib. More...

#include <abstractnodeparser.h>

Inheritance diagram for QH::AbstractNodeParser:
Inheritance graph
Collaboration diagram for QH::AbstractNodeParser:
Collaboration graph

Signals

void sigPingReceived (const QSharedPointer< QH::PKG::Ping > &ping)
 sigPingReceived This method emited
 

Public Member Functions

 AbstractNodeParser (AbstractNode *parentNode)
 
 ~AbstractNodeParser () override
 
ParserResult parsePackage (const QSharedPointer< PKG::AbstractData > &pkg, const Header &pkgHeader, AbstractNodeInfo *sender) override
 parsePackage This is main method of all childs classes of an AbstractNode class. This method work on own thread. If you ovveride this method you need to create this than an example:
 
int version () const override
 version This method return version of parser object
 
QString parserId () const override
 parserId This is id of the parsers. All parser will be synced betwin nodes by ids.
 
- Public Member Functions inherited from QH::iParser
 iParser (AbstractNode *parentNode)
 
virtual ~iParser ()=default
 
template<class T >
void registerPackageType ()
 registerPackageType This method register package type T. This is need to prepare pacakge for parsing in the parsePackage method.
 
template<class PackageClass , class HandlerType , class HandlerMethod >
ParserResult commandHandler (HandlerType handlerObject, HandlerMethod method, const QSharedPointer< QH::PKG::AbstractData > &pkg, QH::AbstractNodeInfo *sender, const QH::Header &pkgHeader)
 commandHandler This method it is simple wrapper for the handle pacakges in the AbstractNode::parsePackage method. Exmaple of use :
 
const PacksMapregisteredTypes () const
 registeredTypes This method return list of registered command.
 
QSharedPointer< PKG::AbstractDatagenPackage (unsigned short cmd) const
 genPackage This is factory method that generate data pacakge objects by command. All object should be registered before using this method.
 
bool checkCommand (unsigned short cmd) const
 checkCommand This method check command are if registered type or not.
 
virtual void initSupportedCommands ()
 initSupportedCommands This method will be invoked before add a parser into parser's storage. Use this method to register your command for this parser object. By default, this method does nothing, You still can register your command in the class constructor. But if you use inheritance between your APIs versions to you must use this method, because your constructors both all your commands, this broken API selector of your node.
 
QString toString () const override
 
const PackagesVersionDatamultiVersionPackages () const
 multiVersionPackages return list of the supported multiversions packages.
 

Additional Inherited Members

- Static Public Member Functions inherited from QH::iParser
static QString pareseResultToString (const ParserResult &parseResult)
 pareseResultToString This method convert ParserResult value to string.
 
- Protected Member Functions inherited from QH::iParser
AbstractNodenode () const
 
virtual unsigned int sendData (const PKG::AbstractData *resp, const HostAddress &address, const Header *req=nullptr) const
 sendData This method send data object another to node
 
virtual unsigned int sendData (const PKG::AbstractData *resp, const AbstractNodeInfo *node, const Header *req=nullptr) const
 sendData This method send data object another to node
 

Detailed Description

The AbstractNodeParser class is main parser of the abstract level of the hear lib.

Definition at line 20 of file abstractnodeparser.h.

Constructor & Destructor Documentation

◆ AbstractNodeParser()

QH::AbstractNodeParser::AbstractNodeParser ( AbstractNode parentNode)

Definition at line 20 of file abstractnodeparser.cpp.

Here is the call graph for this function:

◆ ~AbstractNodeParser()

QH::AbstractNodeParser::~AbstractNodeParser ( )
override

Definition at line 28 of file abstractnodeparser.cpp.

Member Function Documentation

◆ parsePackage()

ParserResult QH::AbstractNodeParser::parsePackage ( const QSharedPointer< PKG::AbstractData > &  pkg,
const Header pkgHeader,
AbstractNodeInfo sender 
)
overridevirtual

parsePackage This is main method of all childs classes of an AbstractNode class. This method work on own thread. If you ovveride this method you need to create this than an example:

ParserResult DataBaseNode::parsePackage(PKG::AbstractData *pkg,
const Header& pkgHeader,
auto parentResult = AbstractNode::parsePackage(pkg, sender);
return parentResult;
}
// you can use parsing without the commandHandler method
if (MyCommand::command() == pkg->cmd()) {
...
}
...
}
// Or with the commandHandler method
auto result = commandHandler<MyPackage>(this, &MyClass::processMyPackage, pkg, sender, pkgHeader);
return result;
}
}
The AbstractNodeInfo class contains information about client or server connection and tcp socket of n...
The AbstractData class is provide base functions for transport data by network For create you own pac...
void registerPackageType()
registerPackageType This method register package type T. This is need to prepare pacakge for parsing ...
Definition iparser.h:62
ParserResult
The ParserResult enum. Error - parser detect a errorob package. NotProcessed - the parser does not kn...
Definition iparser.h:35
@ NotProcessed
the parser does not know what to do with the package or has not finished processing it.
@ Error
parser detect a errorob package.
@ Processed
the parser finished processing correctly.
The Header struct 32 bytes.
Definition header.h:19
Parameters
pkgThis is package with incomming data.
senderThis is sender this pacakge.
pkgHeaderThis is header of the incoming packet is used to create a response.
Returns
item of ParserResult. For more information see The ParserResult enum.
See also
AbstractNode::commandHandler
AbstractNode::sendData
AbstractNode::badRequest

Implements QH::iParser.

Definition at line 31 of file abstractnodeparser.cpp.

Here is the call graph for this function:

◆ parserId()

QString QH::AbstractNodeParser::parserId ( ) const
overridevirtual

parserId This is id of the parsers. All parser will be synced betwin nodes by ids.

Returns
parser id.

Implements QH::iParser.

Definition at line 83 of file abstractnodeparser.cpp.

◆ sigPingReceived

void QH::AbstractNodeParser::sigPingReceived ( const QSharedPointer< QH::PKG::Ping > &  ping)
signal

sigPingReceived This method emited

Parameters
pingthis is received ping object.
Here is the caller graph for this function:

◆ version()

int QH::AbstractNodeParser::version ( ) const
overridevirtual

version This method return version of parser object

Returns
version of parsed object.

Implements QH::iParser.

Definition at line 79 of file abstractnodeparser.cpp.


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