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

The APIVersionParser class This is main parser forthe main command. This parsers work only with the APIVersion packge;. More...

#include <apiversionparser.h>

Inheritance diagram for QH::APIVersionParser:
Inheritance graph
Collaboration diagram for QH::APIVersionParser:
Collaboration graph

Signals

void sigNoLongerSupport (const QString &ApiKey, unsigned short version)
 sigNoLongerSupport This signal will be emit when node receive incomplite versions.
 

Public Member Functions

 APIVersionParser (AbstractNode *node)
 
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.
 
QString toString () const override
 toString This method show all supported commands and them names.
 
QSharedPointer< PKG::AbstractDatasearchPackage (unsigned short cmd, AbstractNodeInfo *sender) const
 searchPackage This method search package recursive in all registered pararsers. Searching will be in compatibility versions. Before search methd choose compatibly verson.
 
QSharedPointer< iParsergetSelectedApiParser (const QString &apiKey, QH::AbstractNodeInfo *node) const
 getSelectedApiParser This method return apiParser for selected node
 
const QSharedPointer< QH::iParser > & addApiParser (const QSharedPointer< QH::iParser > &parserObject)
 addApiParser This method add new Api parser for this node.
 
QHash< QString, QSharedPointer< QH::iParser > > selectParser (const VersionData &distVersion) const
 selectParser This method select api parser betwin nodes.
 
unsigned int parsersTypedCount () const
 parsersTypedCount This method return count of the parsers types.
 
QSharedPointer< QH::iParserselectParser (unsigned short cmd, AbstractNodeInfo *sender) const
 selectParser This method select parser by command and sender.
 
QSharedPointer< QH::iParserselectParser (const QString &parserKey, unsigned short version) const
 selectParser This method select parser by command and sender.
 
QSharedPointer< QH::iParserselectParser (const QString &parserKey, AbstractNodeInfo *sender) const
 selectParser This method select parser by command and sender.
 
unsigned short maximumApiVersion (const QString &apiKey) const
 maximumApiVersion This method return maximum supported api version of this node.
 
unsigned short minimumApiVersion (const QString &apiKey) const
 minimumApiVersion This method return minimum supported api version of this node.
 
bool sendSupportedAPI (AbstractNodeInfo *dist) const
 sendSupportedAPI This method sents all ainformation about suppported api.
 
unsigned short selectPackageVersion (const VersionData &local, const VersionData &dist)
 
- 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 APIVersionParser class This is main parser forthe main command. This parsers work only with the APIVersion packge;.

Definition at line 25 of file apiversionparser.h.

Constructor & Destructor Documentation

◆ APIVersionParser()

QH::APIVersionParser::APIVersionParser ( AbstractNode node)

Definition at line 22 of file apiversionparser.cpp.

Member Function Documentation

◆ addApiParser()

const QSharedPointer< QH::iParser > & QH::APIVersionParser::addApiParser ( const QSharedPointer< QH::iParser > &  parserObject)

addApiParser This method add new Api parser for this node.

Parameters
parserObjectThis is bew api parser.
Returns
added parser.

Definition at line 162 of file apiversionparser.cpp.

Here is the call graph for this function:

◆ getSelectedApiParser()

QSharedPointer< iParser > QH::APIVersionParser::getSelectedApiParser ( const QString apiKey,
QH::AbstractNodeInfo node 
) const

getSelectedApiParser This method return apiParser for selected node

Parameters
apiKeyThis is key of needed api.
nodeThis is distanation node.
Returns
needed parser of the distanation node.

Definition at line 117 of file apiversionparser.cpp.

Here is the call graph for this function:

◆ maximumApiVersion()

unsigned short QH::APIVersionParser::maximumApiVersion ( const QString apiKey) const

maximumApiVersion This method return maximum supported api version of this node.

Parameters
apiKeyThis is api key.
Returns
maximum supported api version of this node.

Definition at line 257 of file apiversionparser.cpp.

Here is the call graph for this function:

◆ minimumApiVersion()

unsigned short QH::APIVersionParser::minimumApiVersion ( const QString apiKey) const

minimumApiVersion This method return minimum supported api version of this node.

Parameters
apiKeyThis is api key.
Returns
minimum supported api version of this node.

Definition at line 267 of file apiversionparser.cpp.

Here is the call graph for this function:

◆ parsePackage()

ParserResult QH::APIVersionParser::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 26 of file apiversionparser.cpp.

Here is the call graph for this function:

◆ parserId()

QString QH::APIVersionParser::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 66 of file apiversionparser.cpp.

◆ parsersTypedCount()

unsigned int QH::APIVersionParser::parsersTypedCount ( ) const

parsersTypedCount This method return count of the parsers types.

Returns
count of the parsers types.

Definition at line 194 of file apiversionparser.cpp.

◆ searchPackage()

QSharedPointer< PKG::AbstractData > QH::APIVersionParser::searchPackage ( unsigned short  cmd,
AbstractNodeInfo sender 
) const

searchPackage This method search package recursive in all registered pararsers. Searching will be in compatibility versions. Before search methd choose compatibly verson.

Parameters
cmdThis is command for that shold be create pacakge object.
verThis is version for that shold be create pacakge object.
senderThis is node that sent the cmd.
Returns
Package generated from cmd.

Definition at line 84 of file apiversionparser.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ selectPackageVersion()

unsigned short QH::APIVersionParser::selectPackageVersion ( const VersionData local,
const VersionData dist 
)

◆ selectParser() [1/4]

QSharedPointer< iParser > QH::APIVersionParser::selectParser ( const QString parserKey,
AbstractNodeInfo sender 
) const

selectParser This method select parser by command and sender.

Parameters
parserKeythis is key of the parser type..
senderthis is node that sent this command.
Returns
parser for the cmd command

Definition at line 208 of file apiversionparser.cpp.

Here is the call graph for this function:

◆ selectParser() [2/4]

QSharedPointer< iParser > QH::APIVersionParser::selectParser ( const QString parserKey,
unsigned short  version 
) const

selectParser This method select parser by command and sender.

Parameters
parserKeythis is key of the parser type..
versionthis is needed version.
Returns
parser for the cmd command

Definition at line 221 of file apiversionparser.cpp.

Here is the call graph for this function:

◆ selectParser() [3/4]

QHash< QString, QSharedPointer< iParser > > QH::APIVersionParser::selectParser ( const VersionData distVersion) const

selectParser This method select api parser betwin nodes.

Parameters
distVersionThis is information about distanation node version.
Returns
hash map of needed parsers of the distanation node.

Definition at line 178 of file apiversionparser.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ selectParser() [4/4]

QSharedPointer< iParser > QH::APIVersionParser::selectParser ( unsigned short  cmd,
AbstractNodeInfo sender 
) const

selectParser This method select parser by command and sender.

Parameters
cmdthis is command that need to parse.
senderthis is node that sent this command.
Returns
parser for the cmd command

Definition at line 198 of file apiversionparser.cpp.

Here is the call graph for this function:

◆ sendSupportedAPI()

bool QH::APIVersionParser::sendSupportedAPI ( AbstractNodeInfo dist) const

sendSupportedAPI This method sents all ainformation about suppported api.

Parameters
distThis is distanation node.
Returns
true if the information sent successful else false.

Definition at line 276 of file apiversionparser.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sigNoLongerSupport

void QH::APIVersionParser::sigNoLongerSupport ( const QString ApiKey,
unsigned short  version 
)
signal

sigNoLongerSupport This signal will be emit when node receive incomplite versions.

Parameters
ApiKeyThis is key of not supported version.
versionThis is version
Here is the caller graph for this function:

◆ toString()

QString QH::APIVersionParser::toString ( ) const
override

toString This method show all supported commands and them names.

Returns
list of the supported commands as a message

Definition at line 70 of file apiversionparser.cpp.

Here is the call graph for this function:

◆ version()

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

version This method return version of parser object

Returns
version of parsed object.

Implements QH::iParser.

Definition at line 62 of file apiversionparser.cpp.

Here is the caller graph for this function:

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