mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 04:25:35 +08:00
Ref T280, definitions for QHash<CCallsign, T> for
* situation * situation list * client * parts * parts list * functions to convert standard swift containers into QMap/QHash<CCallign, T>
This commit is contained in:
@@ -12,13 +12,14 @@
|
||||
#ifndef BLACKMISC_AVIATION_AIRCRAFTPARTSLIST_H
|
||||
#define BLACKMISC_AVIATION_AIRCRAFTPARTSLIST_H
|
||||
|
||||
#include "blackmisc/aviation/callsign.h"
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/collection.h"
|
||||
#include "blackmisc/sequence.h"
|
||||
#include "blackmisc/aviation/aircraftparts.h"
|
||||
#include "blackmisc/timestampobjectlist.h"
|
||||
#include "blackmisc/variant.h"
|
||||
|
||||
#include <QHash>
|
||||
#include <QMetaType>
|
||||
|
||||
namespace BlackMisc
|
||||
@@ -46,11 +47,20 @@ namespace BlackMisc
|
||||
//! Set on ground for all entries
|
||||
int setOnGround(bool onGround);
|
||||
};
|
||||
|
||||
//! Parts per callsign
|
||||
using CAircraftPartsPerCallsign = QHash<CCallsign, CAircraftParts>;
|
||||
|
||||
//! Parts (list) per callsign
|
||||
using CAircraftPartsListPerCallsign = QHash<CCallsign, CAircraftPartsList>;
|
||||
|
||||
} //namespace
|
||||
} // namespace
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Aviation::CAircraftPartsList)
|
||||
Q_DECLARE_METATYPE(BlackMisc::CCollection<BlackMisc::Aviation::CAircraftParts>)
|
||||
Q_DECLARE_METATYPE(BlackMisc::CSequence<BlackMisc::Aviation::CAircraftParts>)
|
||||
Q_DECLARE_METATYPE(BlackMisc::Aviation::CAircraftPartsPerCallsign)
|
||||
Q_DECLARE_METATYPE(BlackMisc::Aviation::CAircraftPartsListPerCallsign)
|
||||
|
||||
#endif //guard
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <QMetaType>
|
||||
#include <QList>
|
||||
#include <QPair>
|
||||
#include <QHash>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
@@ -34,7 +35,7 @@ namespace BlackMisc
|
||||
{
|
||||
class CAircraftParts;
|
||||
|
||||
//! Value object encapsulating a list of aircraft situations
|
||||
//! List of aircraft situations
|
||||
class BLACKMISC_EXPORT CAircraftSituationList :
|
||||
public CSequence<CAircraftSituation>,
|
||||
public Geo::IGeoObjectList<CAircraftSituation, CAircraftSituationList>,
|
||||
@@ -181,11 +182,20 @@ namespace BlackMisc
|
||||
//! \note distance is without CG, so on ground it can also be used to calculate
|
||||
QPair<CAltitude, CAltitude> altitudeAglStandardDeviationAndMean() const;
|
||||
};
|
||||
|
||||
//! Situation per callsign
|
||||
using CAircraftSituationPerCallsign = QHash<CCallsign, CAircraftSituation>;
|
||||
|
||||
//! Situations (list) per callsign
|
||||
using CAircraftSituationListPerCallsign = QHash<CCallsign, CAircraftSituationList>;
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Aviation::CAircraftSituationList)
|
||||
Q_DECLARE_METATYPE(BlackMisc::CCollection<BlackMisc::Aviation::CAircraftSituation>)
|
||||
Q_DECLARE_METATYPE(BlackMisc::CSequence<BlackMisc::Aviation::CAircraftSituation>)
|
||||
Q_DECLARE_METATYPE(BlackMisc::Aviation::CAircraftSituationPerCallsign)
|
||||
Q_DECLARE_METATYPE(BlackMisc::Aviation::CAircraftSituationListPerCallsign)
|
||||
|
||||
#endif // guard
|
||||
|
||||
@@ -215,6 +215,28 @@ namespace BlackMisc
|
||||
container().sortBy(&OBJ::getCallsign);
|
||||
}
|
||||
|
||||
template<class OBJ, class CONTAINER>
|
||||
QMap<CCallsign, OBJ> ICallsignObjectList<OBJ, CONTAINER>::asCallsignMap() const
|
||||
{
|
||||
QMap<CCallsign, OBJ> map;
|
||||
for (const OBJ &obj : this->container())
|
||||
{
|
||||
map.insert(obj.getCallsign(), obj);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
template<class OBJ, class CONTAINER>
|
||||
QHash<CCallsign, OBJ> ICallsignObjectList<OBJ, CONTAINER>::asCallsignHash() const
|
||||
{
|
||||
QHash<CCallsign, OBJ> hash;
|
||||
for (const OBJ &obj : this->container())
|
||||
{
|
||||
hash.insert(obj.getCallsign(), obj);
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
template<class OBJ, class CONTAINER>
|
||||
CONTAINER ICallsignObjectList<OBJ, CONTAINER>::sortedByCallsign() const
|
||||
{
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "blackmisc/propertyindexvariantmap.h"
|
||||
|
||||
#include <QHash>
|
||||
#include <QMap>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
@@ -78,7 +79,7 @@ namespace BlackMisc
|
||||
CONTAINER findBySuffix(const QString &suffix) const;
|
||||
|
||||
//! First found index of callsign, otherwise -1
|
||||
int firstIndexOfCallsign(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
int firstIndexOfCallsign(const CCallsign &callsign);
|
||||
|
||||
//! Remove all objects with callsign
|
||||
int removeByCallsign(const CCallsign &callsign);
|
||||
@@ -90,7 +91,7 @@ namespace BlackMisc
|
||||
QMap<QString, int> getSuffixes() const;
|
||||
|
||||
//! Split into 0..n containers as per callsign
|
||||
QHash<BlackMisc::Aviation::CCallsign, CONTAINER> splitPerCallsign() const;
|
||||
QHash<CCallsign, CONTAINER> splitPerCallsign() const;
|
||||
|
||||
//! Replace or add objects by callsign
|
||||
int replaceOrAddObjectByCallsign(const OBJ &otherObject);
|
||||
@@ -104,6 +105,12 @@ namespace BlackMisc
|
||||
//! Sort by callsign
|
||||
void sortByCallsign();
|
||||
|
||||
//! Turn into callsign map
|
||||
QMap<CCallsign, OBJ> asCallsignMap() const;
|
||||
|
||||
//! Turn into callsign hash
|
||||
QHash<CCallsign, OBJ> asCallsignHash() const;
|
||||
|
||||
//! Copy of list sorted by callsign
|
||||
CONTAINER sortedByCallsign() const;
|
||||
|
||||
|
||||
40
src/blackmisc/aviation/percallsign.h
Normal file
40
src/blackmisc/aviation/percallsign.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/* 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 BLACKMISC_AVIATION_PERCALLSIGN_H
|
||||
#define BLACKMISC_AVIATION_PERCALLSIGN_H
|
||||
|
||||
#include "blackmisc/aviation/callsign.h"
|
||||
#include "blackmisc/pq/length.h"
|
||||
#include "blackmisc/statusmessagelist.h"
|
||||
|
||||
#include <QHash>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Aviation
|
||||
{
|
||||
//! Status message per callsign
|
||||
using CStatusMessagePerCallsign = QHash<CCallsign, CStatusMessage>;
|
||||
|
||||
//! Status messages (list) per callsign
|
||||
using CStatusMessageListPerCallsign = QHash<CCallsign, CStatusMessageList>;
|
||||
|
||||
//! Timestamp der callsign
|
||||
using CTimestampPerCallsign = QHash<CCallsign, qint64>;
|
||||
|
||||
//! Lenght per callsign
|
||||
using CLengthPerCallsign = QHash<CCallsign, PhysicalQuantities::CLength>;
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
#endif // guard
|
||||
@@ -30,15 +30,5 @@ namespace BlackMisc
|
||||
if (this->isEmpty()) { return static_cast<CClient::Capabilities>(CClient::None); }
|
||||
return this->findFirstByCallsign(callsign).getCapabilities();
|
||||
}
|
||||
|
||||
QMap<CCallsign, CClient> CClientList::asMap() const
|
||||
{
|
||||
QMap<CCallsign, CClient> map;
|
||||
for (const CClient &client : *this)
|
||||
{
|
||||
map.insert(client.getCallsign(), client);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -13,11 +13,11 @@
|
||||
#define BLACKMISC_NETWORK_CLIENTLIST_H
|
||||
|
||||
#include "blackmisc/aviation/callsignobjectlist.h"
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/collection.h"
|
||||
#include "blackmisc/network/client.h"
|
||||
#include "blackmisc/sequence.h"
|
||||
#include "blackmisc/variant.h"
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include <QMap>
|
||||
#include <QMetaType>
|
||||
|
||||
@@ -45,15 +45,16 @@ namespace BlackMisc
|
||||
|
||||
//! Capabilities of client for callsign
|
||||
CClient::Capabilities getCapabilities(const Aviation::CCallsign &callsign) const;
|
||||
|
||||
//! As map
|
||||
QMap<Aviation::CCallsign, CClient> asMap() const;
|
||||
};
|
||||
|
||||
//! Client per callsign
|
||||
using CClientPerCallsign = QHash<Aviation::CCallsign, CClient>;
|
||||
} //namespace
|
||||
} // namespace
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Network::CClientList)
|
||||
Q_DECLARE_METATYPE(BlackMisc::CCollection<BlackMisc::Network::CClient>)
|
||||
Q_DECLARE_METATYPE(BlackMisc::CSequence<BlackMisc::Network::CClient>)
|
||||
Q_DECLARE_METATYPE(BlackMisc::Network::CClientPerCallsign)
|
||||
|
||||
#endif //guard
|
||||
|
||||
Reference in New Issue
Block a user