From dace680fa404d7c02a68db105fd7b958b4681442 Mon Sep 17 00:00:00 2001 From: Patrick Venture Date: Thu, 1 Nov 2018 16:52:10 -0700 Subject: Add clang-format to repo Add clang-format to repo. Change-Id: I3f8704d80dd0bdde0706ab189c68cffe6d347995 Signed-off-by: Patrick Venture --- evdev.hpp | 137 +++++++++++++++++++++++++++++++------------------------------- 1 file changed, 68 insertions(+), 69 deletions(-) (limited to 'evdev.hpp') diff --git a/evdev.hpp b/evdev.hpp index 353c593..eb7781b 100644 --- a/evdev.hpp +++ b/evdev.hpp @@ -1,9 +1,14 @@ #pragma once -#include -#include -#include #include "file.hpp" +#include +#include + +#include +#include +#include +#include + namespace phosphor { namespace gpio @@ -46,85 +51,79 @@ using EvdevPtr = std::unique_ptr; class Evdev { - using Property = std::string; - using Value = sdbusplus::message::variant; - // Association between property and its value - using PropertyMap = std::map; - using Interface = std::string; - // Association between interface and the D-Bus property - using InterfaceMap = std::map; - using Object = sdbusplus::message::object_path; - // Association between object and the interface - using ObjectMap = std::map; - - public: - Evdev() = delete; - ~Evdev() = default; - Evdev(const Evdev&) = delete; - Evdev& operator=(const Evdev&) = delete; - Evdev(Evdev&&) = delete; - Evdev& operator=(Evdev&&) = delete; - - /** @brief Constructs Evdev object. - * - * @param[in] path - Device path to read for GPIO pin state - * @param[in] key - GPIO key to monitor - * @param[in] event - sd_event handler - * @param[in] handler - IO callback handler. - * @param[in] useEvDev - Whether to use EvDev to retrieve events - */ - Evdev(const std::string& path, - const unsigned int key, - EventPtr& event, - sd_event_io_handler_t handler, - bool useEvDev = true) : - path(path), - key(key), - event(event), - callbackHandler(handler), - fd(openDevice()) + using Property = std::string; + using Value = sdbusplus::message::variant; + // Association between property and its value + using PropertyMap = std::map; + using Interface = std::string; + // Association between interface and the D-Bus property + using InterfaceMap = std::map; + using Object = sdbusplus::message::object_path; + // Association between object and the interface + using ObjectMap = std::map; + + public: + Evdev() = delete; + ~Evdev() = default; + Evdev(const Evdev&) = delete; + Evdev& operator=(const Evdev&) = delete; + Evdev(Evdev&&) = delete; + Evdev& operator=(Evdev&&) = delete; + + /** @brief Constructs Evdev object. + * + * @param[in] path - Device path to read for GPIO pin state + * @param[in] key - GPIO key to monitor + * @param[in] event - sd_event handler + * @param[in] handler - IO callback handler. + * @param[in] useEvDev - Whether to use EvDev to retrieve events + */ + Evdev(const std::string& path, const unsigned int key, EventPtr& event, + sd_event_io_handler_t handler, bool useEvDev = true) : + path(path), + key(key), event(event), callbackHandler(handler), fd(openDevice()) + { + if (useEvDev) { - if (useEvDev) - { - // If we are asked to use EvDev, do that initialization. - initEvDev(); - } - - // Register callback handler when FD has some data - registerCallback(); + // If we are asked to use EvDev, do that initialization. + initEvDev(); } - protected: - /** @brief Device path to read for GPIO pin state */ - const std::string path; + // Register callback handler when FD has some data + registerCallback(); + } + + protected: + /** @brief Device path to read for GPIO pin state */ + const std::string path; - /** @brief GPIO key to monitor */ - const unsigned int key; + /** @brief GPIO key to monitor */ + const unsigned int key; - /** @brief Event structure */ - EvdevPtr devicePtr; + /** @brief Event structure */ + EvdevPtr devicePtr; - /** @brief Monitor to sd_event */ - EventPtr& event; + /** @brief Monitor to sd_event */ + EventPtr& event; - /** @brief Callback handler when the FD has some data */ - sd_event_io_handler_t callbackHandler; + /** @brief Callback handler when the FD has some data */ + sd_event_io_handler_t callbackHandler; - /** @brief event source */ - EventSourcePtr eventSource; + /** @brief event source */ + EventSourcePtr eventSource; - /** @brief Opens the device and populates the descriptor */ - int openDevice(); + /** @brief Opens the device and populates the descriptor */ + int openDevice(); - /** @brief attaches FD to events and sets up callback handler */ - void registerCallback(); + /** @brief attaches FD to events and sets up callback handler */ + void registerCallback(); - /** @brief File descriptor manager */ - FileDescriptor fd; + /** @brief File descriptor manager */ + FileDescriptor fd; - /** @brief Initializes evdev handle with the fd */ - void initEvDev(); + /** @brief Initializes evdev handle with the fd */ + void initEvDev(); }; } // namespace gpio -- cgit v1.2.1