Heart 1.3.842.34c2ab5
Heart is base back end library for your c++ Qt projects.
QH::PKG::DataPack< Package > Class Template Referencefinal

DataPack this is conteiner is wraqper of the QList for transport arrays to another node. More...

#include <datapack.h>

Inheritance diagram for QH::PKG::DataPack< Package >:
Inheritance graph
Collaboration diagram for QH::PKG::DataPack< Package >:
Collaboration graph

Public Member Functions

 DataPack (const QList< QSharedPointer< Package > > &newPackData={})
 
unsigned int size () const
 size This method return of the items count of this pack.
 
const QList< QSharedPointer< Package > > & packData () const
 packData This method return source list of the elements.
 
void setPackData (const QList< QSharedPointer< Package > > &newPackData)
 setPackData This method sets new lsit of pacakges.
 
void push (const QSharedPointer< Package > &data)
 push This method append data to end of list.
 
void push (const Package &data)
 push This method append data to end of list.
 
bool isValid () const override
 isValid This implementation check all items of the pack to valid and packa size. The pack size should be more then 0.
 
const QByteArray & customData () const
 token is custom data block.
 
void setCustomData (const QByteArray &newToken)
 setCustomData This method sets custom data block
 
- Public Member Functions inherited from QH::PKG::AbstractData
 ~AbstractData () override
 
virtual unsigned short cmd () const =0
 cmd - This is command of this object, (for generate cmd use macross QH_PACKAGE)
 
virtual QString cmdString () const =0
 cmdString - This is command string of this object, (for generate cmd use macross QH_PACKAGE)
 
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.
 
QString toString () const override
 toString - Return a string implementation for this object.
 
template<class C , class... Args>
C * create (Args &&... args) const
 create - This is factory method for create a new object.
 
void fromPakcage (const Package &pkg)
 fromPakcage - This method initialize the current object from a package class object.
 
- Public Member Functions inherited from QH::StreamBase
 StreamBase ()
 
virtual ~StreamBase ()
 
bool fromBytes (const QByteArray &data)
 fromBytes This method provide initialization of object from byte array.
 
QByteArray toBytes () const
 toBytes This method convert a current object to bytes array.
 
bool fromBase64 (const QString &data)
 fromBase64 This method provide initialization of object from the base64 string.
 
bool fromBase64 (const QByteArray &data)
 fromBase64 This method provide initialization of object from the base64 string.
 
QByteArray toBase64 () const
 toBase64 This method convert a current object to the base64 string.
 
template<class T >
T & copy (const StreamBase &right)
 copy This is base copy method for all StreamBase structures. Default implementation it is copy from byteArray.
 
template<class T >
bool compare (const T &right)
 compare This method compare array signatures of this and right objects.
 

Protected Member Functions

QDataStream & fromStream (QDataStream &stream) override
 fromStream This method should be read all bytes from the stream object and full the current object.
 
QDataStream & toStream (QDataStream &stream) const override
 fromStream This method should be write all members of the current object to the stream object.
 
- Protected Member Functions inherited from QH::PKG::AbstractData
 AbstractData ()
 AbstractData - Base constructor of this object.
 
- Protected Member Functions inherited from QH::StreamBase
virtual int parsingVersion () const
 parsingVersion this method return parsing version of Qt. By Default is 0 (last available parsing). see https://doc.qt.io/qt-6/qdatastream.html#Version-enum
 
virtual unsigned int typeId () const
 typeId This method return id of type.
 

Additional Inherited Members

- Static Public Member Functions inherited from QH::PKG::AbstractData
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
 

Detailed Description

template<class Package>
class QH::PKG::DataPack< Package >

DataPack this is conteiner is wraqper of the QList for transport arrays to another node.

Template Parameters
PackageThis is type of trasported pacakges item.
Note
All packs data objects should be inherited of the UniversalData class. This is due to classes base on abstract data may broken transporting data between nodes if you change toStream and fromStream methods. To fix this issue, we use QVariantMap container for parsing data.
See also
UniversalData

Definition at line 25 of file datapack.h.

Constructor & Destructor Documentation

◆ DataPack()

template<class Package >
QH::PKG::DataPack< Package >::DataPack ( const QList< QSharedPointer< Package > > &  newPackData = {})
inline

Definition at line 31 of file datapack.h.

Member Function Documentation

◆ customData()

template<class Package >
const QByteArray & QH::PKG::DataPack< Package >::customData ( ) const
inline

token is custom data block.

Note
The custom data block do not validate. If you want to add validation for custom data block then override the isValid method.
Returns
custom data block

Definition at line 104 of file datapack.h.

◆ fromStream()

template<class Package >
QDataStream & QH::PKG::DataPack< Package >::fromStream ( QDataStream &  stream)
inlineoverrideprotectedvirtual

fromStream This method should be read all bytes from the stream object and full the current object.

Note
The implementation of this method should be invoke a method of base class.
Parameters
streamThis is Qt stream object.
Returns
Qt stream object.

Examle of base simple implementation:

QDataStream &ExampleClass::fromStream(QDataStream &stream) const {
stream >> exampleMember;
return stream;
}
virtual QDataStream & toStream(QDataStream &stream) const =0
fromStream This method should be write all members of the current object to the stream object.

Implements QH::StreamBase.

Definition at line 117 of file datapack.h.

Here is the call graph for this function:

◆ isValid()

template<class Package >
bool QH::PKG::DataPack< Package >::isValid ( ) const
inlineoverridevirtual

isValid This implementation check all items of the pack to valid and packa size. The pack size should be more then 0.

Returns
true if the pack of items is valid else flase..

Reimplemented from QH::PKG::AbstractData.

Definition at line 83 of file datapack.h.

Here is the call graph for this function:

◆ packData()

template<class Package >
const QList< QSharedPointer< Package > > & QH::PKG::DataPack< Package >::packData ( ) const
inline

packData This method return source list of the elements.

Returns
source list

Definition at line 51 of file datapack.h.

◆ push() [1/2]

template<class Package >
void QH::PKG::DataPack< Package >::push ( const Package data)
inline

push This method append data to end of list.

Parameters
dataThis is new data pacakge that will be added into back of this list.

Definition at line 75 of file datapack.h.

◆ push() [2/2]

template<class Package >
void QH::PKG::DataPack< Package >::push ( const QSharedPointer< Package > &  data)
inline

push This method append data to end of list.

Parameters
dataThis is new data pacakge that will be added into back of this list.

Definition at line 67 of file datapack.h.

◆ setCustomData()

template<class Package >
void QH::PKG::DataPack< Package >::setCustomData ( const QByteArray &  newToken)
inline

setCustomData This method sets custom data block

Parameters
newToken

Definition at line 112 of file datapack.h.

◆ setPackData()

template<class Package >
void QH::PKG::DataPack< Package >::setPackData ( const QList< QSharedPointer< Package > > &  newPackData)
inline

setPackData This method sets new lsit of pacakges.

Parameters
newPackDataThis is new source lsit.

Definition at line 59 of file datapack.h.

◆ size()

template<class Package >
unsigned int QH::PKG::DataPack< Package >::size ( ) const
inline

size This method return of the items count of this pack.

Returns
size of the packs.

Definition at line 43 of file datapack.h.

Here is the caller graph for this function:

◆ toStream()

template<class Package >
QDataStream & QH::PKG::DataPack< Package >::toStream ( QDataStream &  stream) const
inlineoverrideprotectedvirtual

fromStream This method should be write all members of the current object to the stream object.

Note
The implementation of this method should be invoke a method of base class.
Parameters
streamThis is Qt stream object.
Returns
Qt stream object.

Examle of base simple implementation:

QDataStream &ExampleClass::toStream(QDataStream &stream) const {
stream << exampleMember;
return stream;
}

Implements QH::StreamBase.

Definition at line 134 of file datapack.h.


The documentation for this class was generated from the following file: