From 9bdb1c8c652ce0c6346628ffda56d1a947670238 Mon Sep 17 00:00:00 2001 From: EndrII Date: Mon, 29 Mar 2021 01:05:45 +0300 Subject: [PATCH] added base package --- src/Library/CMakeLists.txt | 2 +- src/Library/src/iconfiguration.cpp | 9 ++++ src/Library/src/iconfiguration.h | 16 +++++- src/Library/src/package.cpp | 64 ++++++++++++++++++++++ src/Library/src/package.h | 85 ++++++++++++++++++++++++++++++ src/Library/src/server.cpp | 7 +++ src/Library/src/server.h | 8 +++ 7 files changed, 189 insertions(+), 2 deletions(-) create mode 100644 src/Library/src/package.cpp create mode 100644 src/Library/src/package.h diff --git a/src/Library/CMakeLists.txt b/src/Library/CMakeLists.txt index 5bb4d42..aee4ff3 100644 --- a/src/Library/CMakeLists.txt +++ b/src/Library/CMakeLists.txt @@ -36,7 +36,7 @@ set(LANGS ${CMAKE_CURRENT_SOURCE_DIR}/languages/en.ts) prepareQM(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR} "${LANGS}") -setVersion(0 0 1) +setVersion(0 1 0) set(QML_IMPORT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/src" CACHE STRING "Qt Creator extra qml import paths") diff --git a/src/Library/src/iconfiguration.cpp b/src/Library/src/iconfiguration.cpp index 8ab46b7..bc022f6 100644 --- a/src/Library/src/iconfiguration.cpp +++ b/src/Library/src/iconfiguration.cpp @@ -21,4 +21,13 @@ void IConfiguration::setHostConfig(const HostConfiguration &hostConfig) { _hostConfig = hostConfig; } +QDataStream &IConfiguration::fromStream(QDataStream &stream) { + return stream; +} + +QDataStream &IConfiguration::toStream(QDataStream &stream) const { + return stream; + +} + } diff --git a/src/Library/src/iconfiguration.h b/src/Library/src/iconfiguration.h index 1d9b764..da4a358 100644 --- a/src/Library/src/iconfiguration.h +++ b/src/Library/src/iconfiguration.h @@ -9,6 +9,7 @@ #define ICONFIGURATION_H #include "CQtServer_global.h" #include "hostconfiguration.h" +#include namespace CQT { @@ -16,7 +17,7 @@ namespace CQT { * @brief The IConfiguration class This is base interface of all configuration. * The configuratin received from the main CQtDeployer application. */ -class CQTSERVER_EXPORT IConfiguration +class CQTSERVER_EXPORT IConfiguration: public QH::StreamBase { public: IConfiguration(const HostConfiguration &hostConfig); @@ -34,7 +35,20 @@ public: */ void setHostConfig(const HostConfiguration &hostConfig); + /** + * @brief name This method return the name of the configuration. + * @return name of the configuration. + */ + virtual const QString& name() const = 0; + +protected: + + // StreamBase interface + QDataStream &fromStream(QDataStream &stream) override; + QDataStream &toStream(QDataStream &stream) const override; + private: + HostConfiguration _hostConfig; }; } diff --git a/src/Library/src/package.cpp b/src/Library/src/package.cpp new file mode 100644 index 0000000..45515d4 --- /dev/null +++ b/src/Library/src/package.cpp @@ -0,0 +1,64 @@ +//# +//# Copyright (C) 2021-2021 QuasarApp. +//# Distributed under the lgplv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + +#include "iconfiguration.h" +#include "package.h" + +namespace CQT { + + +Package::Package() { + +} + +bool Package::isValid() const { + return AbstractData::isValid() && _config && _packageData.size(); +} + +bool Package::copyFrom(const QH::PKG::AbstractData *other) { + AbstractData::copy(*other); + return true; +} + +QString Package::toString() const { + return AbstractData::toString() + QString(" Configuration id: %0, Data size: %1"). + arg(_config->name(), _packageData.size()); +} + +QDataStream &Package::fromStream(QDataStream &stream) { + stream >> _packageData; + setConfig(initConfiguration()); + stream >> *_config; + + return stream; +} + +QDataStream &Package::toStream(QDataStream &stream) const { + stream << _packageData; + stream << *_config; + return stream; +} + +const QByteArray &Package::packageData() const { + return _packageData; +} + +void Package::setPackkageData(const QByteArray &packkageData) { + _packageData = packkageData; +} + +IConfiguration *Package::config() const { + return _config; +} + +void Package::setConfig(IConfiguration *config) { + if (_config) + delete _config; + + _config = config; +} +} diff --git a/src/Library/src/package.h b/src/Library/src/package.h new file mode 100644 index 0000000..90a7baf --- /dev/null +++ b/src/Library/src/package.h @@ -0,0 +1,85 @@ +//# +//# Copyright (C) 2021-2021 QuasarApp. +//# Distributed under the lgplv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + +#ifndef PACKAGE_H +#define PACKAGE_H +#include +#include "CQtServer_global.h" + + + +namespace CQT { + +class IConfiguration; +class iDistributor; + +/** + * @brief The Package class This is class with deployed package. The deployed package should be deploy on the server repository. + * 1. The cqtdeployer main tool prepare the package. + * 2. The cqtdeployer main tool send the pacakge to the server cqtdeployer tool. + * 3. The server tool deploy package on the own host. + */ +class CQTSERVER_EXPORT Package: public QH::PKG::AbstractData { +public: + Package(); + + bool isValid() const override; + bool copyFrom(const QH::PKG::AbstractData *other) override; + QString toString() const override; + + // StreamBase interface + + /** + * @brief config This method return the pointer to the current configuration. + * @return pointer to the cnfiguration. + */ + IConfiguration *config() const; + + /** + * @brief setConfig This method sets new configuration for this package object. + * @param config pointer to new configuration. + * @note This method remove old configuration if it exists. + */ + void setConfig(IConfiguration *config); + + /** + * @brief packkageData This method retun the physical data of the deployed distribution. + * @return reference to the physical data. + */ + const QByteArray& packageData() const; + + /** + * @brief setPackkageData This method sets new data of the distributionkit. + * @param packkageData new data of the distributionkeit. + */ + void setPackkageData(const QByteArray &packkageData); + +protected: + QDataStream &fromStream(QDataStream &stream) override; + QDataStream &toStream(QDataStream &stream) const override; + + /** + * @brief initConfiguration This method must be init new object of the Cnfiguration. + * each package type should be contains own configuration type. + * @return pointer to the configuration type. + * @note This method uses for init data object from the bytesaArray. + */ + virtual IConfiguration * initConfiguration() const = 0; + + /** + * @brief initDistribute This method must be init distribute of this pacakge data. + * @return pointer of the distibuteobject. + */ + virtual iDistributor* initDistribute() const = 0; + +private: + IConfiguration *_config = nullptr; + QByteArray _packageData; +}; +} + +#endif // PACKAGE_H diff --git a/src/Library/src/server.cpp b/src/Library/src/server.cpp index bb825bc..dfd50c6 100644 --- a/src/Library/src/server.cpp +++ b/src/Library/src/server.cpp @@ -1,3 +1,10 @@ +//# +//# Copyright (C) 2021-2021 QuasarApp. +//# Distributed under the lgplv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + #include "server.h" namespace CQT { diff --git a/src/Library/src/server.h b/src/Library/src/server.h index 17e86ca..dfb2296 100644 --- a/src/Library/src/server.h +++ b/src/Library/src/server.h @@ -1,3 +1,10 @@ +//# +//# Copyright (C) 2021-2021 QuasarApp. +//# Distributed under the lgplv3 software license, see the accompanying +//# Everyone is permitted to copy and distribute verbatim copies +//# of this license document, but changing it is not allowed. +//# + #ifndef SERVER_H #define SERVER_H @@ -13,6 +20,7 @@ namespace CQT { */ class Server : public QH::AbstractNode { + Q_OBJECT public: Server(); };