diff options
author | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2018-03-29 10:34:05 -0400 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2018-03-29 10:34:46 -0400 |
commit | d1eac88d18ae7dd11033dba87b6aebb220da9064 (patch) | |
tree | 9744e38138ff853c53868d847f86e9ad58e9ac66 /src/event.hpp | |
parent | 1abcb06bedadfbd40b4ec6f7e5f6a95021df3c96 (diff) | |
download | phosphor-dbus-monitor-d1eac88d18ae7dd11033dba87b6aebb220da9064.tar.gz phosphor-dbus-monitor-d1eac88d18ae7dd11033dba87b6aebb220da9064.zip |
Enable clang-format
Fix up errors and enable clang-format during CI builds.
Change-Id: I4176b81f8b85a287af9354165e09ff66aeb9fb29
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Diffstat (limited to 'src/event.hpp')
-rw-r--r-- | src/event.hpp | 178 |
1 files changed, 84 insertions, 94 deletions
diff --git a/src/event.hpp b/src/event.hpp index b9f5167..a2a2236 100644 --- a/src/event.hpp +++ b/src/event.hpp @@ -22,60 +22,53 @@ namespace monitoring */ class EventBase : public IndexedCallback { - public: - EventBase() = delete; - EventBase(const EventBase&) = delete; - EventBase(EventBase&&) = default; - EventBase& operator=(const EventBase&) = delete; - EventBase& operator=(EventBase&&) = default; - virtual ~EventBase() = default; - EventBase(const PropertyIndex& index) : - IndexedCallback(index) {} + public: + EventBase() = delete; + EventBase(const EventBase&) = delete; + EventBase(EventBase&&) = default; + EventBase& operator=(const EventBase&) = delete; + EventBase& operator=(EventBase&&) = default; + virtual ~EventBase() = default; + EventBase(const PropertyIndex& index) : IndexedCallback(index) + { + } + + /** @brief Callback interface implementation. */ + void operator()(Context ctx) override + { + if (ctx == Context::START) + { + // No action should be taken + // as this call back is being called from + // daemon Startup. + return; + } - /** @brief Callback interface implementation. */ - void operator()(Context ctx) override + for (const auto& n : index) { - if (ctx == Context::START) - { - // No action should be taken - // as this call back is being called from - // daemon Startup. - return; - } + const auto& path = std::get<pathIndex>(n.first); + const auto& propertyMeta = std::get<propertyIndex>(n.first); + const auto& storage = std::get<storageIndex>(n.second); + const auto& value = std::get<valueIndex>(storage.get()); - for (const auto& n : index) + if (!value.empty()) { - const auto& path = std::get<pathIndex>(n.first); - const auto& propertyMeta = std::get<propertyIndex>(n.first); - const auto& storage = std::get<storageIndex>(n.second); - const auto& value = std::get<valueIndex>(storage.get()); - - if (!value.empty()) - { - createEvent( - path, - propertyMeta, - value); - } + createEvent(path, propertyMeta, value); } - } - - private: - - /** @brief Create the event Dbus Object. - * @param[in] path - Dbus Object Path for which the - * property has changed. - * @param[in] property - Name of the property whose value - * has been changed. - * @param[in] value - Changed property value. - */ - virtual void createEvent( - const std::string& path, - const std::string& property, - const any_ns::any& value) const = 0; - - + } + + private: + /** @brief Create the event Dbus Object. + * @param[in] path - Dbus Object Path for which the + * property has changed. + * @param[in] property - Name of the property whose value + * has been changed. + * @param[in] value - Changed property value. + */ + virtual void createEvent(const std::string& path, + const std::string& property, + const any_ns::any& value) const = 0; }; /** @class Event @@ -83,53 +76,50 @@ class EventBase : public IndexedCallback * * @tparam T - The C++ type of the property values being traced. */ -template <typename T> -class Event : public EventBase +template <typename T> class Event : public EventBase { - public: - Event() = delete; - Event(const Event&) = delete; - Event(Event&&) = default; - Event& operator=(const Event&) = delete; - Event& operator=(Event&&) = default; - ~Event() = default; - - /** @brief Constructor. - * @param[in] eventName - Name of the event. - * @param[in] eventMessage- Event Message. - * @param[in] index - look up index for the properties. - */ - Event(std::string eventName, - std::string eventMessage, - const PropertyIndex& index) : - EventBase(index), - name(eventName), - message(eventMessage) {} - - private: - /** @brief Create the event Dbus Object. - * @param[in] path - Dbus Object Path for which the - * property has changed. - * @param[in] property - Name of the property whose value - * has been changed. - * @param[in] value - Changed property value. - */ - void createEvent( - const std::string& path, - const std::string& property, - const any_ns::any& value) const override - { - std::stringstream ss {}; - ss << any_ns::any_cast<T>(value); - phosphor::events::getManager().create( - name, message, path, property, ss.str()); - } - - /** @brief Event Name */ - std::string name; - - /** @brief Event Message */ - std::string message; + public: + Event() = delete; + Event(const Event&) = delete; + Event(Event&&) = default; + Event& operator=(const Event&) = delete; + Event& operator=(Event&&) = default; + ~Event() = default; + + /** @brief Constructor. + * @param[in] eventName - Name of the event. + * @param[in] eventMessage- Event Message. + * @param[in] index - look up index for the properties. + */ + Event(std::string eventName, std::string eventMessage, + const PropertyIndex& index) : + EventBase(index), + name(eventName), message(eventMessage) + { + } + + private: + /** @brief Create the event Dbus Object. + * @param[in] path - Dbus Object Path for which the + * property has changed. + * @param[in] property - Name of the property whose value + * has been changed. + * @param[in] value - Changed property value. + */ + void createEvent(const std::string& path, const std::string& property, + const any_ns::any& value) const override + { + std::stringstream ss{}; + ss << any_ns::any_cast<T>(value); + phosphor::events::getManager().create(name, message, path, property, + ss.str()); + } + + /** @brief Event Name */ + std::string name; + + /** @brief Event Message */ + std::string message; }; } // namespace monitoring |