manager: switch to refactored internal APIs

Switch the manager over to the new serialization concept API
implementation and the new interface operations API - introduced
previously.

Change-Id: I756021e4c42c0f61d269dccfd9ff0c489d91c0c7
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/generated.mako.cpp b/generated.mako.cpp
index 6fc1521..fee8745 100644
--- a/generated.mako.cpp
+++ b/generated.mako.cpp
@@ -25,16 +25,16 @@
         std::make_tuple(
             MakeInterface<
                 ServerObject<
-                    ${i.namespace()}>>::make,
-            MakeInterface<
+                    ${i.namespace()}>>::op,
+            AssignInterface<
                 ServerObject<
-                    ${i.namespace()}>>::assign,
-            MakeInterface<
+                    ${i.namespace()}>>::op,
+            SerializeInterface<
                 ServerObject<
-                    ${i.namespace()}>>::serialize,
-            MakeInterface<
+                    ${i.namespace()}>, SerialOps>::op,
+            DeserializeInterface<
                 ServerObject<
-                    ${i.namespace()}>>::deserialize
+                    ${i.namespace()}>, SerialOps>::op
         )
     },
 % endfor
diff --git a/manager.cpp b/manager.cpp
index dcd2e48..fd33c80 100644
--- a/manager.cpp
+++ b/manager.cpp
@@ -161,7 +161,7 @@
             if (refaceit == refaces.end() || refaceit->first != ifaceit->first)
             {
                 // Add the new interface.
-                auto& ctor = std::get<MakerType>(opsit->second);
+                auto& ctor = std::get<MakeInterfaceType>(opsit->second);
                 refaceit = refaces.insert(
                     refaceit,
                     std::make_pair(ifaceit->first, ctor(_bus, path.str.c_str(),
@@ -171,17 +171,20 @@
             else
             {
                 // Set the new property values.
-                auto& assign = std::get<AssignerType>(opsit->second);
+                auto& assign = std::get<AssignInterfaceType>(opsit->second);
                 assign(ifaceit->second, refaceit->second);
             }
             if (!restoreFromCache)
             {
-                auto& serialize = std::get<SerializerType>(opsit->second);
+                auto& serialize =
+                    std::get<SerializeInterfaceType<SerialOps>>(opsit->second);
                 serialize(path, ifaceit->first, refaceit->second);
             }
             else
             {
-                auto& deserialize = std::get<DeserializerType>(opsit->second);
+                auto& deserialize =
+                    std::get<DeserializeInterfaceType<SerialOps>>(
+                        opsit->second);
                 deserialize(path, ifaceit->first, refaceit->second);
             }
         }
diff --git a/manager.hpp b/manager.hpp
index 93957d9..cabbac9 100644
--- a/manager.hpp
+++ b/manager.hpp
@@ -2,6 +2,7 @@
 
 #include "events.hpp"
 #include "functor.hpp"
+#include "interface_ops.hpp"
 #include "serialize.hpp"
 #include "types.hpp"
 
@@ -13,6 +14,13 @@
 #include <vector>
 #include <xyz/openbmc_project/Inventory/Manager/server.hpp>
 
+namespace sdbusplus
+{
+namespace bus
+{
+class bus;
+}
+} // namespace sdbusplus
 namespace phosphor
 {
 namespace inventory
@@ -26,146 +34,6 @@
 using ManagerIface =
     sdbusplus::xyz::openbmc_project::Inventory::server::Manager;
 
-/** @struct PropertiesVariant
- *  @brief Wrapper for sdbusplus PropertiesVariant.
- *
- *  A wrapper is useful since MakeInterface is instantiated with 'int'
- *  to deduce the return type of its methods, which does not depend
- *  on T.
- *
- *  @tparam T - The sdbusplus server binding type.
- */
-template <typename T, typename Enable = void>
-struct PropertiesVariant
-{
-};
-
-template <typename T>
-struct PropertiesVariant<
-    T, typename std::enable_if<std::is_object<T>::value>::type>
-{
-    using Type = typename T::PropertiesVariant;
-};
-
-template <typename T>
-using PropertiesVariantType = typename PropertiesVariant<T>::Type;
-
-template <typename T, typename U = int>
-struct HasProperties : std::false_type
-{
-};
-
-template <typename T>
-struct HasProperties<
-    T, decltype((void)std::declval<typename T::PropertiesVariant>(), 0)>
-    : std::true_type
-{
-};
-
-template <typename T, std::enable_if_t<HasProperties<T>::value, bool> = true>
-std::any propMake(sdbusplus::bus::bus& bus, const char* path,
-                  const Interface& props)
-{
-    using InterfaceVariant = std::map<std::string, PropertiesVariantType<T>>;
-
-    InterfaceVariant v;
-    for (const auto& p : props)
-    {
-        v.emplace(p.first, convertVariant<PropertiesVariantType<T>>(p.second));
-    }
-
-    return std::any(std::make_shared<T>(bus, path, v));
-}
-
-template <typename T, std::enable_if_t<!HasProperties<T>::value, bool> = false>
-std::any propMake(sdbusplus::bus::bus& bus, const char* path,
-                  const Interface& props)
-{
-    return std::any(std::make_shared<T>(bus, path));
-}
-
-template <typename T, std::enable_if_t<HasProperties<T>::value, bool> = true>
-void propAssign(const Interface& props, std::any& holder)
-{
-    auto& iface = *std::any_cast<std::shared_ptr<T>&>(holder);
-    for (const auto& p : props)
-    {
-        iface.setPropertyByName(
-            p.first, convertVariant<PropertiesVariantType<T>>(p.second));
-    }
-}
-
-template <typename T, std::enable_if_t<!HasProperties<T>::value, bool> = false>
-void propAssign(const Interface& props, std::any& holder)
-{
-}
-
-template <typename T, std::enable_if_t<HasProperties<T>::value, bool> = true>
-void propSerialize(const std::string& path, const std::string& iface,
-                   const std::any& holder)
-{
-    const auto& object = *std::any_cast<const std::shared_ptr<T>&>(holder);
-    SerialOps::serialize(path, iface, object);
-}
-
-template <typename T, std::enable_if_t<!HasProperties<T>::value, bool> = false>
-void propSerialize(const std::string& path, const std::string& iface,
-                   const std::any& holder)
-{
-    SerialOps::serialize(path, iface);
-}
-
-template <typename T, std::enable_if_t<HasProperties<T>::value, bool> = true>
-void propDeSerialize(const std::string& path, const std::string& iface,
-                     std::any& holder)
-{
-    auto& object = *std::any_cast<std::shared_ptr<T>&>(holder);
-    SerialOps::deserialize(path, iface, object);
-}
-
-template <typename T, std::enable_if_t<!HasProperties<T>::value, bool> = false>
-void propDeSerialize(const std::string& path, const std::string& iface,
-                     std::any& holder)
-{
-    SerialOps::deserialize(path, iface);
-}
-
-/** @struct MakeInterface
- *  @brief Adapt an sdbusplus interface proxy.
- *
- *  Template instances are builder functions that create
- *  adapted sdbusplus interface proxy interface objects.
- *
- *  @tparam T - The type of the interface being adapted.
- */
-
-template <typename T>
-struct MakeInterface
-{
-    static std::any make(sdbusplus::bus::bus& bus, const char* path,
-                         const Interface& props)
-    {
-        return propMake<T>(bus, path, props);
-    }
-
-    static void assign(const Interface& props, std::any& holder)
-    {
-        propAssign<T>(props, holder);
-    }
-
-    static void serialize(const std::string& path, const std::string& iface,
-                          const std::any& holder)
-    {
-        propSerialize<T>(path, iface, holder);
-    }
-
-    static void deserialize(const std::string& path, const std::string& iface,
-                            std::any& holder)
-    {
-        propDeSerialize<T>(path, iface, holder);
-    }
-};
-
 /** @class Manager
  *  @brief OpenBMC inventory manager implementation.
  *
@@ -261,16 +129,10 @@
 
     // The int instantiations are safe since the signature of these
     // functions don't change from one instantiation to the next.
-    using MakerType = std::add_pointer_t<decltype(MakeInterface<int>::make)>;
-    using AssignerType =
-        std::add_pointer_t<decltype(MakeInterface<int>::assign)>;
-    using SerializerType =
-        std::add_pointer_t<decltype(MakeInterface<int>::serialize)>;
-    using DeserializerType =
-        std::add_pointer_t<decltype(MakeInterface<int>::deserialize)>;
     using Makers =
-        std::map<std::string, std::tuple<MakerType, AssignerType,
-                                         SerializerType, DeserializerType>>;
+        std::map<std::string, std::tuple<MakeInterfaceType, AssignInterfaceType,
+                                         SerializeInterfaceType<SerialOps>,
+                                         DeserializeInterfaceType<SerialOps>>>;
 
     /** @brief Provides weak references to interface holders.
      *