9 using namespace swift::misc::aviation;
11 namespace swift::misc::network
15 QList<CClient> clients;
17 QReadLocker l(&m_lockClient);
18 clients = m_clients.values();
26 QWriteLocker l(&m_lockClient);
27 m_clients = perCallsign;
30 void CClientProvider::clearClients()
32 QWriteLocker l(&m_lockClient);
38 if (callsigns.
isEmpty()) {
return {}; }
42 CClient CClientProvider::getClientOrDefaultForCallsign(
const CCallsign &callsign)
const
44 if (callsign.
isEmpty()) {
return {}; }
46 QReadLocker l(&m_lockClient);
47 if (m_clients.contains(callsign)) {
return m_clients.value(callsign); }
52 bool CClientProvider::setOtherClient(
const CClient &client)
55 SWIFT_VERIFY_X(hasCallsign, Q_FUNC_INFO,
"Need callsign in client");
56 if (!hasCallsign) {
return false; }
57 QWriteLocker l(&m_lockClient);
62 bool CClientProvider::hasClientInfo(
const CCallsign &callsign)
const
64 if (callsign.
isEmpty()) {
return false; }
65 QReadLocker l(&m_lockClient);
66 return m_clients.contains(callsign);
69 bool CClientProvider::addNewClient(
const CClient &client)
73 if (callsign.
isEmpty()) {
return false; }
74 if (this->hasClientInfo(callsign)) {
return false; }
75 QWriteLocker l(&m_lockClient);
76 m_clients[callsign] = client;
84 if (callsign.
isEmpty()) {
return 0; }
86 if (this->hasClientInfo(callsign))
88 QWriteLocker l(&m_lockClient);
89 CClient &client = m_clients[callsign];
90 c = client.
apply(vm, skipEqualValues).
size();
96 QWriteLocker l(&m_lockClient);
97 m_clients[callsign] = client;
102 int CClientProvider::removeClient(
const CCallsign &callsign)
104 QWriteLocker l(&m_lockClient);
105 return m_clients.remove(callsign);
111 if (!situation.
isOnGround()) {
return false; }
116 return this->addClientGndCapability(situation.
getCallsign());
119 bool CClientProvider::addClientGndCapability(
const CCallsign &callsign)
121 return this->setClientGndCapability(callsign,
true);
124 bool CClientProvider::setClientGndCapability(
const CCallsign &callsign,
bool supportGndFlag)
127 if (callsign.
isEmpty()) {
return 0; }
129 CClient client = this->getClientOrDefaultForCallsign(callsign);
132 if (!client.
isValid()) {
return false; }
134 if (supportGndFlag) { client.
addCapability(CClient::FsdWithGroundFlag); }
136 QWriteLocker l(&m_lockClient);
137 m_clients[callsign] = client;
141 void CClientProvider::markAsSwiftClient(
const CCallsign &callsign)
143 if (callsign.
isEmpty()) {
return; }
144 QWriteLocker l(&m_lockClient);
145 if (!m_clients.contains(callsign)) {
return; }
146 m_clients[callsign].setSwiftClient(
true);
150 void CClientAware::anchor() {}
154 if (this->provider()) {
return this->provider()->getClients(); }
160 if (this->provider()) {
return this->provider()->getClientOrDefaultForCallsign(callsign); }
164 bool CClientAware::hasClientInfo(
const CCallsign &callsign)
const
166 if (this->provider()) {
return this->provider()->hasClientInfo(callsign); }
170 bool CClientAware::addNewClient(
const CClient &client)
172 if (this->provider()) {
return this->provider()->addNewClient(client); }
177 bool skipEqualValues)
179 if (this->provider()) {
return this->provider()->updateOrAddClient(callsign, vm, skipEqualValues); }
183 int CClientAware::removeClient(
const CCallsign &callsign)
185 if (this->provider()) {
return this->provider()->removeClient(callsign); }
191 if (this->provider()) {
return this->provider()->autoAdjustCientGndCapability(situation); }
195 bool CClientAware::addClientGndCapability(
const CCallsign &callsign)
197 if (this->provider()) {
return this->provider()->addClientGndCapability(callsign); }
201 void CClientAware::markAsSwiftClient(
const CCallsign &callsign)
203 if (!this->provider()) {
return; }
204 this->provider()->markAsSwiftClient(callsign);
bool isEmpty() const
Synonym for empty.
Specialized value object compliant map for variants, based on indexes.
size_type size() const
Returns number of elements in the sequence.
Value object encapsulating information of an aircraft's situation.
aviation::COnGroundInfo getOnGroundInfo() const
On ground info.
bool isOnGround() const
Is on ground?
const CCallsign & getCallsign() const
Corresponding callsign.
Value object encapsulating information of a callsign.
bool isEmpty() const
Is empty?
Value object for a set of callsigns.
@ InFromNetwork
received from network
OnGroundDetails getGroundDetails() const
Get ground details.
CONTAINER findByCallsigns(const CCallsignSet &callsigns) const
Find 0..n aircraft matching any of a set of callsigns.
QHash< CCallsign, OBJ > asCallsignHash() const
Turn into callsign hash.
CPropertyIndexList apply(const CPropertyIndexVariantMap &indexMap, bool skipEqualValues=false)
Update by variant map.
void addCapability(Capability capability)
Add capability.
bool hasGndFlagCapability() const
Supports gnd.flag?
bool isValid() const
Is valid.
void removeCapability(Capability capability)
Remove capability.
const aviation::CCallsign & getCallsign() const
Callsign used with other client.
Value object encapsulating a list of voice rooms.
Client provider dummy for testing.
#define SWIFT_VERIFY_X(COND, WHERE, WHAT)
A weaker kind of assert.