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

The AbstractData class is provide base functions for transport data by network For create you own package you need to inherited from this class. Simple Example: More...

#include <abstractdata.h>

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

Public Member Functions

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

Static Public Member Functions

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

 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 QDataStream & fromStream (QDataStream &stream)=0
 fromStream This method should be read all bytes from the stream object and full the current object.
 
virtual QDataStream & toStream (QDataStream &stream) const =0
 fromStream This method should be write all members of the current object to the stream object.
 
virtual unsigned int typeId () const
 typeId This method return id of type.
 

Detailed Description

The AbstractData class is provide base functions for transport data by network For create you own package you need to inherited from this class. Simple Example:

class MyPackage: public QH::AbstractData
{
QH_PACKAGE_AUTO_VER(MyPackage, 1)
public:
MyPackage();
// your data for for server of client
std::string _data = "";
protected:
// StreamBase interface override this methods for serialization your package
QDataStream &fromStream(QDataStream &stream) {
stream >> _data;
return stream;
}
QDataStream &toStream(QDataStream &stream) const {
stream << _data;
return stream;
}
};
The AbstractData class is provide base functions for transport data by network For create you own pac...

This is simple implementation of package for transport text data. You need to override 2 serialization methods (fromStream and toStream).

See also
AbstractNode

Definition at line 82 of file abstractdata.h.

Constructor & Destructor Documentation

◆ ~AbstractData()

QH::PKG::AbstractData::~AbstractData ( )
override

Definition at line 55 of file abstractdata.cpp.

◆ AbstractData()

QH::PKG::AbstractData::AbstractData ( )
explicitprotected

AbstractData - Base constructor of this object.

Definition at line 18 of file abstractdata.cpp.

Member Function Documentation

◆ cmd()

virtual unsigned short QH::PKG::AbstractData::cmd ( ) const
pure virtual

cmd - This is command of this object, (for generate cmd use macross QH_PACKAGE)

Note
Use the QH_PACKAGE macross for implement this method.
Returns
global command of package.
See also
QH_PACKAGE

Implemented in QH::PKG::APIVersion, and QH::PKG::VersionIsReceived.

Here is the caller graph for this function:

◆ cmdString()

virtual QString QH::PKG::AbstractData::cmdString ( ) const
pure virtual

cmdString - This is command string of this object, (for generate cmd use macross QH_PACKAGE)

Note
Use the QH_PACKAGE macross for implement this method.
Returns
global command of package.
See also
QH_PACKAGE

Implemented in QH::PKG::APIVersion, and QH::PKG::VersionIsReceived.

Here is the caller graph for this function:

◆ command()

static unsigned int QH::PKG::AbstractData::command ( )
inlinestatic

command This static method that return glaball code of this object.

Note
This method generated automaticaly in the QH_PACKAGE macross.
Returns
global code
See also
QH_PACKAGE

Definition at line 149 of file abstractdata.h.

Here is the caller graph for this function:

◆ commandText()

static QString QH::PKG::AbstractData::commandText ( )
inlinestatic

commandText This method return text of package command

Returns
text of pacakge command

Definition at line 155 of file abstractdata.h.

◆ create()

template<class C , class... Args>
C * QH::PKG::AbstractData::create ( Args &&...  args) const
inline

create - This is factory method for create a new object.

Parameters
args- List of arguments for create object.
Returns
Pointer to created object.

Definition at line 132 of file abstractdata.h.

◆ fromPakcage()

void QH::PKG::AbstractData::fromPakcage ( const Package pkg)

fromPakcage - This method initialize the current object from a package class object.

Parameters
pkg- Input package value.

Definition at line 51 of file abstractdata.cpp.

Here is the call graph for this function:

◆ isValid()

bool QH::PKG::AbstractData::isValid ( ) const
virtual

isValid This method check current object to valid.

Returns
True if class isValid.

Reimplemented in QH::PKG::APIVersion, QH::PKG::BigDataBase, QH::PKG::BigDataHeader, QH::PKG::BigDataPart, QH::PKG::DataPack< Package >, QH::PKG::DBObject, QH::PKG::DBObjectsRequest< T >, and QH::PKG::Ping.

Definition at line 40 of file abstractdata.cpp.

Here is the caller graph for this function:

◆ toPackage()

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

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 in QH::PKG::MultiversionData.

Definition at line 21 of file abstractdata.cpp.

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

◆ toString()

QString QH::PKG::AbstractData::toString ( ) const
override

toString - Return a string implementation for this object.

Returns
String of object.

Definition at line 44 of file abstractdata.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: