Heart 1.4.984.b4712811
Heart is base back end library for your c++ Qt projects.
Loading...
Searching...
No Matches
multiversiondata.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2023-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#ifndef MULTIVERSIONDATA_H
9#define MULTIVERSIONDATA_H
10
11#include "heart_global.h"
12#include "abstractdata.h"
13
14
15namespace QH {
16namespace PKG {
17
18struct HEARTSHARED_EXPORT SerializationBox {
19 std::function<QDataStream& (QDataStream& stream)> from = nullptr;
20 std::function<QDataStream& (QDataStream& stream)> to = nullptr;
21};
22
68class HEARTSHARED_EXPORT MultiversionData: public AbstractData
69{
70public:
75 MultiversionData(const QMap<unsigned short /*version*/, SerializationBox>& serializers);
76
81 const DistVersion& packageVersion() const;
82
83 QDataStream& fromStream(QDataStream& stream) override final;
84 QDataStream& toStream(QDataStream& stream) const override final;
85
92 QByteArray toBytesOf(const DistVersion &version) const;
93
100 QDataStream& toStreamOf(QDataStream& stream, const DistVersion &version) const;
101
102
103 bool toPackage(Package &package, const DistVersion &reqVersion, unsigned int triggerHash = 0) const override final;
104
105
106private:
107 DistVersion _packageVersion;
108 QMap<unsigned short /*version*/, SerializationBox> _serializers;
109
110
111};
112}
113}
114#endif // MULTIVERSIONDATA_H
The DistVersion class This is information of supported versions of the destinations api.
Definition distversion.h:21
AbstractData()
AbstractData - Base constructor of this object.
QDataStream & toStreamOf(QDataStream &stream, const DistVersion &version) const
toStreamOf This overrload of the base toStream method for support the multi version packages.
QDataStream & fromStream(QDataStream &stream) override final
fromStream This method should be read all bytes from the stream object and full the current object.
QByteArray toBytesOf(const DistVersion &version) const
toBytesOf This is overload method of StreamBase::toBytes for support multi versions of packages.
MultiversionData(const QMap< unsigned short, SerializationBox > &serializers)
MultiversionData main constructor.
bool toPackage(Package &package, const DistVersion &reqVersion, unsigned int triggerHash=0) const override final
toPackage This method convert this class object to the package. For more info see Package class.
const DistVersion & packageVersion() const
packageVersion This method should be return number of the package version.
QDataStream & toStream(QDataStream &stream) const override final
fromStream This method should be write all members of the current object to the stream object.
The Package struct. This is base structure for transporting data by network between QH nodes....
Definition package.h:23
The PKG namespace - this namespace contains all default packages of the Heart library....
Definition heart.h:211
The QH namespace - QuasarApp Heart namespace. This namespace contains all classes of the Heart librar...
Definition heart.cpp:13
std::function< QDataStream &(QDataStream &stream)> to
std::function< QDataStream &(QDataStream &stream)> from