diff options
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | actions.hpp | 5 | ||||
-rw-r--r-- | examples/match2.yaml | 2 | ||||
-rw-r--r-- | manager.cpp | 6 | ||||
-rw-r--r-- | manager.hpp | 3 |
5 files changed, 17 insertions, 0 deletions
@@ -36,6 +36,7 @@ Supported action tags are: The available actions provided by PIM are: * noop - A non-action. +* destroyObject - Destroy the specified DBus object. ---- **match** diff --git a/actions.hpp b/actions.hpp index 2837e7a..ff08019 100644 --- a/actions.hpp +++ b/actions.hpp @@ -113,6 +113,11 @@ struct Wrapper /** @brief The default action. */ inline void noop(Manager &mgr) noexcept { } +/** @brief Destroy an object action. */ +inline auto destroyObject(const char *path) +{ + return [path](auto &m){m.destroyObject(path);}; +} } // namespace actions } // namespace manager } // namespace inventory diff --git a/examples/match2.yaml b/examples/match2.yaml index 8cfa105..269a469 100644 --- a/examples/match2.yaml +++ b/examples/match2.yaml @@ -18,5 +18,7 @@ events: - value: xyz.openbmc_project.Testing - value: TestProperty - value: teststring + action: + name: destroyObject("Example") # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 diff --git a/manager.cpp b/manager.cpp index 6c15bf0..d77f128 100644 --- a/manager.cpp +++ b/manager.cpp @@ -160,6 +160,12 @@ void Manager::signal(sdbusplus::message::message &msg, auto &args) } } +void Manager::destroyObject(const char *path) +{ + std::string p{path}; + _refs.erase(_root + p); +} + #include "generated.hpp" } // namespace manager diff --git a/manager.hpp b/manager.hpp index 23d91da..5f78066 100644 --- a/manager.hpp +++ b/manager.hpp @@ -123,6 +123,9 @@ class Manager final : /** @brief sd_bus signal callback. */ void signal(sdbusplus::message::message &, auto &); + /** @brief Drop an object from DBus. */ + void destroyObject(const char *); + using Event = std::tuple< const char *, filters::details::Wrapper, |