mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-03 07:35:48 +08:00
* distribution is just the channel, no more the concrete file * masterdir no longer part of distribution * using QStringList instead of QSet in some place so sort order is kept * new utility functions
88 lines
3.0 KiB
C++
88 lines
3.0 KiB
C++
/* 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_DISTRIBUTIONLIST_H
|
|
#define BLACKMISC_DB_DISTRIBUTIONLIST_H
|
|
|
|
#include "distribution.h"
|
|
#include "blackmisc/db/datastoreobjectlist.h"
|
|
#include "blackmisc/platform.h"
|
|
#include "blackmisc/blackmiscexport.h"
|
|
#include "blackmisc/collection.h"
|
|
#include "blackmisc/sequence.h"
|
|
#include "blackmisc/variant.h"
|
|
#include <QSet>
|
|
#include <QString>
|
|
|
|
namespace BlackMisc
|
|
{
|
|
namespace Db
|
|
{
|
|
//! Multiple distributions for different channels:
|
|
//! - one CDistribution objects contains all artifacts for a channel
|
|
//! - a distribution list normally contains all artifacts for all channels
|
|
//! \sa CArtifact
|
|
class BLACKMISC_EXPORT CDistributionList :
|
|
public CSequence<CDistribution>,
|
|
public IDatastoreObjectList<CDistribution, CDistributionList, int>,
|
|
public Mixin::MetaType<CDistributionList>
|
|
{
|
|
public:
|
|
BLACKMISC_DECLARE_USING_MIXIN_METATYPE(CDistributionList)
|
|
|
|
//! Empty constructor.
|
|
CDistributionList();
|
|
|
|
//! Construct from a base class object.
|
|
CDistributionList(const CSequence<CDistribution> &other);
|
|
|
|
//! All channels
|
|
QStringList getChannels() const;
|
|
|
|
//! Stability
|
|
void sortByStability(Qt::SortOrder order = Qt::AscendingOrder);
|
|
|
|
//! Contains distributions considered of same stability or more stable
|
|
bool containsEqualOrMoreStable(CDistribution &distribution) const;
|
|
|
|
//! Contains any unrestricted
|
|
bool containsUnrestricted() const;
|
|
|
|
//! Contains channel?
|
|
bool containsChannel(const QString &channel) const;
|
|
|
|
//! Find by channel
|
|
CDistribution findFirstByChannelOrDefault(const QString &channel) const;
|
|
|
|
//! Find by restriction flag
|
|
CDistributionList findByRestriction(bool restricted) const;
|
|
|
|
//! Most stable or default
|
|
CDistribution getMostStableOrDefault() const;
|
|
|
|
//! Least stable or default
|
|
CDistribution getLeastStableOrDefault() const;
|
|
|
|
//! From database JSON by array
|
|
static CDistributionList fromDatabaseJson(const QJsonArray &array);
|
|
|
|
//! From database JSON by string
|
|
static CDistributionList fromDatabaseJson(const QString &json);
|
|
};
|
|
} // ns
|
|
} // ns
|
|
|
|
Q_DECLARE_METATYPE(BlackMisc::Db::CDistributionList)
|
|
Q_DECLARE_METATYPE(BlackMisc::CCollection<BlackMisc::Db::CDistribution>)
|
|
Q_DECLARE_METATYPE(BlackMisc::CSequence<BlackMisc::Db::CDistribution>)
|
|
|
|
#endif //guard
|