diff options
author | Patrick Venture <venture@google.com> | 2018-11-01 16:52:10 -0700 |
---|---|---|
committer | Patrick Venture <venture@google.com> | 2018-11-01 16:59:54 -0700 |
commit | dace680fa404d7c02a68db105fd7b958b4681442 (patch) | |
tree | 6d447ced41a2d1ef9bbd8206d52099609cd973d1 /monitor.hpp | |
parent | 3c4a23e7764c7785d18cb30340a6d185022a797a (diff) | |
download | phosphor-gpio-monitor-dace680fa404d7c02a68db105fd7b958b4681442.tar.gz phosphor-gpio-monitor-dace680fa404d7c02a68db105fd7b958b4681442.zip |
Add clang-format to repo
Add clang-format to repo.
Change-Id: I3f8704d80dd0bdde0706ab189c68cffe6d347995
Signed-off-by: Patrick Venture <venture@google.com>
Diffstat (limited to 'monitor.hpp')
-rw-r--r-- | monitor.hpp | 124 |
1 files changed, 61 insertions, 63 deletions
diff --git a/monitor.hpp b/monitor.hpp index f4b07de..771492a 100644 --- a/monitor.hpp +++ b/monitor.hpp @@ -1,11 +1,13 @@ #pragma once -#include <unistd.h> -#include <string> +#include "evdev.hpp" + #include <linux/input.h> #include <systemd/sd-event.h> +#include <unistd.h> + #include <sdbusplus/bus.hpp> -#include "evdev.hpp" +#include <string> namespace phosphor { @@ -18,74 +20,70 @@ namespace gpio */ class Monitor : public Evdev { - public: - Monitor() = delete; - ~Monitor() = default; - Monitor(const Monitor&) = delete; - Monitor& operator=(const Monitor&) = delete; - Monitor(Monitor&&) = delete; - Monitor& operator=(Monitor&&) = delete; + public: + Monitor() = delete; + ~Monitor() = default; + Monitor(const Monitor&) = delete; + Monitor& operator=(const Monitor&) = delete; + Monitor(Monitor&&) = delete; + Monitor& operator=(Monitor&&) = delete; - /** @brief Constructs Monitor object. - * - * @param[in] path - Path to gpio input device - * @param[in] key - GPIO key to monitor - * @param[in] polarity - GPIO assertion polarity to look for - * @param[in] target - systemd unit to be started on GPIO - * value change - * @param[in] event - sd_event handler - * @param[in] continueRun - Whether to continue after key pressed - * @param[in] handler - IO callback handler. Defaults to one in this - * class - * @param[in] useEvDev - Whether to use EvDev to retrieve events - */ - Monitor(const std::string& path, - decltype(input_event::code) key, - decltype(input_event::value) polarity, - const std::string& target, - EventPtr& event, - bool continueRun, - sd_event_io_handler_t handler = Monitor::processEvents, - bool useEvDev = true) - : Evdev(path, key, event, handler, useEvDev), - polarity(polarity), - target(target), - continueAfterKeyPress(continueRun) {}; + /** @brief Constructs Monitor object. + * + * @param[in] path - Path to gpio input device + * @param[in] key - GPIO key to monitor + * @param[in] polarity - GPIO assertion polarity to look for + * @param[in] target - systemd unit to be started on GPIO + * value change + * @param[in] event - sd_event handler + * @param[in] continueRun - Whether to continue after key pressed + * @param[in] handler - IO callback handler. Defaults to one in this + * class + * @param[in] useEvDev - Whether to use EvDev to retrieve events + */ + Monitor(const std::string& path, decltype(input_event::code) key, + decltype(input_event::value) polarity, const std::string& target, + EventPtr& event, bool continueRun, + sd_event_io_handler_t handler = Monitor::processEvents, + bool useEvDev = true) : + Evdev(path, key, event, handler, useEvDev), + polarity(polarity), target(target), + continueAfterKeyPress(continueRun){}; - /** @brief Callback handler when the FD has some activity on it - * - * @param[in] es - Populated event source - * @param[in] fd - Associated File descriptor - * @param[in] revents - Type of event - * @param[in] userData - User data that was passed during registration - * - * @return - 0 or positive number on success and negative - * errno otherwise - */ - static int processEvents(sd_event_source* es, int fd, - uint32_t revents, void* userData); + /** @brief Callback handler when the FD has some activity on it + * + * @param[in] es - Populated event source + * @param[in] fd - Associated File descriptor + * @param[in] revents - Type of event + * @param[in] userData - User data that was passed during registration + * + * @return - 0 or positive number on success and negative + * errno otherwise + */ + static int processEvents(sd_event_source* es, int fd, uint32_t revents, + void* userData); - /** @brief Returns the completion state of this handler */ - inline auto completed() const - { - return complete; - } + /** @brief Returns the completion state of this handler */ + inline auto completed() const + { + return complete; + } - private: - /** @brief GPIO key value that is of interest */ - decltype(input_event::value) polarity; + private: + /** @brief GPIO key value that is of interest */ + decltype(input_event::value) polarity; - /** @brief Systemd unit to be started when the condition is met */ - const std::string& target; + /** @brief Systemd unit to be started when the condition is met */ + const std::string& target; - /** @brief If the monitor should continue after key press */ - bool continueAfterKeyPress; + /** @brief If the monitor should continue after key press */ + bool continueAfterKeyPress; - /** @brief Completion indicator */ - bool complete = false; + /** @brief Completion indicator */ + bool complete = false; - /** @brief Analyzes the GPIO event and starts configured target */ - void analyzeEvent(); + /** @brief Analyzes the GPIO event and starts configured target */ + void analyzeEvent(); }; } // namespace gpio |