mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-18 11:25:33 +08:00
Ref T203, update info combining artifacts and distributions
This commit is contained in:
125
src/blackmisc/db/updateinfo.h
Normal file
125
src/blackmisc/db/updateinfo.h
Normal file
@@ -0,0 +1,125 @@
|
||||
/* Copyright (C) 2017
|
||||
* swift project community / contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKMISC_DB_UPDATEINFO_H
|
||||
#define BLACKMISC_DB_UPDATEINFO_H
|
||||
|
||||
#include "artifactlist.h"
|
||||
#include "distributionlist.h"
|
||||
#include "blackmisc/datacache.h"
|
||||
#include "blackmisc/valueobject.h"
|
||||
#include <QStringList>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Db
|
||||
{
|
||||
//! Update info, i.e. artifacts and distributions
|
||||
//! \sa CArtifact
|
||||
//! \sa CDistribution
|
||||
class BLACKMISC_EXPORT CUpdateInfo : public CValueObject<CUpdateInfo>
|
||||
{
|
||||
public:
|
||||
//! Properties by index
|
||||
enum ColumnIndex
|
||||
{
|
||||
IndexArtifactsPilotClient = CPropertyIndex::GlobalIndexCUpdateInfo,
|
||||
IndexArtifactsXSwiftBus,
|
||||
IndexDistributions
|
||||
};
|
||||
|
||||
//! Constructor
|
||||
CUpdateInfo() {}
|
||||
|
||||
//! Constructor
|
||||
CUpdateInfo(const CArtifactList &artifacts, const CDistributionList &distributions);
|
||||
|
||||
//! Destructor.
|
||||
~CUpdateInfo() {}
|
||||
|
||||
//! Artifacts (pilot client)
|
||||
const CArtifactList &getArtifactsPilotClient() const { return m_artifactsPilotClient; }
|
||||
|
||||
//! Artifacts for current platform
|
||||
//! \note sorted by version
|
||||
CArtifactList getArtifactsPilotClientForCurrentPlatform() const;
|
||||
|
||||
//! Artifacts (XSwiftBus)
|
||||
const CArtifactList &getArtifactsXsb() const { return m_artifactsXsb; }
|
||||
|
||||
//! Artifacts (XSwiftBus)
|
||||
CArtifactList getArtifactsXsbLatestVersionFirst() const;
|
||||
|
||||
//! Artifacts for current platform
|
||||
//! \note sorted by version
|
||||
CArtifactList getArtifactsXsbForCurrentPlatform() const;
|
||||
|
||||
//! Distributions (all)
|
||||
const CDistributionList &getDistributions() const { return m_distributions; }
|
||||
|
||||
//! Distributions for current platform
|
||||
CDistributionList getDistributionsPilotClientForCurrentPlatform() const;
|
||||
|
||||
//! Own distribution
|
||||
CDistribution anticipateOwnDistribution() const;
|
||||
|
||||
//! Default channel, OS
|
||||
QStringList anticipateMyDefaultChannelAndPlatform() const;
|
||||
|
||||
//! Empty (no data)
|
||||
bool isEmpty() const { return m_artifactsPilotClient.isEmpty() && m_distributions.isEmpty(); }
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
//! To string
|
||||
QString convertToQString(const QString &separator, bool i18n = false) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
||||
BlackMisc::CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
||||
void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const BlackMisc::CVariant &variant);
|
||||
|
||||
//! Object from database JSON format
|
||||
static CUpdateInfo fromDatabaseJson(const QJsonObject &json, const QString &prefix = {});
|
||||
|
||||
//! Object from database JSOn format
|
||||
static CUpdateInfo fromDatabaseJson(const QString &jsonString);
|
||||
|
||||
private:
|
||||
CArtifactList m_artifactsPilotClient; //!< artifacts pilot client
|
||||
CArtifactList m_artifactsXsb; //!< artifacts XSwiftBus
|
||||
CDistributionList m_distributions; //!< all distributions (for any artifacts)
|
||||
|
||||
BLACK_METACLASS(
|
||||
CUpdateInfo,
|
||||
BLACK_METAMEMBER(artifactsPilotClient),
|
||||
BLACK_METAMEMBER(artifactsXsb),
|
||||
BLACK_METAMEMBER(distributions)
|
||||
);
|
||||
};
|
||||
|
||||
//! Trait for update info, i.e. distributions and artifacts
|
||||
struct TUpdateInfo : public TDataTrait<CUpdateInfo>
|
||||
{
|
||||
//! Key in data cache
|
||||
static const char *key() { return "updateinfo"; }
|
||||
|
||||
//! First load is synchronous
|
||||
static constexpr bool isPinned() { return true; }
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Db::CUpdateInfo)
|
||||
|
||||
#endif // guard
|
||||
Reference in New Issue
Block a user