FlightGear next
dbusmessage.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: (C) 2019-2022 swift Project Community / Contributors (https://swift-project.org/)
3 * SPDX-FileCopyrightText: (C) 2019-2022 Lars Toenning <dev@ltoenning.de>
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7#pragma once
8
9#include "dbus/dbus.h"
10#include <string>
11#include <vector>
12
13namespace flightgear::swift {
14
17{
18public:
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 getInterfaceName() const;
45
47 std::string getObjectPath() const;
48
50 std::string 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<double>& array);
63 void appendArgument(const std::vector<std::string>& array);
65
67 void beginArgumentRead();
68
71 void getArgument(int& value);
72 void getArgument(bool& value);
73 void getArgument(double& value);
74 void getArgument(std::string& value);
75 void getArgument(std::vector<int>& value);
76 void getArgument(std::vector<bool>& value);
77 void getArgument(std::vector<double>& value);
78 void getArgument(std::vector<std::string>& value);
80
82 static CDBusMessage createSignal(const std::string& path, const std::string& interfaceName, const std::string& signalName);
83
85 static CDBusMessage createReply(const std::string& destination, dbus_uint32_t serial);
86
87private:
88 friend class CDBusConnection;
89
90 DBusMessage* m_message = nullptr;
91 DBusMessageIter m_messageIterator;
92 CDBusMessage(DBusMessage* message, dbus_uint32_t serial);
93 dbus_uint32_t m_serial = 0;
94};
95
96} // namespace flightgear::swift
static CDBusMessage createSignal(const std::string &path, const std::string &interfaceName, const std::string &signalName)
Creates a DBus message containing a DBus signal.
void appendArgument(bool value)
Append argument.
bool isMethodCall() const
Is this message a method call?
static CDBusMessage createReply(const std::string &destination, dbus_uint32_t serial)
Creates a DBus message containing a DBus reply.
std::string getSender() const
Get the message sender.
std::string getObjectPath() const
Get the called object path.
dbus_uint32_t getSerial() const
Get the message serial. This is usally required for reply message.
std::string getMethodName() const
Get the called method name.
std::string getInterfaceName() const
Get the called interface name.
CDBusMessage(DBusMessage *message)
Constructor.
bool wantsReply() const
Does this message want a reply?
void getArgument(int &value)
Read single argument.
void beginArgumentRead()
Begin reading arguments.
void beginArgumentWrite()
Begin writing argument.
CDBusMessage & operator=(CDBusMessage other)
Assignment operator.