geopm 3.1.1.dev456+g3ba31824
GEOPM - Global Extensible Open Power Manager
Loading...
Searching...
No Matches
SDBus.hpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015 - 2024 Intel Corporation
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#ifndef SDBUS_HPP_INCLUDE
7#define SDBUS_HPP_INCLUDE
8
9#include <memory>
10#include <string>
11#include <vector>
12#include <cstdint>
13
14struct sd_bus;
15
16namespace geopm
17{
18 class SDBusMessage;
19
30 class SDBus
31 {
32 public:
33 SDBus() = default;
34 virtual ~SDBus() = default;
39 static std::unique_ptr<SDBus> make_unique(void);
57 virtual std::shared_ptr<SDBusMessage> call_method(
58 std::shared_ptr<SDBusMessage> message) = 0;
67 virtual std::shared_ptr<SDBusMessage> call_method(
68 const std::string &member) = 0;
83 virtual std::shared_ptr<SDBusMessage> call_method(
84 const std::string &member,
85 const std::string &arg0,
86 int arg1,
87 int arg2) = 0;
104 virtual std::shared_ptr<SDBusMessage> call_method(
105 const std::string &member,
106 const std::string &arg0,
107 int arg1,
108 int arg2,
109 double arg3) = 0;
120 virtual std::shared_ptr<SDBusMessage> call_method(
121 const std::string &member,
122 int arg0) = 0;
137 virtual std::shared_ptr<SDBusMessage> make_call_message(
138 const std::string &member) = 0;
139
140 virtual std::shared_ptr<SDBusMessage> call_method(
141 const std::string &member,
142 const std::string &arg0) = 0;
143
144 };
145
146 class SDBusImp : public SDBus
147 {
148 public:
149 SDBusImp();
150 SDBusImp(const SDBusImp &other) = delete;
151 SDBusImp &operator=(const SDBusImp &other) = delete;
152 virtual ~SDBusImp();
153 std::shared_ptr<SDBusMessage> call_method(
154 std::shared_ptr<SDBusMessage> message) override;
155 std::shared_ptr<SDBusMessage> call_method(
156 const std::string &member) override;
157 std::shared_ptr<SDBusMessage> call_method(
158 const std::string &member,
159 const std::string &arg0,
160 int arg1,
161 int arg2) override;
162 std::shared_ptr<SDBusMessage> call_method(
163 const std::string &member,
164 const std::string &arg0,
165 int arg1,
166 int arg2,
167 double arg3) override;
168 std::shared_ptr<SDBusMessage> call_method(
169 const std::string &member,
170 int arg0) override;
171 std::shared_ptr<SDBusMessage> make_call_message(
172 const std::string &member) override;
173 std::shared_ptr<SDBusMessage> call_method(
174 const std::string &member,
175 const std::string &arg0) override;
176 private:
177 sd_bus *m_bus;
178 const char *m_dbus_destination;
179 const char *m_dbus_path;
180 const char *m_dbus_interface;
181 const uint64_t m_dbus_timeout_usec;
182 };
183}
184
185#endif
Abstraction around sd_bus interface for calling methods.
Definition SDBus.hpp:31
virtual std::shared_ptr< SDBusMessage > call_method(std::shared_ptr< SDBusMessage > message)=0
Wrapper for the sd_bus_call(3) function.
virtual std::shared_ptr< SDBusMessage > call_method(const std::string &member)=0
Wrapper for the sd_bus_call_method(3) function.
SDBus()=default
static std::unique_ptr< SDBus > make_unique(void)
Factory method for SDBus interface.
Definition SDBus.cpp:41
virtual ~SDBus()=default
virtual std::shared_ptr< SDBusMessage > make_call_message(const std::string &member)=0
Wrapper for the sd_bus_message_new_method_call(3) function.
virtual std::shared_ptr< SDBusMessage > call_method(const std::string &member, const std::string &arg0)=0
virtual std::shared_ptr< SDBusMessage > call_method(const std::string &member, const std::string &arg0, int arg1, int arg2, double arg3)=0
Wrapper for the sd_bus_call_method(3) function.
virtual std::shared_ptr< SDBusMessage > call_method(const std::string &member, int arg0)=0
Wrapper for the sd_bus_call_method(3) function.
virtual std::shared_ptr< SDBusMessage > call_method(const std::string &member, const std::string &arg0, int arg1, int arg2)=0
Wrapper for the sd_bus_call_method(3) function.
Definition SDBus.hpp:147
SDBusImp(const SDBusImp &other)=delete
std::shared_ptr< SDBusMessage > call_method(std::shared_ptr< SDBusMessage > message) override
Wrapper for the sd_bus_call(3) function.
Definition SDBus.cpp:66
std::shared_ptr< SDBusMessage > make_call_message(const std::string &member) override
Wrapper for the sd_bus_message_new_method_call(3) function.
Definition SDBus.cpp:184
SDBusImp & operator=(const SDBusImp &other)=delete
virtual ~SDBusImp()
Definition SDBus.cpp:59
SDBusImp()
Definition SDBus.cpp:46
Definition Agg.cpp:20