mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-15 09:15:34 +08:00
Ref T246, distributor filter
Needed because we want to create a 1st model set by distributors per simulator
This commit is contained in:
38
src/blackgui/models/distributorfilter.cpp
Normal file
38
src/blackgui/models/distributorfilter.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
/* Copyright (C) 2018
|
||||
* 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 "blackgui/models/distributorfilter.h"
|
||||
#include "blackmisc/simulation/distributor.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Simulation;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Models
|
||||
{
|
||||
CDistributorFilter::CDistributorFilter(const Simulation::CSimulatorInfo &simulator) :
|
||||
m_simulator(simulator)
|
||||
{
|
||||
this->m_valid = true;
|
||||
}
|
||||
|
||||
CDistributorList CDistributorFilter::filter(const CDistributorList &inDistributors) const
|
||||
{
|
||||
if (!this->isValid()) { return inDistributors; }
|
||||
CDistributorList outContainer;
|
||||
for (const CDistributor &distributor : inDistributors)
|
||||
{
|
||||
if (!distributor.getSimulator().matchesAny(m_simulator)) { continue; }
|
||||
outContainer.push_back(distributor);
|
||||
}
|
||||
return outContainer;
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
42
src/blackgui/models/distributorfilter.h
Normal file
42
src/blackgui/models/distributorfilter.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/* Copyright (C) 2018
|
||||
* 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 BLACKGUI_DISTRIBUTORFILTER_H
|
||||
#define BLACKGUI_DISTRIBUTORFILTER_H
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackgui/models/modelfilter.h"
|
||||
#include "blackmisc/simulation/simulatorinfo.h"
|
||||
#include "blackmisc/simulation/distributorlist.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Models
|
||||
{
|
||||
//! Country filter
|
||||
class BLACKGUI_EXPORT CDistributorFilter : public IModelFilter<BlackMisc::Simulation::CDistributorList>
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
CDistributorFilter(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
|
||||
//! \copydoc IModelFilter::filter
|
||||
virtual BlackMisc::Simulation::CDistributorList filter(const BlackMisc::Simulation::CDistributorList &inDistributors) const override;
|
||||
|
||||
private:
|
||||
BlackMisc::Simulation::CSimulatorInfo m_simulator;
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
#endif // guard
|
||||
Reference in New Issue
Block a user