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

The MultiversionData class This class add support for multiple versions of ne command/package. If you need to add support multiple versions make your pakcage class children of the MultiversionData class. More...

#include <multiversiondata.h>

Inheritance diagram for QH::PKG::MultiversionData:
Inheritance graph
Collaboration diagram for QH::PKG::MultiversionData:
Collaboration graph

Public Member Functions

 MultiversionData (const QMap< unsigned short, SerializationBox > &serializers)
 MultiversionData main constructor.
 
const DistVersionpackageVersion () const
 packageVersion This method should be return number of the pacakge version.
 
QDataStream & fromStream (QDataStream &stream) override final
 fromStream This method should be read all bytes from the stream object and full the current object.
 
QDataStream & toStream (QDataStream &stream) const override final
 fromStream This method should be write all members of the current object to the stream object.
 
QByteArray toBytesOf (const DistVersion &version) const
 toBytesOf This is overload method of StreamBase::toBytes for support multi versions of packages.
 
QDataStream & toStreamOf (QDataStream &stream, const DistVersion &version) const
 toStreamOf This overrload of the base toStream method for support the multi version packages.
 
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.
 
- 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 isValid () const
 isValid This method check current object to valid.
 
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.
 

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

Detailed Description

The MultiversionData class This class add support for multiple versions of ne command/package. If you need to add support multiple versions make your pakcage class children of the MultiversionData class.

Example:

class MyPackage: public MultiversionData {
MyPackage(): QH::PKG::MultiversionData(
{
{0, // version 0
{
[this](QDataStream& stream) -> QDataStream&{ // from
stream >> v1;
return stream;
},
[this](QDataStream& stream) -> QDataStream&{ // to
stream << v1;
return stream;
}
}
},
{1, // version 1
{
[this](QDataStream& stream) -> QDataStream&{ // from
stream >> v1;
stream >> v2;
return stream;
},
[this](QDataStream& stream) -> QDataStream&{ // to
stream << v1;
stream << v2;
return stream;
}
}
}
}
) {};
The MultiversionData class This class add support for multiple versions of ne command/package....
The QH namespace - QuasarApp Heart namespace. This namespace contains all classes of the Heart librar...
Definition heart.cpp:13
Note
the default toBytes function of this class will be convert your class using latest version.

Definition at line 67 of file multiversiondata.h.

Constructor & Destructor Documentation

◆ MultiversionData()

QH::PKG::MultiversionData::MultiversionData ( const QMap< unsigned short, SerializationBox > &  serializers)

MultiversionData main constructor.

Parameters
serializersthis is map of the all supported versions.

Definition at line 18 of file multiversiondata.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ fromStream()

QDataStream & QH::PKG::MultiversionData::fromStream ( QDataStream &  stream)
finaloverridevirtual

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 27 of file multiversiondata.cpp.

◆ packageVersion()

const DistVersion & QH::PKG::MultiversionData::packageVersion ( ) const

packageVersion This method should be return number of the pacakge version.

Returns
pcakge version. by default return - 0 (any version)

Definition at line 113 of file multiversiondata.cpp.

◆ toBytesOf()

QByteArray QH::PKG::MultiversionData::toBytesOf ( const DistVersion version) const

toBytesOf This is overload method of StreamBase::toBytes for support multi versions of packages.

Parameters
versionThis is required version pacakge.
Returns
bytes array for package.
Note
This is just wrapper method for the AbstractData::toStream method.

Definition at line 64 of file multiversiondata.cpp.

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

◆ toPackage()

bool QH::PKG::MultiversionData::toPackage ( Package package,
const DistVersion reqVersion,
unsigned int  triggerHash = 0 
) const
finaloverridevirtual

toPackage This method convert this class object to the package. For more info see Package class.

Parameters
packageThis is return value of Package class.
reqVersionThis is required version. This method create package of the needed version.
triggerHashThis is hash of the package the current class is responding to.
Returns
True if convert to package finished successful.

Reimplemented from QH::PKG::AbstractData.

Definition at line 95 of file multiversiondata.cpp.

Here is the call graph for this function:

◆ toStream()

QDataStream & QH::PKG::MultiversionData::toStream ( QDataStream &  stream) const
finaloverridevirtual

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 49 of file multiversiondata.cpp.

◆ toStreamOf()

QDataStream & QH::PKG::MultiversionData::toStreamOf ( QDataStream &  stream,
const DistVersion version 
) const

toStreamOf This overrload of the base toStream method for support the multi version packages.

Parameters
streamthis is stream object.
versionthis is custom version of parsing function.
Returns
stream object.

Definition at line 76 of file multiversiondata.cpp.

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

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