swift
visualpilotdatatoggle.cpp
1 // SPDX-FileCopyrightText: Copyright (C) 2022 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
5 
6 #include "pbh.h"
7 #include "serializer.h"
8 
9 #include "misc/logmessage.h"
10 
11 using namespace swift::misc;
12 using namespace swift::misc::aviation;
13 
14 namespace swift::core::fsd
15 {
16  VisualPilotDataToggle::VisualPilotDataToggle(const QString &sender, const QString &client, bool active)
17  : MessageBase(sender, {}), m_client(client), m_active(active)
18  {}
19 
21  {
22  QStringList tokens;
23  tokens.push_back(m_sender);
24  tokens.push_back(m_client);
25  tokens.push_back(QString::number(m_active ? 1 : 0));
26  return tokens;
27  }
28 
30  {
31  if (tokens.size() < 3)
32  {
33  CLogMessage(static_cast<VisualPilotDataToggle *>(nullptr)).debug(u"Wrong number of arguments.");
34  return {};
35  }
36 
37  return { tokens[0], tokens[1], tokens[2] == QStringLiteral("1") };
38  }
39 } // namespace swift::core::fsd
FSD message base class.
Definition: messagebase.h:58
QString m_sender
message sender
Definition: messagebase.h:88
Message from server to start or stop sending visual pilot data updates.
static VisualPilotDataToggle fromTokens(const QStringList &tokens)
Construct from tokens.
QStringList toTokens() const
Message converted to tokens.
Class for emitting a log message.
Definition: logmessage.h:27
Derived & debug()
Set the severity to debug.
Free functions in swift::misc.
void push_back(QList< T >::parameter_type value)
qsizetype size() const const
QString number(double n, char format, int precision)