mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-04 00:45:46 +08:00
Ref T472, initial version of category matcher
This commit is contained in:
committed by
Mat Sutcliffe
parent
5846860382
commit
503bbf3a26
@@ -41,7 +41,14 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
|
|
||||||
CAircraftMatcher::CAircraftMatcher(const CAircraftMatcherSetup &setup, QObject *parent) : QObject(parent), m_setup(setup)
|
CAircraftMatcher::CAircraftMatcher(const CAircraftMatcherSetup &setup, QObject *parent) : QObject(parent), m_setup(setup)
|
||||||
{ }
|
{
|
||||||
|
if (sApp && !sApp->isShuttingDown())
|
||||||
|
{
|
||||||
|
sApp->getWebDataServices()->synchronizeDbCaches(CEntityFlags::AircraftCategoryEntity);
|
||||||
|
const CAircraftCategoryList categories = sApp->getWebDataServices()->getAircraftCategories();
|
||||||
|
m_categoryMatcher.setCategories(categories);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CAircraftMatcher::CAircraftMatcher(QObject *parent) : CAircraftMatcher(CAircraftMatcherSetup(), parent)
|
CAircraftMatcher::CAircraftMatcher(QObject *parent) : CAircraftMatcher(CAircraftMatcherSetup(), parent)
|
||||||
{ }
|
{ }
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
#include "blackmisc/simulation/aircraftmatchersetup.h"
|
#include "blackmisc/simulation/aircraftmatchersetup.h"
|
||||||
#include "blackmisc/simulation/aircraftmodellist.h"
|
#include "blackmisc/simulation/aircraftmodellist.h"
|
||||||
#include "blackmisc/simulation/matchingstatistics.h"
|
#include "blackmisc/simulation/matchingstatistics.h"
|
||||||
|
#include "blackmisc/simulation/categorymatcher.h"
|
||||||
#include "blackmisc/statusmessage.h"
|
#include "blackmisc/statusmessage.h"
|
||||||
#include "blackmisc/valueobject.h"
|
#include "blackmisc/valueobject.h"
|
||||||
#include "blackmisc/variant.h"
|
#include "blackmisc/variant.h"
|
||||||
@@ -309,6 +310,7 @@ namespace BlackCore
|
|||||||
BlackMisc::Simulation::CAircraftModelList m_disabledModels; //!< disabled models for matching
|
BlackMisc::Simulation::CAircraftModelList m_disabledModels; //!< disabled models for matching
|
||||||
BlackMisc::Simulation::CSimulatorInfo m_simulator; //!< simulator (optional)
|
BlackMisc::Simulation::CSimulatorInfo m_simulator; //!< simulator (optional)
|
||||||
BlackMisc::Simulation::CMatchingStatistics m_statistics; //!< matching statistics
|
BlackMisc::Simulation::CMatchingStatistics m_statistics; //!< matching statistics
|
||||||
|
BlackMisc::Simulation::CCategoryMatcher m_categoryMatcher; //!< the category matcher
|
||||||
QString m_modelSetInfo; //!< info string
|
QString m_modelSetInfo; //!< info string
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
50
src/blackmisc/simulation/categorymatcher.cpp
Normal file
50
src/blackmisc/simulation/categorymatcher.cpp
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
/* Copyright (C) 2019
|
||||||
|
* 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. 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 "categorymatcher.h"
|
||||||
|
#include <QStringBuilder>
|
||||||
|
|
||||||
|
using namespace BlackMisc::Aviation;
|
||||||
|
|
||||||
|
namespace BlackMisc
|
||||||
|
{
|
||||||
|
namespace Simulation
|
||||||
|
{
|
||||||
|
void CCategoryMatcher::setCategories(const CAircraftCategoryList &categories)
|
||||||
|
{
|
||||||
|
m_all = categories;
|
||||||
|
|
||||||
|
CAircraftCategoryList gliders = categories.findByName("glider").findFirstLevels();
|
||||||
|
if (!gliders.isEmpty())
|
||||||
|
{
|
||||||
|
const int fl = gliders.front().getFirstLevel();
|
||||||
|
gliders = categories.findByFirstLevel(fl);
|
||||||
|
gliders.sortByLevel();
|
||||||
|
m_gliders = gliders;
|
||||||
|
}
|
||||||
|
|
||||||
|
CAircraftCategoryList militaryWing = categories.findByName("wing military").findFirstLevels();
|
||||||
|
if (!militaryWing.isEmpty())
|
||||||
|
{
|
||||||
|
const int fl = militaryWing.front().getFirstLevel();
|
||||||
|
militaryWing = categories.findByFirstLevel(fl);
|
||||||
|
militaryWing.sortByLevel();
|
||||||
|
m_militaryWingAircraft = militaryWing;
|
||||||
|
}
|
||||||
|
|
||||||
|
CAircraftCategoryList militaryRotor = categories.findByName("rotor military").findFirstLevels();
|
||||||
|
if (!militaryRotor.isEmpty())
|
||||||
|
{
|
||||||
|
const int fl = militaryRotor.front().getFirstLevel();
|
||||||
|
militaryRotor = categories.findByFirstLevel(fl);
|
||||||
|
militaryRotor.sortByLevel();
|
||||||
|
m_militaryRotorAircraft = militaryRotor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
} // namespace
|
||||||
46
src/blackmisc/simulation/categorymatcher.h
Normal file
46
src/blackmisc/simulation/categorymatcher.h
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
/* Copyright (C) 2019
|
||||||
|
* 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. 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_SIMULATION_CATEGORYMATCHER_H
|
||||||
|
#define BLACKMISC_SIMULATION_CATEGORYMATCHER_H
|
||||||
|
|
||||||
|
#include "blackmisc/aviation/aircraftcategorylist.h"
|
||||||
|
#include "blackmisc/blackmiscexport.h"
|
||||||
|
|
||||||
|
namespace BlackMisc
|
||||||
|
{
|
||||||
|
namespace Simulation
|
||||||
|
{
|
||||||
|
//! Category matcher, uses the DB categories
|
||||||
|
class BLACKMISC_EXPORT CCategoryMatcher
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//! Constructor
|
||||||
|
CCategoryMatcher() {}
|
||||||
|
|
||||||
|
//! Used categories
|
||||||
|
void setCategories(const Aviation::CAircraftCategoryList &categories);
|
||||||
|
|
||||||
|
//! Specialized categories @{
|
||||||
|
const Aviation::CAircraftCategoryList &gliderCategories() const { return m_gliders; }
|
||||||
|
const Aviation::CAircraftCategoryList &militaryWingCategories() const { return m_militaryWingAircraft; }
|
||||||
|
const Aviation::CAircraftCategoryList &militaryRotorCategories() const { return m_militaryRotorAircraft; }
|
||||||
|
//! @}
|
||||||
|
|
||||||
|
private:
|
||||||
|
Aviation::CAircraftCategoryList m_all;
|
||||||
|
Aviation::CAircraftCategoryList m_gliders;
|
||||||
|
Aviation::CAircraftCategoryList m_militaryWingAircraft;
|
||||||
|
Aviation::CAircraftCategoryList m_militaryRotorAircraft;
|
||||||
|
};
|
||||||
|
} // ns
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
#endif // guard
|
||||||
Reference in New Issue
Block a user