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

The BigDataParser class is main manager for control big data packages. More...

#include <bigdataparser.h>

Inheritance diagram for QH::BigDataParser:
Inheritance graph
Collaboration diagram for QH::BigDataParser:
Collaboration graph

Public Member Functions

 BigDataParser (AbstractNode *parentNode)
 
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.
 

Protected Member Functions

bool newPackage (const QSharedPointer< PKG::BigDataHeader > &header, AbstractNodeInfo *sender, const Header &pkgHeader)
 newPackage This method process first header packge of the big data.
 
bool processPart (const QSharedPointer< PKG::BigDataPart > &part, AbstractNodeInfo *sender, const QH::Header &pkgHeader)
 processPart This method process part of package
 
bool processRequest (const QSharedPointer< PKG::BigDataRequest > &request, QH::AbstractNodeInfo *sender, const QH::Header &pkgHeader)
 finishPart This metho process last package of big data transaction.
 
bool processBigDataWraper (const QSharedPointer< PKG::BigDataWraper > &request, AbstractNodeInfo *sender, const Header &pkgHeader)
 sendBigDataPackage This method separate big pacakge and sent only heder ot serve.
 
- 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
 

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.
 

Detailed Description

The BigDataParser class is main manager for control big data packages.

Definition at line 36 of file bigdataparser.h.

Constructor & Destructor Documentation

◆ BigDataParser()

QH::BigDataParser::BigDataParser ( AbstractNode parentNode)

Definition at line 22 of file bigdataparser.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ newPackage()

bool QH::BigDataParser::newPackage ( const QSharedPointer< PKG::BigDataHeader > &  header,
AbstractNodeInfo sender,
const Header pkgHeader 
)
protected

newPackage This method process first header packge of the big data.

Parameters
headerThis is header package.
pkgHeaderThis is header of an incomming package.
senderThis is socket object of a sender that send this package.
Returns
true if packge processed successful else false

Definition at line 85 of file bigdataparser.cpp.

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

◆ parsePackage()

ParserResult QH::BigDataParser::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 bigdataparser.cpp.

Here is the call graph for this function:

◆ parserId()

QString QH::BigDataParser::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 71 of file bigdataparser.cpp.

◆ processBigDataWraper()

bool QH::BigDataParser::processBigDataWraper ( const QSharedPointer< PKG::BigDataWraper > &  request,
AbstractNodeInfo sender,
const Header pkgHeader 
)
protected

sendBigDataPackage This method separate big pacakge and sent only heder ot serve.

Parameters
dataThis is package that will be sent to remote node.
senderThis is request object.
pkgHeaderrequested header.
Returns
true if package sent successful

Definition at line 195 of file bigdataparser.cpp.

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

◆ processPart()

bool QH::BigDataParser::processPart ( const QSharedPointer< PKG::BigDataPart > &  part,
AbstractNodeInfo sender,
const QH::Header pkgHeader 
)
protected

processPart This method process part of package

Parameters
partThis is pacakge part.
pkgHeaderThis is header of an incomming package.
senderThis is socket object of a sender that send this package.
Returns
true if packge processed successful else false

Definition at line 103 of file bigdataparser.cpp.

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

◆ processRequest()

bool QH::BigDataParser::processRequest ( const QSharedPointer< PKG::BigDataRequest > &  request,
QH::AbstractNodeInfo sender,
const QH::Header pkgHeader 
)
protected

finishPart This metho process last package of big data transaction.

Parameters
requestthis is shared pointer to last part of big data transaction.
pkgHeaderThis is header of an incomming package.
senderThis is socket object of a sender that send this package.
Returns
true if pacakge parsed successful else false.

Definition at line 162 of file bigdataparser.cpp.

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

◆ version()

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

version This method return version of parser object

Returns
version of parsed object.

Implements QH::iParser.

Definition at line 67 of file bigdataparser.cpp.


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