QuasarApp Heart - it is base backend for C++/Qt projects. This library support work with databases and work with lite network requests.
Futures
This library consists of two levels (AbstractNode level and DataBaseNode level).
- [X] Support ssl sockets
- [X] Support initialize database
- [X] Support work in database
Build and Include
For cmake projects
Usage
Create a own package class and override some basic methods.
{
public:
MyPackage();
};
std::string _data = "";
protected:
stream >> _data;
return stream;
}
QDataStream &
toStream(QDataStream &stream)
const {
stream << _data;
return stream;
}
};
The AbstractData class is provide base functions for transport data by network For create you own pac...
virtual bool isValid() const
isValid This method check current object to valid.
virtual QDataStream & fromStream(QDataStream &stream)=0
fromStream This method should be read all bytes from the stream object and full the current object.
virtual QDataStream & toStream(QDataStream &stream) const =0
fromStream This method should be write all members of the current object to the stream object.
Create your parser api class.
*
public:
}
public:
const AbstractNodeInfo *sender) {
auto parentResult = AbstractNode::parsePackage(pkg, sender);
if (parentResult != ParserResult::NotProcessed) {
}
}
}
BaseId requesterId =
getSender(sender, &cardrequest);
if (!cardrequest.isValid()) {
}
cardrequest._data = "responce for client "
}
int version()
const override {
return 0;};
QString
parserId()
const override {
return "MyParser";};
};
The AbstractNodeInfo class contains information about client or server connection and tcp socket of n...
HostAddress networkAddress() const
networkAddress This method return network address of current node or client.
The AbstractNode class - Abstract implementation of node. this implementation have a methods for send...
@ Server
This is node can works only as a public server.
The iParser class This class provide functions for parsing income packages. For yousing just override...
virtual QString parserId() const =0
parserId This is id of the parsers. All parser will be synced betwin nodes by ids.
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
void registerPackageType()
registerPackageType This method register package type T. This is need to prepare pacakge for parsing ...
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 ...
virtual int version() const =0
version This method return version of parser object
The QH namespace - QuasarApp Heart namespace. This namespace contains all classes of the Heart librar...
@ 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.
Create a server class and add supported parsers to work with packages.
Q_OBJECT
public:
TestingServer() {
addApiParser<MyParser>();
}
}
};
NodeType
The NodeType enum contains types of the node. By default node contains only 3 types.
virtual NodeType nodeType() const =0
nodeType This method should be return type of the serve.
Create a client class and add supported parsers to work with packages.
public:
TestingClient() {
addApiParser<MyParser>();
}
}
};
@ Client
Node with this type is general clints nodes.
For more information, see our QuasarApp Heart Code Documentation.