Heart 1.4.984.b4712811
Heart is base back end library for your c++ Qt projects.
Loading...
Searching...
No Matches
abstractdata.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2018-2027 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 "package.h"
12#include <QSharedPointer>
13#include <streambase.h>
14#include <crc/crchash.h>
15
19#define PROTOCKOL_VERSION_COMMAND 0xFFFF
20
24#define PROTOCKOL_VERSION_RECEIVED_COMMAND PROTOCKOL_VERSION_COMMAND - 1
25
33#define QH_PACKAGE(S) \
34 public: \
35 static unsigned short command(){\
36 QByteArray ba = QString(S).toLocal8Bit();\
37 return qa_common::hash16(ba.data(), ba.size());\
38 } \
39 static QString commandText(){return S;} \
40 unsigned short cmd() const override {return command();} \
41\
42 QString cmdString() const override {return S;} \
43 private:
44
45namespace QH {
46namespace PKG {
47
81class HEARTSHARED_EXPORT AbstractData : public StreamBase, public QuasarAppUtils::iHRO
82{
83public:
84
85 ~AbstractData() override;
86
93 virtual unsigned short cmd() const = 0;
94
101 virtual QString cmdString() const = 0;
102
111 virtual bool toPackage(Package &package, const DistVersion &reqVersion, unsigned int triggerHash = 0) const;
112
117 bool isValid() const override;
118
123 QString toString() const override;
124
130 template<class C, class... Args>
131 C* create(Args&&... args) const {
132 C* object = new C(std::forward<Args>(args)...);
133 return object;
134 }
135
140 void fromPackage(const Package& pkg);
141
148 static unsigned int command(){return 0;};
149
154 static QString commandText(){return "NULL";};
155
156protected:
160 explicit AbstractData();
161
162};
163
164
165}
166}
167
168#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...
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.
bool isValid() const override
isValid This method check current object to valid.
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
QString toString() const override
toString - Return a string implementation for this object.
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)
AbstractData()
AbstractData - Base constructor of this object.
The Package struct. This is base structure for transporting data by network between QH nodes....
Definition package.h:23
The QH namespace - QuasarApp Heart namespace. This namespace contains all classes of the Heart librar...
Definition heart.cpp:13