Heart 1.4.984.b4712811
Heart is base back end library for your c++ Qt projects.
Loading...
Searching...
No Matches
QH::APIVersionParser Class Reference

The APIVersionParser class This is main parser for the main command. This parsers work only with the APIVersion package;. 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 children classes of an AbstractNode class. This method work on own thread. If you override 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::AbstractData > 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 method choose compatibly version.
QSharedPointer< iParser > getSelectedApiParser (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::iParser > selectParser (unsigned short cmd, AbstractNodeInfo *sender) const
 selectParser This method select parser by command and sender.
QSharedPointer< QH::iParser > selectParser (const QString &parserKey, unsigned short version) const
 selectParser This method select parser by command and sender.
QSharedPointer< QH::iParser > selectParser (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 supported 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 package 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 packages in the AbstractNode::parsePackage method. Example of use :
const PacksMap & registeredTypes () const
 registeredTypes This method return list of registered command.
QSharedPointer< PKG::AbstractData > genPackage (unsigned short cmd) const
 genPackage This is factory method that generate data package 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 PackagesVersionData & multiVersionPackages () 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
AbstractNode * node () 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 for the main command. This parsers work only with the APIVersion package;.

Definition at line 26 of file apiversionparser.h.

Constructor & Destructor Documentation

◆ APIVersionParser()

QH::APIVersionParser::APIVersionParser ( AbstractNode * node)

Definition at line 20 of file apiversionparser.cpp.

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

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 158 of file apiversionparser.cpp.

◆ 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 destination node.
Returns
needed parser of the destination node.

Definition at line 113 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 253 of file apiversionparser.cpp.

◆ 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 263 of file apiversionparser.cpp.

◆ parsePackage()

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

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

ParserResult DataBaseNode::parsePackage(PKG::AbstractData *pkg,
const Header& pkgHeader,
const AbstractNodeInfo* sender) {
auto parentResult = AbstractNode::parsePackage(pkg, sender);
if (parentResult != ParserResult::NotProcessed) {
return parentResult;
}
// you can use parsing without the commandHandler method
if (MyCommand::command() == pkg->cmd()) {
BaseId requesterId = getSender(sender, &obj);
...
if (FailCondition) {
}
...
}
// 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...
virtual unsigned short cmd() const =0
cmd - This is command of this object, (for generate cmd use macross QH_PACKAGE)
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 packages in the AbstractNode::parsePac...
Definition iparser.h:167
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.
Definition iparser.h:39
@ Error
parser detect a errorob package.
Definition iparser.h:37
@ Processed
the parser finished processing correctly.
Definition iparser.h:41
The Header struct 32 bytes.
Definition header.h:19
Parameters
pkgThis is package with incoming data.
senderThis is sender this package.
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 24 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 63 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 190 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 method choose compatibly version.

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

Definition at line 81 of file apiversionparser.cpp.

Here is the call 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 204 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 217 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 destination node version.
Returns
hash map of needed parsers of the destination node.

Definition at line 174 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 194 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 supported api.

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

Definition at line 272 of file apiversionparser.cpp.

Here is the call 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 call graph for this function:
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 67 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 59 of file apiversionparser.cpp.

Here is the caller graph for this function:

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