dbus_environment.hpp (3a1c297a36bcd78d33ee45c603cb1b46e4619f49) dbus_environment.hpp (cff70c14ef8cadb7fffd0cd41e06b972fa240e56)
1#pragma once
2
3#include "types/duration_types.hpp"
4#include "utils/set_exception.hpp"
5
6#include <sdbusplus/asio/object_server.hpp>
7#include <sdbusplus/asio/property.hpp>
8

--- 117 unchanged lines hidden (view full) ---

126 interfaceName, property, std::move(newValue),
127 [promise = std::move(promise)](
128 boost::system::error_code ec) mutable {
129 promise.set_value(ec);
130 });
131 return DbusEnvironment::waitForFuture(std::move(future));
132 }
133
1#pragma once
2
3#include "types/duration_types.hpp"
4#include "utils/set_exception.hpp"
5
6#include <sdbusplus/asio/object_server.hpp>
7#include <sdbusplus/asio/property.hpp>
8

--- 117 unchanged lines hidden (view full) ---

126 interfaceName, property, std::move(newValue),
127 [promise = std::move(promise)](
128 boost::system::error_code ec) mutable {
129 promise.set_value(ec);
130 });
131 return DbusEnvironment::waitForFuture(std::move(future));
132 }
133
134 template <class... Args>
135 static boost::system::error_code
136 callMethod(const std::string& path, const std::string& interface,
137 const std::string& method, Args&&... args)
138 {
139 auto promise = std::promise<boost::system::error_code>();
140 auto future = promise.get_future();
141 DbusEnvironment::getBus()->async_method_call(
142 [promise = std::move(promise)](
143 boost::system::error_code ec) mutable {
144 promise.set_value(ec);
145 },
146 DbusEnvironment::serviceName(), path, interface, method,
147 std::forward<Args>(args)...);
148 return DbusEnvironment::waitForFuture(std::move(future));
149 }
150
134 private:
135 static std::future<bool> getFuture(std::string_view name);
136
137 static boost::asio::io_context ioc;
138 static std::shared_ptr<sdbusplus::asio::connection> bus;
139 static std::shared_ptr<sdbusplus::asio::object_server> objServer;
140 static std::map<std::string, std::vector<std::future<bool>>> futures;
141 static bool setUp;
142};
151 private:
152 static std::future<bool> getFuture(std::string_view name);
153
154 static boost::asio::io_context ioc;
155 static std::shared_ptr<sdbusplus::asio::connection> bus;
156 static std::shared_ptr<sdbusplus::asio::object_server> objServer;
157 static std::map<std::string, std::vector<std::future<bool>>> futures;
158 static bool setUp;
159};