swift
Loading...
Searching...
No Matches
dbusmessage.h
1// SPDX-FileCopyrightText: Copyright (C) 2018 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
4#ifndef SWIFT_SIM_XSWIFTBUS_DBUSMESSAGE_H
5#define SWIFT_SIM_XSWIFTBUS_DBUSMESSAGE_H
6
7#include <string>
8#include <string_view>
9#include <vector>
10
11#include "dbus/dbus.h"
12
13namespace XSwiftBus
14{
17 {
18 public:
21 CDBusMessage(DBusMessage *message);
22 CDBusMessage(const CDBusMessage &other);
24
27
30
32 bool isMethodCall() const;
33
35 bool wantsReply() const;
36
38 std::string getSender() const;
39
41 dbus_uint32_t getSerial() const;
42
44 std::string_view getInterfaceName() const;
45
47 std::string_view getObjectPath() const;
48
50 std::string_view getMethodName() const;
51
53 void beginArgumentWrite();
54
57 void appendArgument(bool value);
58 void appendArgument(const char *value);
59 void appendArgument(const std::string &value);
60 void appendArgument(int value);
61 void appendArgument(double value);
62 void appendArgument(const std::vector<bool> &array);
63 void appendArgument(const std::vector<double> &array);
64 void appendArgument(const std::vector<std::string> &array);
66
68 void beginArgumentRead();
69
72 void getArgument(int &value);
73 void getArgument(bool &value);
74 void getArgument(double &value);
75 void getArgument(std::string &value);
76 void getArgument(std::vector<int> &value);
77 void getArgument(std::vector<bool> &value);
78 void getArgument(std::vector<double> &value);
79 void getArgument(std::vector<std::string> &value);
81
83 static CDBusMessage createSignal(const std::string &path, const std::string &interfaceName,
84 const std::string &signalName);
85
87 static CDBusMessage createReply(const std::string &destination, dbus_uint32_t serial);
88
89 private:
90 friend class CDBusConnection;
91
92 DBusMessage *m_message = nullptr;
93 DBusMessageIter m_messageIterator;
94 CDBusMessage(DBusMessage *message, dbus_uint32_t serial);
95 dbus_uint32_t m_serial = 0;
96 };
97
98} // namespace XSwiftBus
99
100#endif // SWIFT_SIM_XSWIFTBUS_DBUSMESSAGE_H
CDBusMessage & operator=(CDBusMessage other)
Assignment operator.
bool wantsReply() const
Does this message want a reply?
bool isMethodCall() const
Is this message a method call?
void appendArgument(bool value)
Append argument. Make sure to call.
void getArgument(int &value)
Read single argument. Make sure to call.
std::string getSender() const
Get the message sender.
std::string_view getObjectPath() const
Get the called object path.
std::string_view getMethodName() const
Get the called method name.
dbus_uint32_t getSerial() const
Get the message serial. This is usally required for reply message.
std::string_view getInterfaceName() const
Get the called interface name.
CDBusMessage(DBusMessage *message)
Constructor.
void beginArgumentRead()
Begin reading arguments.
void beginArgumentWrite()
Begin writing argument.
static CDBusMessage createReply(const std::string &destination, dbus_uint32_t serial)
Creates a DBus message containing a DBus reply.
static CDBusMessage createSignal(const std::string &path, const std::string &interfaceName, const std::string &signalName)
Creates a DBus message containing a DBus signal.
Plugin loaded by X-Plane which publishes a DBus service.
Definition command.h:14