blob: 2f9798583507a834c6903138d5e78712daa1e7db [file] [log] [blame]
Deepak Kodihalli5de09572017-05-16 23:53:40 -05001## This file is a template. The comment below is emitted
2## into the rendered file; feel free to edit this file.
3// WARNING: Generated header. Do not edit!
4
5<%
6objects = list(settingsDict.viewkeys())
7
8def get_setting_type(setting_intf):
9 setting = "sdbusplus::" + setting_intf.replace('.', '::')
10 i = setting.rfind('::')
11 setting = setting[:i] + '::server::' + setting[i+2:]
12 return setting
13%>\
14#pragma once
15
16% for object in objects:
17<%
18 includes = []
19 include = settingsDict[object]['Interface']
20 include = include.replace('.', '/')
21 include = include + "/server.hpp"
22 includes.append(include)
23%>\
24% endfor
25% for i in set(includes):
26#include "${i}"
27% endfor
28
29% for object in objects:
30<%
31 ns_list = []
32 ns = get_setting_type(settingsDict[object]['Interface'])
33 i = ns.rfind('::')
34 ns = ns[:i]
35 ns_list.append(ns)
36%>\
37% endfor
38% for n in set(ns_list):
39using namespace ${n};
40% endfor
41
42namespace phosphor
43{
44namespace settings
45{
46
47/** @class Manager
48 *
49 * @brief Compose settings objects and put them on the bus.
50 */
51class Manager
52{
53 public:
54 Manager() = delete;
55 Manager(const Manager&) = delete;
56 Manager& operator=(const Manager&) = delete;
57 Manager(Manager&&) = delete;
58 Manager& operator=(Manager&&) = delete;
59 virtual ~Manager() = default;
60
61 /** @brief Constructor to put settings objects on to the bus.
62 * @param[in] bus - Bus to attach to.
63 */
64 Manager(sdbusplus::bus::bus& bus)
65 {
66 settings =
67 std::make_tuple(
68% for index, object in enumerate(objects):
69<% type = get_setting_type(settingsDict[object]['Interface']) %>\
70 std::make_unique<${type}>(
71 bus,
72 % if index < len(settingsDict) - 1:
73 "${object}"),
74 % else:
75 "${object}"));
76 % endif
77% endfor
78
79% for index, object in enumerate(objects):
80 % if 'Defaults' in settingsDict[object].viewkeys():
81 % for property, value in settingsDict[object]['Defaults'].items():
82 std::get<${index}>(settings)->
83 setPropertyByName("${property}", ${value});
84 % endfor
85 % endif
86 bus.emit_object_added("${object}");
87
88% endfor
89 }
90
91 private:
92 /* @brief Composition of settings objects. */
93 std::tuple<
94% for index, object in enumerate(objects):
95<% type = get_setting_type(settingsDict[object]['Interface']) %>\
96 % if index < len(settingsDict) - 1:
97 std::unique_ptr<${type}>,
98 % else:
99 std::unique_ptr<${type}>> settings;
100 % endif
101% endfor
102};
103
104} // namespace settings
105} // namespace phosphor