Support to skip property changed signal

PropertyChanged signals are sent out, even before
InterfacesAdded signals (if deferSignal is set to true in
Object) are sent. This patch provides an option, to skip sending out
PropertiesChanged signal for proper initialization sequence.

Change-Id: I1678d80cc382fce420dda9f0dd9413d43c1c711d
Signed-off-by: Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>
diff --git a/tools/sdbusplus/templates/interface.mako.server.cpp.in b/tools/sdbusplus/templates/interface.mako.server.cpp.in
index 5fa46a9..aee5424 100644
--- a/tools/sdbusplus/templates/interface.mako.server.cpp.in
+++ b/tools/sdbusplus/templates/interface.mako.server.cpp.in
@@ -33,12 +33,13 @@
 
     % if interface.properties:
 ${classname}::${classname}(bus::bus& bus, const char* path,
-                           const std::map<std::string, PropertiesVariant>& vals)
+                           const std::map<std::string, PropertiesVariant>& vals,
+                           bool skipSignal)
         : ${classname}(bus, path)
 {
     for (const auto& v : vals)
     {
-        setPropertyByName(v.first, v.second);
+        setPropertyByName(v.first, v.second, skipSignal);
     }
 }
 
@@ -57,14 +58,15 @@
 
     % if interface.properties:
 void ${classname}::setPropertyByName(const std::string& _name,
-                                     const PropertiesVariant& val)
+                                     const PropertiesVariant& val,
+                                     bool skipSignal)
 {
         % for p in interface.properties:
     if (_name == "${p.name}")
     {
         auto& v = message::variant_ns::get<${p.cppTypeParam(interface.name)}>(\
 val);
-        ${p.camelCase}(v);
+        ${p.camelCase}(v, skipSignal);
         return;
     }
         % endfor
diff --git a/tools/sdbusplus/templates/interface.mako.server.hpp b/tools/sdbusplus/templates/interface.mako.server.hpp
index ec02c57..b263c7a 100644
--- a/tools/sdbusplus/templates/interface.mako.server.hpp
+++ b/tools/sdbusplus/templates/interface.mako.server.hpp
@@ -66,7 +66,8 @@
          *  @param[in] vals - Map of property name to value for initialization.
          */
         ${classname}(bus::bus& bus, const char* path,
-                     const std::map<std::string, PropertiesVariant>& vals);
+                     const std::map<std::string, PropertiesVariant>& vals,
+                     bool skipSignal = false);
 
     % endif
     % for m in interface.methods:
@@ -80,6 +81,10 @@
     % for p in interface.properties:
         /** Get value of ${p.name} */
         virtual ${p.cppTypeParam(interface.name)} ${p.camelCase}() const;
+        /** Set value of ${p.name} with option to skip sending signal */
+        virtual ${p.cppTypeParam(interface.name)} \
+${p.camelCase}(${p.cppTypeParam(interface.name)} value,
+               bool skipSignal);
         /** Set value of ${p.name} */
         virtual ${p.cppTypeParam(interface.name)} \
 ${p.camelCase}(${p.cppTypeParam(interface.name)} value);
@@ -91,7 +96,8 @@
          *  @param[in] val - A variant containing the value to set.
          */
         void setPropertyByName(const std::string& _name,
-                               const PropertiesVariant& val);
+                               const PropertiesVariant& val,
+                               bool skipSignal = false);
 
         /** @brief Gets a property by name.
          *  @param[in] _name - A string representation of the property name.
diff --git a/tools/sdbusplus/templates/property.mako.prototype.hpp.in b/tools/sdbusplus/templates/property.mako.prototype.hpp.in
index 163f6e9..0322554 100644
--- a/tools/sdbusplus/templates/property.mako.prototype.hpp.in
+++ b/tools/sdbusplus/templates/property.mako.prototype.hpp.in
@@ -68,18 +68,27 @@
     return true;
 }
 
-auto ${classname}::${property.camelCase}(${property.cppTypeParam(interface.name)} value) ->
+auto ${classname}::${property.camelCase}(${property.cppTypeParam(interface.name)} value,
+                                         bool skipSignal) ->
         ${property.cppTypeParam(interface.name)}
 {
     if (_${property.camelCase} != value)
     {
         _${property.camelCase} = value;
-        _${interface_instance()}.property_changed("${property.name}");
+        if (!skipSignal)
+        {
+            _${interface_instance()}.property_changed("${property.name}");
+        }
     }
 
     return _${property.camelCase};
 }
 
+auto ${classname}::${property.camelCase}(${property.cppTypeParam(interface.name)} val) ->
+        ${property.cppTypeParam(interface.name)}
+{
+    return ${property.camelCase}(val, false);
+}
 int ${classname}::_callback_set_${property.name}(
         sd_bus* bus, const char* path, const char* interface,
         const char* property, sd_bus_message* value, void* context,