加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
events.hpp 1.92 KB
一键复制 编辑 原始数据 按行查看 历史
Brad Bishop 提交于 2020-12-06 14:51 . style: update clang-format
#pragma once
#include "types.hpp"
#include <memory>
#include <vector>
namespace phosphor
{
namespace inventory
{
namespace manager
{
class Manager;
/** @struct Event
* @brief Event object interface.
*
* The event base is an association of an event type
* and an array of filter callbacks.
*/
struct Event : public std::vector<Filter>
{
enum class Type
{
DBUS_SIGNAL,
STARTUP,
};
virtual ~Event() = default;
Event(const Event&) = delete;
Event& operator=(const Event&) = delete;
Event(Event&&) = default;
Event& operator=(Event&&) = default;
/** @brief Event constructor.
*
* @param[in] filters - An array of filter callbacks.
* @param[in] t - The event type.
*/
explicit Event(const std::vector<Filter>& filters, Type t = Type::STARTUP) :
std::vector<Filter>(filters), type(t)
{}
/** @brief event class enumeration. */
Type type;
};
using StartupEvent = Event;
using EventBasePtr = std::shared_ptr<Event>;
/** @struct DbusSignal
* @brief DBus signal event.
*
* DBus signal events are an association of a match signature
* and filtering function object.
*/
struct DbusSignal final : public Event
{
~DbusSignal() = default;
DbusSignal(const DbusSignal&) = delete;
DbusSignal& operator=(const DbusSignal&) = delete;
DbusSignal(DbusSignal&&) = default;
DbusSignal& operator=(DbusSignal&&) = default;
/** @brief Import from signature and filter constructor.
*
* @param[in] sig - The DBus match signature.
* @param[in] filter - An array of DBus signal
* match callback filtering functions.
*/
DbusSignal(const char* sig, const std::vector<Filter>& filters) :
Event(filters, Type::DBUS_SIGNAL), signature(sig)
{}
const char* signature;
};
} // namespace manager
} // namespace inventory
} // namespace phosphor
// vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化