Heart
1.4.984.b4712811
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-2027 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 <QCryptographicHash>
12
#include <qaglobalutils.h>
13
14
namespace
QH
{
15
namespace
PKG
{
16
17
AbstractData::AbstractData
() {
18
}
19
20
bool
AbstractData::toPackage
(
Package
&package,
21
const
DistVersion
& ,
22
unsigned
int
triggerHash)
const
{
23
24
if
(!
isValid
()) {
25
return
false
;
26
}
27
28
package.
data
=
toBytes
();
29
package.
hdr
.
command
=
cmd
();
30
package.
hdr
.
triggerHash
= triggerHash;
31
package.
hdr
.
size
= package.
data
.size();
32
33
package.
hdr
.
hash
= package.
calcHash
();
34
35
36
return
package.
isValid
();
37
}
38
39
bool
AbstractData::isValid
()
const
{
40
return
true
;
41
}
42
43
QString
AbstractData::toString
()
const
{
44
return
QString(
"Type: %0 \n"
45
"Command: %1 \n"
).
46
arg(
cmdString
()).
47
arg(
cmd
());
48
}
49
50
void
AbstractData::fromPackage
(
const
Package
&pkg) {
51
fromBytes
(pkg.
data
);
52
}
53
54
AbstractData::~AbstractData
() {
55
56
}
57
58
59
60
}
61
}
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:54
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:20
QH::PKG::AbstractData::isValid
bool isValid() const override
isValid This method check current object to valid.
Definition
abstractdata.cpp:39
QH::PKG::AbstractData::toString
QString toString() const override
toString - Return a string implementation for this object.
Definition
abstractdata.cpp:43
QH::PKG::AbstractData::fromPackage
void fromPackage(const Package &pkg)
fromPackage - This method initialize the current object from a package class object.
Definition
abstractdata.cpp:50
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:17
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 package.
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:39
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 namespace - 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