Heart 1.3.842.34c2ab5
Heart is base back end library for your c++ Qt projects.
QH::Package Class Reference

The Package struct. This is base structure for transporting data by network between QH nodes. The Package contains a 32 bytes header and Package::data array. The size on the header should be equals size of Package::data array. More...

#include <package.h>

Inheritance diagram for QH::Package:
Inheritance graph
Collaboration diagram for QH::Package:
Collaboration graph

Public Member Functions

 Package ()
 
virtual ~Package ()=default
 
virtual bool isValid () const
 isValid This method validation a current package. Default implementation is checked a header and compare a size of package in header and size of source data.
 
virtual void reset ()
 reset This method reset all data and set for package invalid status.
 
QString toString () const
 toString This method convert a package information to a string label.
 
unsigned int calcHash () const
 calcHash This method recalc hash sum for this pacakge.
 
- 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.
 

Static Public Member Functions

static unsigned int maximumSize ()
 maximumSize This method return maximu size of pacakge. If pacakge large the maximum size then package will separate to BigDataPart in sending.
 

Public Attributes

Header hdr
 hdr This is header of package. For more information see the Header struct.
 
QByteArray data
 data This is source data of package.
 

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::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.
 

Detailed Description

The Package struct. This is base structure for transporting data by network between QH nodes. The Package contains a 32 bytes header and Package::data array. The size on the header should be equals size of Package::data array.

Definition at line 23 of file package.h.

Constructor & Destructor Documentation

◆ Package()

QH::Package::Package ( )

Definition at line 14 of file package.cpp.

Here is the call graph for this function:

◆ ~Package()

virtual QH::Package::~Package ( )
virtualdefault

Member Function Documentation

◆ calcHash()

unsigned int QH::Package::calcHash ( ) const

calcHash This method recalc hash sum for this pacakge.

Returns
int32 hash of pacakge.

Definition at line 44 of file package.cpp.

Here is the caller graph for this function:

◆ fromStream()

QDataStream & QH::Package::fromStream ( QDataStream &  stream)
overrideprotectedvirtual

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 53 of file package.cpp.

Here is the call graph for this function:

◆ isValid()

bool QH::Package::isValid ( ) const
virtual

isValid This method validation a current package. Default implementation is checked a header and compare a size of package in header and size of source data.

Returns
true if package is valid.

Definition at line 18 of file package.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ maximumSize()

unsigned int QH::Package::maximumSize ( )
static

maximumSize This method return maximu size of pacakge. If pacakge large the maximum size then package will separate to BigDataPart in sending.

Returns
size in bytes of pacakge.

Definition at line 49 of file package.cpp.

Here is the caller graph for this function:

◆ reset()

void QH::Package::reset ( )
virtual

reset This method reset all data and set for package invalid status.

Definition at line 33 of file package.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toStream()

QDataStream & QH::Package::toStream ( QDataStream &  stream) const
overrideprotectedvirtual

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 67 of file package.cpp.

◆ toString()

QString QH::Package::toString ( ) const

toString This method convert a package information to a string label.

Returns
string value of the package.

Definition at line 38 of file package.cpp.

Here is the call graph for this function:

Member Data Documentation

◆ data

QByteArray QH::Package::data

data This is source data of package.

Definition at line 33 of file package.h.

◆ hdr

Header QH::Package::hdr

hdr This is header of package. For more information see the Header struct.

Definition at line 29 of file package.h.


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