Use std::function

Replace CallableHolder with std::function.  No need to re-invent
the wheel.

Change-Id: I2647a802237dba4a48187718f0d3da59e97575d7
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/actions.hpp b/actions.hpp
index 2fea212..403dca1 100644
--- a/actions.hpp
+++ b/actions.hpp
@@ -2,6 +2,7 @@
 
 #include <utility>
 #include <memory>
+#include <functional>
 #include "utils.hpp"
 #include "types.hpp"
 
@@ -15,10 +16,7 @@
 class Manager;
 namespace details
 {
-using ActionBase = holder::CallableBase<void, sdbusplus::bus::bus&, Manager&>;
-using ActionBasePtr = std::shared_ptr<ActionBase>;
-template <typename T>
-using Action = holder::CallableHolder<T, void, sdbusplus::bus::bus&, Manager&>;
+using Action = std::function<void (sdbusplus::bus::bus&, Manager&)>;
 
 /** @brief make_action
  *
@@ -32,8 +30,7 @@
 template <typename T>
 auto make_action(T&& action)
 {
-    return Action<T>::template make_shared<Action<T>>(
-        std::forward<T>(action));
+    return Action(std::forward<T>(action));
 }
 } // namespace details
 
@@ -43,7 +40,7 @@
 /** @brief Destroy objects action.  */
 inline auto destroyObjects(std::vector<const char*>&& paths)
 {
-    return [=](auto&, auto & m)
+    return [ = ](auto&, auto & m)
     {
         m.destroyObjects(paths);
     };
@@ -53,7 +50,7 @@
 inline auto createObjects(
     std::map<sdbusplus::message::object_path, Object>&& objs)
 {
-    return [=](auto&, auto & m)
+    return [ = ](auto&, auto & m)
     {
         m.createObjects(objs);
     };
diff --git a/events.hpp b/events.hpp
index 6737861..9ecb93a 100644
--- a/events.hpp
+++ b/events.hpp
@@ -2,6 +2,7 @@
 
 #include <utility>
 #include <memory>
+#include <functional>
 #include <sdbusplus/message.hpp>
 #include "utils.hpp"
 
@@ -15,12 +16,8 @@
 class Manager;
 namespace details
 {
-using FilterBase = holder::CallableBase <
-                   bool, sdbusplus::bus::bus&, sdbusplus::message::message&, Manager& >;
-using FilterBasePtr = std::shared_ptr<FilterBase>;
-template <typename T>
-using Filter = holder::CallableHolder <
-               T, bool, sdbusplus::bus::bus&, sdbusplus::message::message&, Manager& >;
+using Filter = std::function <
+               bool (sdbusplus::bus::bus&, sdbusplus::message::message&, Manager&) >;
 
 /** @struct Event
  *  @brief Event object interface.
@@ -28,7 +25,7 @@
  *  The event base is an assocation of an event type
  *  and an array of filter callbacks.
  */
-struct Event : public std::vector<FilterBasePtr>
+struct Event : public std::vector<Filter>
 {
     enum class Type
     {
@@ -48,8 +45,8 @@
      *  @param[in] t - The event type.
      */
     explicit Event(
-        const std::vector<FilterBasePtr>& filters, Type t = Type::STARTUP) :
-        std::vector<FilterBasePtr>(filters),
+        const std::vector<Filter>& filters, Type t = Type::STARTUP) :
+        std::vector<Filter>(filters),
         type(t) {}
 
     /** @brief event class enumeration. */
@@ -80,7 +77,7 @@
      *  @param[in] filter - An array of DBus signal
      *     match callback filtering functions.
      */
-    DbusSignal(const char* sig, const std::vector<FilterBasePtr>& filters) :
+    DbusSignal(const char* sig, const std::vector<Filter>& filters) :
         Event(filters, Type::DBUS_SIGNAL),
         signature(sig) {}
 
@@ -99,8 +96,7 @@
 template <typename T>
 auto make_filter(T&& filter)
 {
-    return Filter<T>::template make_shared<Filter<T>>(
-        std::forward<T>(filter));
+    return Filter(std::forward<T>(filter));
 }
 } // namespace details
 
@@ -123,7 +119,7 @@
         PropertyChangedCondition() = delete;
         ~PropertyChangedCondition() = default;
         PropertyChangedCondition(const PropertyChangedCondition&) = default;
-        PropertyChangedCondition& operator=(const PropertyChangedCondition&) = delete;
+        PropertyChangedCondition& operator=(const PropertyChangedCondition&) = default;
         PropertyChangedCondition(PropertyChangedCondition&&) = default;
         PropertyChangedCondition& operator=(PropertyChangedCondition&&) = default;
         PropertyChangedCondition(const char* iface, const char* property,
@@ -180,8 +176,8 @@
 {
         PropertyConditionBase() = delete;
         virtual ~PropertyConditionBase() = default;
-        PropertyConditionBase(const PropertyConditionBase&) = delete;
-        PropertyConditionBase& operator=(const PropertyConditionBase&) = delete;
+        PropertyConditionBase(const PropertyConditionBase&) = default;
+        PropertyConditionBase& operator=(const PropertyConditionBase&) = default;
         PropertyConditionBase(PropertyConditionBase&&) = default;
         PropertyConditionBase& operator=(PropertyConditionBase&&) = default;
 
@@ -239,8 +235,8 @@
 {
         PropertyCondition() = delete;
         ~PropertyCondition() = default;
-        PropertyCondition(const PropertyCondition&) = delete;
-        PropertyCondition& operator=(const PropertyCondition&) = delete;
+        PropertyCondition(const PropertyCondition&) = default;
+        PropertyCondition& operator=(const PropertyCondition&) = default;
         PropertyCondition(PropertyCondition&&) = default;
         PropertyCondition& operator=(PropertyCondition&&) = default;
 
diff --git a/manager.cpp b/manager.cpp
index 7d0e7d3..94748ad 100644
--- a/manager.cpp
+++ b/manager.cpp
@@ -165,14 +165,14 @@
 
     for (auto& f : event)
     {
-        if (!(*f)(_bus, msg, *this))
+        if (!f(_bus, msg, *this))
         {
             return;
         }
     }
     for (auto& action : actions)
     {
-        (*action)(_bus, *this);
+        action(_bus, *this);
     }
 }
 
diff --git a/manager.hpp b/manager.hpp
index c1137a4..9d83ee8 100644
--- a/manager.hpp
+++ b/manager.hpp
@@ -81,7 +81,7 @@
 
         using EventInfo = std::tuple <
                           std::vector<details::EventBasePtr>,
-                          std::vector<details::ActionBasePtr >>;
+                          std::vector<details::Action >>;
 
         /** @brief Start processing DBus messages. */
         void run() noexcept;
diff --git a/pimgen.py b/pimgen.py
index 4fd6fcc..4cbaafd 100755
--- a/pimgen.py
+++ b/pimgen.py
@@ -371,7 +371,7 @@
         filters = [
             self.filter_map[x['name']](**x) for x in kw.pop('filters', [])]
         filters = Vector(
-            templates=[Template(name='FilterBasePtr', namespace=['details'])],
+            templates=[Template(name='Filter', namespace=['details'])],
             args=filters)
 
         event = MethodCall(
@@ -386,7 +386,7 @@
             templates=[Template(name='EventBasePtr', namespace=['details'])],
             args=[event])
 
-        action_type = Template(name='ActionBasePtr', namespace=['details'])
+        action_type = Template(name='Action', namespace=['details'])
         action_args = [
             self.action_map[x['name']](**x) for x in kw.pop('actions', [])]
         actions = Vector(
diff --git a/utils.hpp b/utils.hpp
index 1ea7fc1..837c82f 100644
--- a/utils.hpp
+++ b/utils.hpp
@@ -92,67 +92,6 @@
     protected:
         T _held;
 };
-
-/** @struct CallableBase
- *  @brief Adapt any callable function object base class.
- *
- *  Provides an un-templated base class for use with an adapt to any
- *  callable function object type.
- *
- *  @tparam Ret - The return type of the callable.
- *  @tparam Args - The argument types of the callable.
- */
-template <typename Ret, typename ...Args>
-struct CallableBase
-{
-    CallableBase() = default;
-    virtual ~CallableBase() = default;
-    CallableBase(const CallableBase&) = delete;
-    CallableBase& operator=(const CallableBase&) = delete;
-    CallableBase(CallableBase&&) = default;
-    CallableBase& operator=(CallableBase&&) = default;
-
-    virtual Ret operator()(Args&& ...args) const = 0;
-    virtual Ret operator()(Args&& ...args)
-    {
-        return const_cast<const CallableBase&>(*this)(
-                   std::forward<Args>(args)...);
-    }
-};
-
-/** @struct CallableHolder
- *  @brief Adapt from any callable type.
- *
- *  Adapts any callable type.
- *
- *  @tparam T - The type of the callable.
- *  @tparam Ret - The return type of the callable.
- *  @tparam Args - The argument types of the callable.
- */
-template <typename T, typename Ret, typename ...Args>
-struct CallableHolder final :
-    public CallableBase<Ret, Args...>,
-    public Holder<T>
-{
-    CallableHolder() = delete;
-    ~CallableHolder() = default;
-    CallableHolder(const CallableHolder&) = delete;
-    CallableHolder& operator=(const CallableHolder&) = delete;
-    CallableHolder(CallableHolder&&) = default;
-    CallableHolder& operator=(CallableHolder&&) = default;
-    explicit CallableHolder(T&& func) : Holder<T>(std::forward<T>(func)) {}
-
-    virtual Ret operator()(Args&& ...args) const override
-    {
-        return this->_held(std::forward<Args>(args)...);
-    }
-
-    virtual Ret operator()(Args&& ...args) override
-    {
-        return this->_held(std::forward<Args>(args)...);
-    }
-};
-
 } // namespace holder
 } // namespace details
 } // namespace manager