24template<
class Package>
31 DataPack(
const QList<QSharedPointer<Package>> &newPackData = {}) {
32 setPackData(newPackData);
33#ifdef HEART_VALIDATE_PACKS
34 static_assert(std::is_base_of_v<UniversalData, Package> &&
35 "The template class of DataPack must be child of the UniversalData class");
43 unsigned int size()
const {
44 return _packData.size();
51 const QList<QSharedPointer<Package>> &
packData()
const {
59 void setPackData(
const QList<QSharedPointer<Package>> &newPackData) {
60 _packData = newPackData;
67 void push(
const QSharedPointer<Package>& data) {
68 _packData.push_back(data);
76 _packData.push_back(QSharedPointer<Package>::create(data));
85 if (!_packData.size()) {
89 for (
const auto& it: _packData) {
122 for (
int i = 0; i <
size; ++i) {
123 auto data = QSharedPointer<Package>::create();
126 _packData.push_back(data);
134 QDataStream &
toStream(QDataStream &stream)
const override {
135 stream << static_cast<int>(_packData.size());
137 for (
const auto &data: std::as_const(_packData)) {
147 QList<QSharedPointer<Package>> _packData;
#define QH_PACKAGE(S)
QH_PACKAGE This macross prepare data to send and create a global id for package. For get global id us...
bool isValid() const override
isValid This method check current object to valid.
AbstractData()
AbstractData - Base constructor of this object.
bool isValid() const override
isValid This implementation check all items of the pack to valid and packa size. The pack size should...
void setCustomData(const QByteArray &newToken)
setCustomData This method sets custom data block
const QByteArray & customData() const
token is custom data block.
void push(const QSharedPointer< Package > &data)
push This method append data to end of list.
QDataStream & fromStream(QDataStream &stream) override
fromStream This method should be read all bytes from the stream object and full the current object.
void setPackData(const QList< QSharedPointer< Package > > &newPackData)
setPackData This method sets new lsit of pacakges.
unsigned int size() const
size This method return of the items count of this pack.
DataPack(const QList< QSharedPointer< Package > > &newPackData={})
QDataStream & toStream(QDataStream &stream) const override
fromStream This method should be write all members of the current object to the stream object.
const QList< QSharedPointer< Package > > & packData() const
packData This method return source list of the elements.
void push(const Package &data)
push This method append data to end of list.
The Package struct. This is base structure for transporting data by network between QH nodes....
The PKG namesapce - this namespace contains all default packages of the Heart library....
The QH namespace - QuasarApp Heart namespace. This namespace contains all classes of the Heart librar...