Heart 1.3.842.34c2ab5
Heart is base back end library for your c++ Qt projects.
abstractdata.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2018-2024 QuasarApp.
3 * Distributed under the GPLv3 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#ifndef ABSTRACTDATA_H
9#define ABSTRACTDATA_H
10#include "distversion.h"
11#include "humanreadableobject.h"
12#include "package.h"
13#include <QSharedPointer>
14#include <streambase.h>
15#include <crc/crchash.h>
16
20#define PROTOCKOL_VERSION_COMMAND 0xFFFF
21
25#define PROTOCKOL_VERSION_RECEIVED_COMMAND PROTOCKOL_VERSION_COMMAND - 1
26
34#define QH_PACKAGE(S) \
35 public: \
36 static unsigned short command(){\
37 QByteArray ba = QString(S).toLocal8Bit();\
38 return qa_common::hash16(ba.data(), ba.size());\
39 } \
40 static QString commandText(){return S;} \
41 unsigned short cmd() const override {return command();} \
42\
43 QString cmdString() const override {return S;} \
44 private:
45
46namespace QH {
47namespace PKG {
48
82class HEARTSHARED_EXPORT AbstractData : public StreamBase, public QuasarAppUtils::iHRO
83{
84public:
85
86 ~AbstractData() override;
87
94 virtual unsigned short cmd() const = 0;
95
102 virtual QString cmdString() const = 0;
103
112 virtual bool toPackage(Package &package, const DistVersion &reqVersion, unsigned int triggerHash = 0) const;
113
118 virtual bool isValid() const;
119
124 QString toString() const override;
125
131 template<class C, class... Args>
132 C* create(Args&&... args) const {
133 C* object = new C(std::forward<Args>(args)...);
134 return object;
135 }
136
141 void fromPakcage(const Package& pkg);
142
149 static unsigned int command(){return 0;};
150
155 static QString commandText(){return "NULL";};
156
157protected:
161 explicit AbstractData();
162
163};
164
165
166}
167}
168
169#endif // ABSTRACTDATA_H
The DistVersion class This is information of supported versions of the destinations api.
Definition distversion.h:21
The AbstractData class is provide base functions for transport data by network For create you own pac...
C * create(Args &&... args) const
create - This is factory method for create a new object.
static unsigned int command()
command This static method that return glaball code of this object.
static QString commandText()
commandText This method return text of package command
virtual QString cmdString() const =0
cmdString - This is command string of this object, (for generate cmd use macross QH_PACKAGE)
virtual unsigned short cmd() const =0
cmd - This is command of this object, (for generate cmd use macross QH_PACKAGE)
The Package struct. This is base structure for transporting data by network between QH nodes....
Definition package.h:23
The StreamBase class add support streaming data for all children classes. For correctly working all s...
Definition streambase.h:28
#define HEARTSHARED_EXPORT
The QH namespace - QuasarApp Heart namespace. This namespace contains all classes of the Heart librar...
Definition heart.cpp:13