cleanup the code related to emit_interface_added

sdbusplus now supports action::emit_interface_added() when an object is
constructed, so the code that manually invokes emit_interface_added()
could be cleaned up and use the above action instead.

Tested:Tested on fp5280g2,and pnor code update works fine.

Signed-off-by: Albert Zhang <zhanghaodi@inspur.com>
Change-Id: I5a68090d7e1bbd31c0df351d553ef6fa6d63e277
diff --git a/activation.hpp b/activation.hpp
index 792e5d5..343458d 100644
--- a/activation.hpp
+++ b/activation.hpp
@@ -69,19 +69,12 @@
      */
     RedundancyPriority(sdbusplus::bus::bus& bus, const std::string& path,
                        Activation& parent, uint8_t value) :
-        RedundancyPriorityInherit(bus, path.c_str(), true),
-        parent(parent), bus(bus), path(path)
+        RedundancyPriorityInherit(bus, path.c_str(),
+                                  action::emit_interface_added),
+        parent(parent)
     {
         // Set Property
         priority(value);
-        std::vector<std::string> interfaces({interface});
-        bus.emit_interfaces_added(path.c_str(), interfaces);
-    }
-
-    virtual ~RedundancyPriority()
-    {
-        std::vector<std::string> interfaces({interface});
-        bus.emit_interfaces_removed(path.c_str(), interfaces);
     }
 
     /** @brief Overloaded Priority property set function
@@ -100,13 +93,6 @@
 
     /** @brief Parent Object. */
     Activation& parent;
-
-  private:
-    // TODO Remove once openbmc/openbmc#1975 is resolved
-    static constexpr auto interface =
-        "xyz.openbmc_project.Software.RedundancyPriority";
-    sdbusplus::bus::bus& bus;
-    std::string path;
 };
 
 /** @class ActivationBlocksTransition
@@ -124,25 +110,11 @@
      */
     ActivationBlocksTransition(sdbusplus::bus::bus& bus,
                                const std::string& path) :
-        ActivationBlocksTransitionInherit(bus, path.c_str(), true),
-        bus(bus), path(path)
-    {
-        std::vector<std::string> interfaces({interface});
-        bus.emit_interfaces_added(path.c_str(), interfaces);
-    }
+        ActivationBlocksTransitionInherit(bus, path.c_str(),
+                                          action::emit_interface_added)
 
-    ~ActivationBlocksTransition()
     {
-        std::vector<std::string> interfaces({interface});
-        bus.emit_interfaces_removed(path.c_str(), interfaces);
     }
-
-  private:
-    // TODO Remove once openbmc/openbmc#1975 is resolved
-    static constexpr auto interface =
-        "xyz.openbmc_project.Software.ActivationBlocksTransition";
-    sdbusplus::bus::bus& bus;
-    std::string path;
 };
 
 class ActivationProgress : public ActivationProgressInherit
@@ -154,25 +126,11 @@
      * @param[in] path   - The Dbus object path
      */
     ActivationProgress(sdbusplus::bus::bus& bus, const std::string& path) :
-        ActivationProgressInherit(bus, path.c_str(), true), bus(bus), path(path)
+        ActivationProgressInherit(bus, path.c_str(),
+                                  action::emit_interface_added)
     {
         progress(0);
-        std::vector<std::string> interfaces({interface});
-        bus.emit_interfaces_added(path.c_str(), interfaces);
     }
-
-    ~ActivationProgress()
-    {
-        std::vector<std::string> interfaces({interface});
-        bus.emit_interfaces_removed(path.c_str(), interfaces);
-    }
-
-  private:
-    // TODO Remove once openbmc/openbmc#1975 is resolved
-    static constexpr auto interface =
-        "xyz.openbmc_project.Software.ActivationProgress";
-    sdbusplus::bus::bus& bus;
-    std::string path;
 };
 
 /** @class Activation
diff --git a/version.hpp b/version.hpp
index 13f772f..85dccda 100644
--- a/version.hpp
+++ b/version.hpp
@@ -45,17 +45,9 @@
      *  @param[in] parent - Parent object.
      */
     Delete(sdbusplus::bus::bus& bus, const std::string& path, Version& parent) :
-        DeleteInherit(bus, path.c_str(), true), parent(parent), bus(bus),
-        path(path)
+        DeleteInherit(bus, path.c_str(), action::emit_interface_added),
+        parent(parent)
     {
-        std::vector<std::string> interfaces({interface});
-        bus.emit_interfaces_added(path.c_str(), interfaces);
-    }
-
-    ~Delete()
-    {
-        std::vector<std::string> interfaces({interface});
-        bus.emit_interfaces_removed(path.c_str(), interfaces);
     }
 
     /**
@@ -68,11 +60,6 @@
   private:
     /** @brief Parent Object. */
     Version& parent;
-
-    // TODO Remove once openbmc/openbmc#1975 is resolved
-    static constexpr auto interface = "xyz.openbmc_project.Object.Delete";
-    sdbusplus::bus::bus& bus;
-    std::string path;
 };
 
 /** @class Version