Use full name for enum default values

In the case where there were multiple interfaces specified in the
settings YAML that had the same last segment, the code generator would
create unbuildable code when those classes both specified default values
for properties that were enums.  This happened because there was a
'using namespace ...' line for every class at global scope, so when
the default value for the enum was specified, the compiler wouldn't know
which class to use.

For example, if there were two interfaces that used a class called Mode
that each tried to set default values like:
 * Mode::bootMode::Safe
 * Mode::powerMode::Static
then the generated code wouldn't compile.

Fix this by removing the global using namespace lines and add the full
prefix to the enum default values when they are set in the initSetting
lambdas.

Note that the code still won't compile when classes of the same name are
used on the same object path.  This is because of the 'using IfaceX'
lines in the scope of each Impl class.  Fixing that is outside of the
scope of this commit, which was done to fix a real world use.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I25ac36a58febe4449a29af845e5faba12bb0e63f
diff --git a/settings_example.yaml b/settings_example.yaml
index e285953..d76b4c7 100644
--- a/settings_example.yaml
+++ b/settings_example.yaml
@@ -41,3 +41,10 @@
                   Unit: "Watts"
           PowerCapEnable:
                Default: 'false'
+
+# This interface also ends in Mode and sets an enum.
+/xyz/openbmc_project/control/power_mode:
+    - Interface: xyz.openbmc_project.Control.Power.Mode
+      Properties:
+          PowerMode:
+              Default: Mode::PowerMode::Static
diff --git a/settings_manager.mako.hpp b/settings_manager.mako.hpp
index c0dac66..d22fd2d 100644
--- a/settings_manager.mako.hpp
+++ b/settings_manager.mako.hpp
@@ -6,7 +6,6 @@
 from collections import defaultdict
 from sdbusplus.namedelement import NamedElement
 objects = settingsDict.keys()
-sdbusplus_namespaces = []
 sdbusplus_includes = []
 props = defaultdict(list)
 validators = defaultdict(tuple)
@@ -51,17 +50,6 @@
 #include "${i}"
 % endfor
 
-% for object in objects:
-    % for item in settingsDict[object]:
-<%
-    ns = get_setting_sdbusplus_type(item['Interface'])
-    i = ns.rfind('::')
-    ns = ns[:i]
-    sdbusplus_namespaces.append(ns)
-%>\
-    % endfor
-% endfor
-
 namespace phosphor
 {
 namespace settings
@@ -84,10 +72,6 @@
 
 }
 
-% for n in set(sdbusplus_namespaces):
-using namespace ${n};
-% endfor
-
 % for object in objects:
 <%
    ns = object.split('/')
@@ -308,6 +292,13 @@
     % for propName, metaDict in item['Properties'].items():
 <% p = NamedElement(name=propName).camelCase %>\
 <% defaultValue = metaDict['Default'] %>\
+% if isinstance(defaultValue, str) and  not \
+    defaultValue.startswith('"') and '::' in defaultValue:
+<% ns = get_setting_sdbusplus_type(item['Interface'])
+i = ns.rfind('::')
+defaultValue = "{}::{}".format(ns[:i], defaultValue)
+%>\
+% endif
                 std::get<${index}>(settings)->
                   ${get_setting_sdbusplus_type(item['Interface'])}::${p}(${defaultValue});
   % endfor