2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2012-01-18 13:50:14 +01:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
|
** Contact: http://www.qt.io/licensing
|
2012-01-18 13:50:14 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2012-01-18 13:50:14 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2015-01-14 18:07:15 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms and
|
|
|
|
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
2014-10-01 13:21:18 +02:00
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2012-01-18 13:50:14 +01:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2012-01-18 13:50:14 +01:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
2012-01-18 13:50:14 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2012-01-18 13:50:14 +01:00
|
|
|
|
2013-03-12 12:07:32 +01:00
|
|
|
#ifndef FEATUREPROVIDER_H
|
|
|
|
|
#define FEATUREPROVIDER_H
|
2012-01-18 13:50:14 +01:00
|
|
|
|
|
|
|
|
#include "core_global.h"
|
|
|
|
|
|
|
|
|
|
#include <coreplugin/id.h>
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QSet>
|
|
|
|
|
#include <QStringList>
|
2012-01-18 13:50:14 +01:00
|
|
|
|
|
|
|
|
namespace Core {
|
|
|
|
|
|
|
|
|
|
class CORE_EXPORT FeatureSet;
|
|
|
|
|
|
2014-07-29 16:39:03 +02:00
|
|
|
class CORE_EXPORT IFeatureProvider
|
2012-01-18 13:50:14 +01:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
IFeatureProvider() {}
|
|
|
|
|
virtual ~IFeatureProvider() {}
|
2012-02-08 17:25:35 +01:00
|
|
|
virtual FeatureSet availableFeatures(const QString &platform) const = 0;
|
|
|
|
|
virtual QStringList availablePlatforms() const = 0;
|
|
|
|
|
virtual QString displayNameForPlatform(const QString &string) const = 0;
|
2012-01-18 13:50:14 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CORE_EXPORT Feature : public Id
|
|
|
|
|
{
|
|
|
|
|
public:
|
2015-06-24 12:32:28 +02:00
|
|
|
Feature() = default;
|
|
|
|
|
template <int N> Feature(const char(&ch)[N]) : Id(ch) { }
|
|
|
|
|
|
|
|
|
|
static Feature fromString(const QString &str) { return Feature(Id::fromString(str)); }
|
|
|
|
|
static Feature fromName(const QByteArray &ba) { return Feature(Id::fromName(ba)); }
|
|
|
|
|
|
2015-06-24 15:56:47 +02:00
|
|
|
static Feature versionedFeature(const QByteArray &prefix, int major = -1, int minor = -1);
|
|
|
|
|
|
2015-06-24 12:32:28 +02:00
|
|
|
private:
|
|
|
|
|
explicit Feature(const Id id) : Id(id) { }
|
2012-01-18 13:50:14 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CORE_EXPORT FeatureSet : private QSet<Feature>
|
|
|
|
|
{
|
|
|
|
|
public:
|
2015-06-24 12:32:28 +02:00
|
|
|
explicit FeatureSet(Feature id)
|
2012-01-18 13:50:14 +01:00
|
|
|
{
|
2013-01-15 16:11:50 +01:00
|
|
|
if (id.isValid())
|
|
|
|
|
insert(id);
|
2012-01-18 13:50:14 +01:00
|
|
|
}
|
|
|
|
|
|
2015-06-24 12:32:28 +02:00
|
|
|
FeatureSet() = default;
|
|
|
|
|
FeatureSet(const FeatureSet &other) = default;
|
|
|
|
|
FeatureSet &operator=(const FeatureSet &other) = default;
|
2012-01-18 13:50:14 +01:00
|
|
|
|
2015-06-24 15:56:47 +02:00
|
|
|
static FeatureSet versionedFeatures(const QByteArray &prefix, int major, int minor = -1);
|
|
|
|
|
|
2015-06-24 12:32:28 +02:00
|
|
|
using QSet<Feature>::isEmpty;
|
2014-07-30 16:37:41 +02:00
|
|
|
|
2012-01-18 13:50:14 +01:00
|
|
|
bool contains(const Feature &feature) const
|
|
|
|
|
{
|
|
|
|
|
return QSet<Feature>::contains(feature);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool contains(const FeatureSet &features) const
|
|
|
|
|
{
|
|
|
|
|
return QSet<Feature>::contains(features);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void remove(const Feature &feature)
|
|
|
|
|
{
|
|
|
|
|
QSet<Feature>::remove(feature);
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-30 16:37:41 +02:00
|
|
|
void remove(const FeatureSet &features)
|
|
|
|
|
{
|
|
|
|
|
QSet<Feature>::subtract(features);
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-18 13:50:14 +01:00
|
|
|
FeatureSet operator|(const Feature &feature) const
|
|
|
|
|
{
|
|
|
|
|
FeatureSet copy = *this;
|
|
|
|
|
if (feature.isValid())
|
|
|
|
|
copy.insert(feature);
|
|
|
|
|
return copy;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FeatureSet operator|(const FeatureSet &features) const
|
|
|
|
|
{
|
|
|
|
|
FeatureSet copy = *this;
|
|
|
|
|
if (!features.isEmpty())
|
|
|
|
|
copy.unite(features);
|
|
|
|
|
return copy;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FeatureSet &operator|=(const Feature &feature)
|
|
|
|
|
{
|
|
|
|
|
if (feature.isValid())
|
|
|
|
|
insert(feature);
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FeatureSet &operator|=(const FeatureSet &features)
|
|
|
|
|
{
|
|
|
|
|
if (!features.isEmpty())
|
|
|
|
|
unite(features);
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringList toStringList() const
|
|
|
|
|
{
|
|
|
|
|
QStringList stringList;
|
|
|
|
|
foreach (const Feature &feature, QSet<Feature>(*this))
|
|
|
|
|
stringList.append(feature.toString());
|
|
|
|
|
return stringList;
|
|
|
|
|
}
|
2014-07-30 16:37:41 +02:00
|
|
|
|
|
|
|
|
static FeatureSet fromStringList(const QStringList &list)
|
|
|
|
|
{
|
|
|
|
|
FeatureSet features;
|
|
|
|
|
foreach (const QString &i, list)
|
2015-06-24 12:32:28 +02:00
|
|
|
features |= Feature::fromString(i);
|
2014-07-30 16:37:41 +02:00
|
|
|
return features;
|
|
|
|
|
}
|
2012-01-18 13:50:14 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Core
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
The following operators have to be defined in the global namespace!
|
|
|
|
|
Otherwise "using namespace Core" would hide other | operators
|
|
|
|
|
defined in the global namespace (e. g. QFlags).
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
inline Core::FeatureSet operator |(Core::Feature feature1, Core::Feature feature2)
|
|
|
|
|
{ return Core::FeatureSet(feature1) | feature2; }
|
|
|
|
|
|
|
|
|
|
inline Core::FeatureSet operator|(Core::Feature feature1, Core::FeatureSet feature2)
|
|
|
|
|
{ return feature2 | feature1; }
|
|
|
|
|
|
|
|
|
|
|
2013-03-12 12:07:32 +01:00
|
|
|
#endif // FEATUREPROVIDER_H
|