xref: /openbmc/phosphor-dbus-monitor/src/templates/generated.mako.hpp (revision 731171a12c6d52ead2d93303867b6d731d4d6728)
1 ## This file is a template, the comment below is emitted into the generated file
2 /* This is an auto generated file. Do not edit. */
3 #pragma once
4 
5 #include <array>
6 #include <string>
7 #include "data_types.hpp"
8 #include "journal.hpp"
9 #include "propertywatchimpl.hpp"
10 #include "sdbusplus.hpp"
11 
12 using namespace std::string_literals;
13 
14 namespace phosphor
15 {
16 namespace dbus
17 {
18 namespace monitoring
19 {
20 
21 struct ConfigMeta
22 {
23     using Meta = std::array<std::string, ${len(meta)}>;
24 
25     static auto& get()
26     {
27         static const Meta meta =
28         {
29 % for m in meta:
30             "${m.name}"s,
31 % endfor
32         };
33         return meta;
34     }
35 };
36 
37 struct ConfigPaths
38 {
39     using Paths = std::array<std::string, ${len(paths)}>;
40 
41     static auto& get()
42     {
43         static const Paths paths =
44         {
45 % for p in paths:
46             "${p.name}"s,
47 % endfor
48         };
49         return paths;
50     }
51 };
52 
53 struct ConfigInterfaces
54 {
55     using Interfaces = std::array<std::string, ${len(interfaces)}>;
56 
57     static auto& get()
58     {
59         static const Interfaces interfaces =
60         {
61 % for i in interfaces:
62             "${i.name}"s,
63 % endfor
64         };
65         return interfaces;
66     }
67 };
68 
69 struct ConfigProperties
70 {
71     using Properties = std::array<std::string, ${len(propertynames)}>;
72 
73     static auto& get()
74     {
75         static const Properties properties =
76         {
77 % for p in propertynames:
78             "${p.name}"s,
79 % endfor
80         };
81         return properties;
82     }
83 };
84 
85 struct ConfigPropertyStorage
86 {
87     using Storage = std::array<any_ns::any, ${len(instances)}>;
88 
89     static auto& get()
90     {
91         static Storage storage;
92         return storage;
93     }
94 };
95 
96 struct ConfigPropertyIndicies
97 {
98     using PropertyIndicies = std::array<PropertyIndex, ${len(instancegroups)}>;
99 
100     static auto& get()
101     {
102         static const PropertyIndicies propertyIndicies =
103         {
104             {
105 % for g in instancegroups:
106                 {
107     % for i in g.members:
108                     {
109                         PropertyIndex::key_type
110                         {
111                             std::cref(ConfigPaths::get()[${i[0]}]),
112                             std::cref(ConfigInterfaces::get()[${i[2]}]),
113                             std::cref(ConfigProperties::get()[${i[3]}])
114                         },
115                         PropertyIndex::mapped_type
116                         {
117                             std::cref(ConfigMeta::get()[${i[1]}]),
118                             std::cref(ConfigMeta::get()[${i[4]}]),
119                             std::ref(ConfigPropertyStorage::get()[${i[5]}])
120                         },
121                     },
122     % endfor
123                 },
124 % endfor
125             }
126         };
127         return propertyIndicies;
128     }
129 };
130 
131 struct ConfigPropertyCallbackGroups
132 {
133     using CallbackGroups = std::array<std::vector<size_t>, ${len(callbackgroups)}>;
134     static auto& get()
135     {
136         static const CallbackGroups propertyCallbackGraph =
137         {
138             {
139 % for g in callbackgroups:
140                 {${', '.join([str(x) for x in g.members])}},
141 % endfor
142             }
143         };
144         return propertyCallbackGraph;
145     }
146 };
147 
148 struct ConfigPropertyCallbacks
149 {
150     using Callbacks = std::array<std::unique_ptr<Callback>, ${len(callbacks)}>;
151 
152     static auto& get()
153     {
154         static const Callbacks propertyCallbacks =
155         {
156 % for c in callbacks:
157             ${c.construct(loader, indent=indent +3)},
158 % endfor
159         };
160         return propertyCallbacks;
161     }
162 };
163 
164 struct ConfigPropertyWatches
165 {
166     using PropertyWatches = std::array<std::unique_ptr<Watch>, ${len(watches)}>;
167 
168     static auto& get()
169     {
170         static const PropertyWatches propertyWatches =
171         {
172 % for w in watches:
173             std::make_unique<PropertyWatchOfType<${w.datatype}, SDBusPlus>>(
174                 ConfigPropertyIndicies::get()[${w.instances}]),
175 % endfor
176         };
177         return propertyWatches;
178     }
179 };
180 } // namespace monitoring
181 } // namespace dbus
182 } // namespace phosphor
183