Debian Codegraph @

src/Network/Swift/dbusmessage.h

raw symbols SCIP
1 /*
2 * SPDX-FileCopyrightText: (C) 2019-2022 swift Project Community / Contributors (https://swift-project.org/)
3 * SPDX-FileCopyrightText: (C) 2019-2022 Lars Toenning <[email protected]>
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
13 namespace flightgear::swift {
14
15 //! DBus Message
16 class CDBusMessage
17 {
18 public:
19 //! Constructor
20 //! @{
21 CDBusMessage(DBusMessage* message);
22 CDBusMessage(const CDBusMessage& other);
23 //! @}
24
25 //! Destructor
26 ~CDBusMessage();
27
28 //! Assignment operator
29 CDBusMessage& operator=(CDBusMessage other);
30
31 //! Is this message a method call?
32 bool isMethodCall() const;
33
34 //! Does this message want a reply?
35 bool wantsReply() const;
36
37 //! Get the message sender
38 std::string getSender() const;
39
40 //! Get the message serial. This is usally required for reply message.
41 dbus_uint32_t getSerial() const;
42
43 //! Get the called interface name
44 std::string getInterfaceName() const;
45
46 //! Get the called object path
47 std::string getObjectPath() const;
48
49 //! Get the called method name
50 std::string getMethodName() const;
51
52 //! Begin writing argument
53 void beginArgumentWrite();
54
55 //! Append argument. Make sure to call \sa beginArgumentWrite() before.
56 //! @{
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);
64 //! @}
65
66 //! Begin reading arguments
67 void beginArgumentRead();
68
69 //! Read single argument. Make sure to call \sa beginArgumentRead() before.
70 //! @{
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);
79 //! @}
80
81 //! Creates a DBus message containing a DBus signal
82 static CDBusMessage createSignal(const std::string& path, const std::string& interfaceName, const std::string& signalName);
83
84 //! Creates a DBus message containing a DBus reply
85 static CDBusMessage createReply(const std::string& destination, dbus_uint32_t serial);
86
87 private:
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