Heart
1.4.918.d927d9c
Heart is base back end library for your c++ Qt projects.
Toggle main menu visibility
Loading...
Searching...
No Matches
abstractdata.cpp
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2018-2025 QuasarApp.
3
* Distributed under the lgplv3 software license, see the accompanying
4
* Everyone is permitted to copy and distribute verbatim copies
5
* of this license document, but changing it is not allowed.
6
*/
7
8
#include "
abstractdata.h
"
9
#include <QDataStream>
10
#include <QMap>
11
#include <quasarapp.h>
12
#include <QCryptographicHash>
13
#include <qaglobalutils.h>
14
15
namespace
QH
{
16
namespace
PKG
{
17
18
AbstractData::AbstractData
() {
19
}
20
21
bool
AbstractData::toPackage
(
Package
&package,
22
const
DistVersion
& ,
23
unsigned
int
triggerHash)
const
{
24
25
if
(!
isValid
()) {
26
return
false
;
27
}
28
29
package.
data
=
toBytes
();
30
package.
hdr
.
command
=
cmd
();
31
package.
hdr
.
triggerHash
= triggerHash;
32
package.
hdr
.
size
= package.
data
.size();
33
34
package.
hdr
.
hash
= package.
calcHash
();
35
36
37
return
package.
isValid
();
38
}
39
40
bool
AbstractData::isValid
()
const
{
41
return
true
;
42
}
43
44
QString
AbstractData::toString
()
const
{
45
return
QString(
"Type: %0 \n"
46
"Command: %1 \n"
).
47
arg(
cmdString
()).
48
arg(
cmd
());
49
}
50
51
void
AbstractData::fromPakcage
(
const
Package
&pkg) {
52
fromBytes
(pkg.
data
);
53
}
54
55
AbstractData::~AbstractData
() {
56
57
}
58
59
60
61
}
62
}
abstractdata.h
QH::DistVersion
The DistVersion class This is information of supported versions of the destinations api.
Definition
distversion.h:21
QH::PKG::AbstractData::~AbstractData
~AbstractData() override
Definition
abstractdata.cpp:55
QH::PKG::AbstractData::toPackage
virtual bool toPackage(Package &package, const DistVersion &reqVersion, unsigned int triggerHash=0) const
toPackage This method convert this class object to the package. For more info see Package class.
Definition
abstractdata.cpp:21
QH::PKG::AbstractData::isValid
bool isValid() const override
isValid This method check current object to valid.
Definition
abstractdata.cpp:40
QH::PKG::AbstractData::fromPakcage
void fromPakcage(const Package &pkg)
fromPakcage - This method initialize the current object from a package class object.
Definition
abstractdata.cpp:51
QH::PKG::AbstractData::toString
QString toString() const override
toString - Return a string implementation for this object.
Definition
abstractdata.cpp:44
QH::PKG::AbstractData::cmdString
virtual QString cmdString() const =0
cmdString - This is command string of this object, (for generate cmd use macross QH_PACKAGE)
QH::PKG::AbstractData::cmd
virtual unsigned short cmd() const =0
cmd - This is command of this object, (for generate cmd use macross QH_PACKAGE)
QH::PKG::AbstractData::AbstractData
AbstractData()
AbstractData - Base constructor of this object.
Definition
abstractdata.cpp:18
QH::Package
The Package struct. This is base structure for transporting data by network between QH nodes....
Definition
package.h:23
QH::Package::calcHash
unsigned int calcHash() const
calcHash This method recalc hash sum for this pacakge.
Definition
package.cpp:44
QH::Package::data
QByteArray data
data This is source data of package.
Definition
package.h:33
QH::Package::hdr
Header hdr
hdr This is header of package. For more information see the Header struct.
Definition
package.h:29
QH::Package::isValid
bool isValid() const override
isValid This method validation a current package. Default implementation is checked a header and comp...
Definition
package.cpp:18
QH::StreamBase::toBytes
QByteArray toBytes() const
toBytes This method convert a current object to bytes array.
Definition
streambase.cpp:38
QH::StreamBase::fromBytes
bool fromBytes(const QByteArray &dataz)
fromBytes This method provide initialization of object from byte array.
Definition
streambase.cpp:21
QH::PKG
The PKG namesapce - this namespace contains all default packages of the Heart library....
Definition
heart.h:211
QH
The QH namespace - QuasarApp Heart namespace. This namespace contains all classes of the Heart librar...
Definition
heart.cpp:13
QH::Header::hash
unsigned int hash
hash This is unique id of a package. id calc with CRC32 function for Qt implementation.
Definition
header.h:38
QH::Header::triggerHash
unsigned int triggerHash
triggerHash This is hash of request package that package has been responded. The server should write ...
Definition
header.h:44
QH::Header::size
unsigned int size
size This is size of package data (exclude header size).
Definition
header.h:33
QH::Header::command
unsigned short command
command of package for more information see the AbstractData::toPackage method.
Definition
header.h:23
src
public
packages
abstractdata.cpp
Generated by
1.18.0