mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-02 07:05:38 +08:00
refs #622, model set builder. Take own models and generate the set of models used in model matching. Normally configured via GUI.
This commit is contained in:
52
src/blackcore/modelsetbuilder.cpp
Normal file
52
src/blackcore/modelsetbuilder.cpp
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
/* Copyright (C) 2016
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "modelsetbuilder.h"
|
||||||
|
#include "application.h"
|
||||||
|
|
||||||
|
using namespace BlackMisc::Simulation;
|
||||||
|
|
||||||
|
namespace BlackCore
|
||||||
|
{
|
||||||
|
CModelSetBuilder::CModelSetBuilder(QObject *parent) : QObject(parent)
|
||||||
|
{
|
||||||
|
// void
|
||||||
|
}
|
||||||
|
|
||||||
|
CAircraftModelList CModelSetBuilder::buildModelSet(const CAircraftModelList &models, Builder oprions, const CDistributorList &onlyByDistributors) const
|
||||||
|
{
|
||||||
|
if (models.isEmpty()) { return CAircraftModelList(); }
|
||||||
|
CAircraftModelList modelSet;
|
||||||
|
if (oprions.testFlag(FilterDistributos))
|
||||||
|
{
|
||||||
|
modelSet = models.byDistributor(onlyByDistributors);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
modelSet = models;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (oprions.testFlag(OnlyDbData))
|
||||||
|
{
|
||||||
|
modelSet.removeObjectsWithoutDbKey();
|
||||||
|
}
|
||||||
|
else if (oprions.testFlag(OnlyDbIcaoCodes))
|
||||||
|
{
|
||||||
|
Q_ASSERT_X(sApp->hasWebDataServices(), Q_FUNC_INFO, "No web data services");
|
||||||
|
const QStringList designators(sApp->getWebDataServices()->getAircraftIcaoCodes().allIcaoCodes());
|
||||||
|
modelSet = modelSet.withAircraftDesignator(designators);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// without any information we can not use them
|
||||||
|
modelSet = modelSet.withKnownAircraftDesignator();
|
||||||
|
}
|
||||||
|
return modelSet;
|
||||||
|
}
|
||||||
|
}
|
||||||
55
src/blackcore/modelsetbuilder.h
Normal file
55
src/blackcore/modelsetbuilder.h
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
/* Copyright (C) 2016
|
||||||
|
* 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 BLACKCORE_CMODELSETBUILDER_H
|
||||||
|
#define BLACKCORE_CMODELSETBUILDER_H
|
||||||
|
|
||||||
|
#include "blackmisc/simulation/aircraftmodellist.h"
|
||||||
|
#include "blackmisc/simulation/distributorlist.h"
|
||||||
|
#include "blackcore/blackcoreexport.h"
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
|
||||||
|
namespace BlackCore
|
||||||
|
{
|
||||||
|
/*!
|
||||||
|
* Create model set (normally from own models)
|
||||||
|
*/
|
||||||
|
class BLACKCORE_EXPORT CModelSetBuilder : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
//! Builder flags
|
||||||
|
enum BuilderFlag
|
||||||
|
{
|
||||||
|
NoOptions = 0,
|
||||||
|
FilterDistributos = 1 << 0,
|
||||||
|
OnlyDbData = 1 << 1,
|
||||||
|
OnlyDbIcaoCodes = 1 << 2
|
||||||
|
};
|
||||||
|
Q_DECLARE_FLAGS(Builder, BuilderFlag)
|
||||||
|
|
||||||
|
//! Constructor
|
||||||
|
CModelSetBuilder(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
//! Build a model set
|
||||||
|
BlackMisc::Simulation::CAircraftModelList buildModelSet(
|
||||||
|
const BlackMisc::Simulation::CAircraftModelList &models, Builder oprions,
|
||||||
|
const BlackMisc::Simulation::CDistributorList &onlyByDistributors = BlackMisc::Simulation::CDistributorList()) const;
|
||||||
|
};
|
||||||
|
} // ns
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(BlackCore::CModelSetBuilder::BuilderFlag)
|
||||||
|
Q_DECLARE_METATYPE(BlackCore::CModelSetBuilder::Builder)
|
||||||
|
Q_DECLARE_OPERATORS_FOR_FLAGS(BlackCore::CModelSetBuilder::Builder)
|
||||||
|
|
||||||
|
#endif // guard
|
||||||
Reference in New Issue
Block a user