summaryrefslogtreecommitdiffstats
path: root/actions.hpp
diff options
context:
space:
mode:
authorBrad Bishop <bradleyb@fuzziesquirrel.com>2017-02-09 01:27:38 -0500
committerPatrick Williams <patrick@stwcx.xyz>2017-02-15 17:43:18 +0000
commitc1f4798d36e63842c97692ca1a36c0975da18c09 (patch)
tree8268892833c89fba16aa364ef129c91afb455105 /actions.hpp
parent02ca0219c1e20f4f51eba068a9a9e272a60f7385 (diff)
downloadphosphor-inventory-manager-c1f4798d36e63842c97692ca1a36c0975da18c09.tar.gz
phosphor-inventory-manager-c1f4798d36e63842c97692ca1a36c0975da18c09.zip
Merge actions.hpp and events.hpp
Move all action/filter functors to a common functor.hpp. The intent of this refactoring is to facilitate reuse of functors in more than one context. - Moved functors from actions.hpp and events.hpp to functor.hpp. - Renamed events.cpp to functor.cpp. - Moved Action/Filter types to types.hpp. - Minor namespace shuffling. - Update pimgen to render according to the new namespaces. Change-Id: I630ec1587b8a48f6dc2eac1111365035873310d9 Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Diffstat (limited to 'actions.hpp')
-rw-r--r--actions.hpp101
1 files changed, 0 insertions, 101 deletions
diff --git a/actions.hpp b/actions.hpp
deleted file mode 100644
index 31932b2..0000000
--- a/actions.hpp
+++ /dev/null
@@ -1,101 +0,0 @@
-#pragma once
-
-#include <utility>
-#include <memory>
-#include <functional>
-#include "utils.hpp"
-#include "types.hpp"
-
-namespace phosphor
-{
-namespace inventory
-{
-namespace manager
-{
-
-class Manager;
-
-using Action = std::function<void (sdbusplus::bus::bus&, Manager&)>;
-
-/** @brief make_action
- *
- * Adapt an action function object.
- *
- * @param[in] action - The action being adapted.
- * @returns - The adapted action.
- *
- * @tparam T - The type of the action being adapted.
- */
-template <typename T>
-auto make_action(T&& action)
-{
- return Action(std::forward<T>(action));
-}
-
-namespace actions
-{
-
-/** @brief Destroy objects action. */
-inline auto destroyObjects(std::vector<const char*>&& paths)
-{
- return [ = ](auto&, auto & m)
- {
- m.destroyObjects(paths);
- };
-}
-
-/** @brief Create objects action. */
-inline auto createObjects(
- std::map<sdbusplus::message::object_path, Object>&& objs)
-{
- return [ = ](auto&, auto & m)
- {
- m.createObjects(objs);
- };
-}
-
-/** @brief Set a property action.
- *
- * Invoke the requested method with a reference to the requested
- * sdbusplus server binding interface as a parameter.
- *
- * @tparam T - The sdbusplus server binding interface type.
- * @tparam U - The type of the sdbusplus server binding member
- * function that sets the property.
- * @tparam V - The property value type.
- *
- * @param[in] paths - The DBus paths on which the property should
- * be set.
- * @param[in] iface - The DBus interface hosting the property.
- * @param[in] member - Pointer to sdbusplus server binding member.
- * @param[in] value - The value the property should be set to.
- *
- * @returns - A function object that sets the requested property
- * to the requested value.
- */
-template <typename T, typename U, typename V>
-auto setProperty(
- std::vector<const char*>&& paths, const char* iface,
- U&& member, V&& value)
-{
- // The manager is the only parameter passed to actions.
- // Bind the path, interface, interface member function pointer,
- // and value to a lambda. When it is called, forward the
- // path, interface and value on to the manager member function.
- return [paths, iface, member,
- value = std::forward<V>(value)](auto&, auto & m)
- {
- for (auto p : paths)
- {
- m.template invokeMethod<T>(
- p, iface, member, value);
- }
- };
-}
-
-} // namespace actions
-} // namespace manager
-} // namespace inventory
-} // namespace phosphor
-
-// vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
OpenPOWER on IntegriCloud