The iParser class This class provide functions for parsing income packages. For yousing just override the iParser::parsePackage method.
More...
#include <iparser.h>
|
| 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.
|
|
virtual ParserResult | parsePackage (const QSharedPointer< PKG::AbstractData > &pkg, const Header &pkgHeader, AbstractNodeInfo *sender)=0 |
| 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:
|
|
virtual int | version () const =0 |
| version This method return version of parser object
|
|
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 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 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 QString | parserId () const =0 |
| parserId This is id of the parsers. All parser will be synced betwin nodes by ids.
|
|
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.
|
|
The iParser class This class provide functions for parsing income packages. For yousing just override the iParser::parsePackage method.
- See also
- AbstractNode::parsePackage
-
AbstractNode
Definition at line 50 of file iparser.h.
◆ iParser()
◆ ~iParser()
◆ checkCommand()
checkCommand This method check command are if registered type or not.
cmd This is command of a verifiable package.
- Returns
- True if the package is registered in a node.
Definition at line 42 of file iparser.cpp.
◆ commandHandler()
commandHandler This method it is simple wrapper for the handle pacakges in the AbstractNode::parsePackage method. Exmaple of use :
}
...
void registerPackageType()
registerPackageType This method register package type T. This is need to prepare pacakge for parsing ...
@ NotProcessed
the parser does not know what to do with the package or has not finished processing it.
- Template Parameters
-
PackageClass | This is class name that you want handle. All classes mist be inhert of the QH::PKG::AbstractData class. |
HandlerType | This is type of the handler object that will invoke HandlerMethod method. |
HandlerMethod | This is name of the handler method. The handler method should be support next signature: bool Method(const QSharedPointer<QH::PKG::PackageClass> &, const QH::Header &pkgHeader, const QH::AbstractNodeInfo *sender). |
- Parameters
-
handlerObject | This is pointer to handler object. |
method | This is handler method. |
pkg | This is package data from the AbstractNode::parsePackage argumetns |
pkgHeader | This is header of an incomming package. |
sender | This is socket object of a sender that send this package. |
- Returns
- item of ParserResult. For more information see The ParserResult enum.
- See also
- iParser::parsePackage
-
ParserResult
Definition at line 167 of file iparser.h.
◆ genPackage()
genPackage This is factory method that generate data pacakge objects by command. All object should be registered before using this method.
- Parameters
-
- Returns
- shared pointer to new data object.
- See also
- AbstractNode::registerPackageType
-
Header::command
Definition at line 38 of file iparser.cpp.
◆ initSupportedCommands()
void QH::iParser::initSupportedCommands |
( |
| ) |
|
|
virtual |
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.
- See also
- registerPackageType
Definition at line 66 of file iparser.cpp.
◆ multiVersionPackages()
multiVersionPackages return list of the supported multiversions packages.
- Returns
- list of the supported multiversions packages.
Definition at line 62 of file iparser.cpp.
◆ node()
◆ pareseResultToString()
pareseResultToString This method convert ParserResult value to string.
- Returns
- The String value of pareseresult.
Definition at line 22 of file iparser.cpp.
◆ parsePackage()
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:
}
if (MyCommand::command() ==
pkg->cmd()) {
...
}
...
}
}
}
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...
ParserResult
The ParserResult enum. Error - parser detect a errorob package. NotProcessed - the parser does not kn...
@ Error
parser detect a errorob package.
@ Processed
the parser finished processing correctly.
- Parameters
-
pkg | This is package with incomming data. |
sender | This is sender this pacakge. |
pkgHeader | This 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
Implemented in QH::AbstractNodeParser, QH::BigDataParser, and QH::APIVersionParser.
◆ parserId()
◆ registeredTypes()
◆ registerPackageType()
template<class T >
void QH::iParser::registerPackageType |
( |
| ) |
|
|
inline |
registerPackageType This method register package type T. This is need to prepare pacakge for parsing in the parsePackage method.
- See also
- initSupportedCommands
Definition at line 62 of file iparser.h.
◆ sendData() [1/2]
sendData This method send data object another to node
- Parameters
-
resp | This is pointer to sendet object. |
address | This is target addres for sending. |
req | This is header of request. |
- Returns
- hash of the sendet package. If function is failed then return 0.
- Note
- This method is a just wraper of the AbstractNode::sendData method.
Definition at line 56 of file iparser.cpp.
◆ sendData() [2/2]
sendData This method send data object another to node
- Parameters
-
resp | This is pointer to sendet object. |
address | This is target addres for sending. |
req | This is header of request. |
- Returns
- hash of the sendet package. If function is failed then return 0.
- Note
- This method is a just wraper of the AbstractNode::sendData method.
Definition at line 50 of file iparser.cpp.
◆ toString()
QString QH::iParser::toString |
( |
| ) |
const |
|
override |
◆ version()
◆ AbstractNode
◆ AbstractNodeParserOld
◆ BigDataParserOld
The documentation for this class was generated from the following files: