From d1eac88d18ae7dd11033dba87b6aebb220da9064 Mon Sep 17 00:00:00 2001 From: Brad Bishop Date: Thu, 29 Mar 2018 10:34:05 -0400 Subject: Enable clang-format Fix up errors and enable clang-format during CI builds. Change-Id: I4176b81f8b85a287af9354165e09ff66aeb9fb29 Signed-off-by: Brad Bishop --- src/sdbusplus.hpp | 172 +++++++++++++++++++++++------------------------------- 1 file changed, 73 insertions(+), 99 deletions(-) (limited to 'src/sdbusplus.hpp') diff --git a/src/sdbusplus.hpp b/src/sdbusplus.hpp index 1a2c9c2..1b54582 100644 --- a/src/sdbusplus.hpp +++ b/src/sdbusplus.hpp @@ -19,116 +19,90 @@ namespace monitoring */ class SDBusPlus { - private: - static auto& getWatches() - { - static std::vector watches; - return watches; - } + private: + static auto& getWatches() + { + static std::vector watches; + return watches; + } - public: - static auto& getBus() - { - static auto bus = sdbusplus::bus::new_default(); - return bus; - } + public: + static auto& getBus() + { + static auto bus = sdbusplus::bus::new_default(); + return bus; + } - /** @brief Invoke a method; ignore reply. */ - template - static void callMethodNoReply( - const std::string& busName, - const std::string& path, - const std::string& interface, - const std::string& method, - Args&& ... args) - { - auto reqMsg = getBus().new_method_call( - busName.c_str(), - path.c_str(), - interface.c_str(), - method.c_str()); - reqMsg.append(std::forward(args)...); - getBus().call_noreply(reqMsg); + /** @brief Invoke a method; ignore reply. */ + template + static void callMethodNoReply(const std::string& busName, + const std::string& path, + const std::string& interface, + const std::string& method, Args&&... args) + { + auto reqMsg = getBus().new_method_call( + busName.c_str(), path.c_str(), interface.c_str(), method.c_str()); + reqMsg.append(std::forward(args)...); + getBus().call_noreply(reqMsg); - // TODO: openbmc/openbmc#1719 - // invoke these methods async, with a callback - // handler that checks for errors and logs. - } + // TODO: openbmc/openbmc#1719 + // invoke these methods async, with a callback + // handler that checks for errors and logs. + } - /** @brief Invoke a method. */ - template - static auto callMethod( - const std::string& busName, - const std::string& path, - const std::string& interface, - const std::string& method, - Args&& ... args) - { - auto reqMsg = getBus().new_method_call( - busName.c_str(), - path.c_str(), - interface.c_str(), - method.c_str()); - reqMsg.append(std::forward(args)...); - return getBus().call(reqMsg); - } + /** @brief Invoke a method. */ + template + static auto callMethod(const std::string& busName, const std::string& path, + const std::string& interface, + const std::string& method, Args&&... args) + { + auto reqMsg = getBus().new_method_call( + busName.c_str(), path.c_str(), interface.c_str(), method.c_str()); + reqMsg.append(std::forward(args)...); + return getBus().call(reqMsg); + } - /** @brief Invoke a method and read the response. */ - template - static auto callMethodAndRead( - const std::string& busName, - const std::string& path, - const std::string& interface, - const std::string& method, - Args&& ... args) - { - Ret resp; - sdbusplus::message::message respMsg = - callMethod( - busName, - path, - interface, - method, - std::forward(args)...); - respMsg.read(resp); - return resp; - } + /** @brief Invoke a method and read the response. */ + template + static auto callMethodAndRead(const std::string& busName, + const std::string& path, + const std::string& interface, + const std::string& method, Args&&... args) + { + Ret resp; + sdbusplus::message::message respMsg = callMethod( + busName, path, interface, method, std::forward(args)...); + respMsg.read(resp); + return resp; + } - /** @brief Register a DBus signal callback. */ - static auto addMatch( - const std::string& match, - const sdbusplus::bus::match::match::callback_t& callback) - { - getWatches().emplace_back( - getBus(), - match, - callback); - } + /** @brief Register a DBus signal callback. */ + static auto + addMatch(const std::string& match, + const sdbusplus::bus::match::match::callback_t& callback) + { + getWatches().emplace_back(getBus(), match, callback); + } - /** @brief Look up the bus name for a path and interface */ - static auto getBusName( - const std::string& path, - const std::string& interface) - { - std::vector interfaces{interface}; + /** @brief Look up the bus name for a path and interface */ + static auto getBusName(const std::string& path, + const std::string& interface) + { + std::vector interfaces{interface}; - auto object = callMethodAndRead( - MAPPER_BUSNAME, - MAPPER_PATH, - MAPPER_INTERFACE, - "GetObject", - path, - interfaces); + auto object = callMethodAndRead( + MAPPER_BUSNAME, MAPPER_PATH, MAPPER_INTERFACE, "GetObject", path, + interfaces); - std::string name; - if (!object.empty()) - { - name = object.begin()->first; - } - return name; + std::string name; + if (!object.empty()) + { + name = object.begin()->first; } + return name; + } - friend Loop; + friend Loop; }; } // namespace monitoring -- cgit v1.2.1