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 <chrono>
7 #include <string>
8 #include "count.hpp"
9 #include "median.hpp"
10 #include "data_types.hpp"
11 #include "journal.hpp"
12 #include "elog.hpp"
13 #include "errors.hpp"
14 #include "method.hpp"
15 #include "propertywatchimpl.hpp"
16 #include "pathwatchimpl.hpp"
17 #include "resolve_errors.hpp"
18 #include "sdbusplus.hpp"
19 #include "event.hpp"
20 #include "snmp_trap.hpp"
21 
22 using namespace std::string_literals;
23 using namespace std::chrono_literals;
24 
25 namespace phosphor
26 {
27 namespace dbus
28 {
29 namespace monitoring
30 {
31 
32 struct ConfigMeta
33 {
34     using Meta = std::array<std::string, ${len(meta)}>;
35 
36     static auto& get()
37     {
38         static const Meta meta =
39         {
40 % for m in meta:
41             "${m.name}"s,
42 % endfor
43         };
44         return meta;
45     }
46 };
47 
48 struct ConfigPaths
49 {
50     using Paths = std::array<std::string, ${len(paths)}>;
51 
52     static auto& get()
53     {
54         static const Paths paths =
55         {
56 % for p in paths:
57             "${p.name}"s,
58 % endfor
59         };
60         return paths;
61     }
62 };
63 
64 struct ConfigInterfaces
65 {
66     using Interfaces = std::array<std::string, ${len(interfaces)}>;
67 
68     static auto& get()
69     {
70         static const Interfaces interfaces =
71         {
72 % for i in interfaces:
73             "${i.name}"s,
74 % endfor
75         };
76         return interfaces;
77     }
78 };
79 
80 struct ConfigIntfAddPaths
81 {
82     using Paths = std::array<std::string, ${len(pathinstances)}>;
83 
84     static auto& get()
85     {
86         static const Paths paths =
87         {
88 % for p in pathinstances:
89             "${p.path}"s,
90 % endfor
91         };
92         return paths;
93     }
94 };
95 
96 struct ConfigProperties
97 {
98     using Properties = std::array<std::string, ${len(propertynames)}>;
99 
100     static auto& get()
101     {
102         static const Properties properties =
103         {
104 % for p in propertynames:
105             "${p.name}"s,
106 % endfor
107         };
108         return properties;
109     }
110 };
111 
112 struct ConfigPropertyStorage
113 {
114     using Storage = std::array<std::tuple<any_ns::any, any_ns::any>, ${len(instances)}>;
115 
116     static auto& get()
117     {
118         static Storage storage;
119         return storage;
120     }
121 };
122 
123 struct ConfigPropertyFilters
124 {
125     using PropertyFilters = std::array<std::unique_ptr<Filters>, ${len(filters)}>;
126 
127     static auto& get()
128     {
129         static const PropertyFilters propertyFilters =
130         {
131 % for f in filters:
132             std::make_unique<OperandFilters<${f.datatype}>>(
133                 std::vector<std::function<bool(${f.datatype})>>{
134     % for o in f.filters:
135                     [](const auto& val){
136                         return val ${o.op} ${o.argument(loader, indent=indent +1)};
137                     },
138     % endfor
139                 }
140             ),
141 % endfor
142         };
143         return propertyFilters;
144     }
145 };
146 
147 struct ConfigPropertyIndicies
148 {
149     using PropertyIndicies = std::array<PropertyIndex, ${len(instancegroups)}>;
150 
151     static auto& get()
152     {
153         static const PropertyIndicies propertyIndicies =
154         {
155             {
156 % for g in instancegroups:
157                 {
158     % for i in g.members:
159                     {
160                         PropertyIndex::key_type
161                         {
162                             ConfigPaths::get()[${i[0]}],
163                             ConfigInterfaces::get()[${i[2]}],
164                             ConfigProperties::get()[${i[3]}]
165                         },
166                         PropertyIndex::mapped_type
167                         {
168                             ConfigMeta::get()[${i[1]}],
169                             ConfigMeta::get()[${i[4]}],
170                             ConfigPropertyStorage::get()[${i[5]}]
171                         },
172                     },
173     % endfor
174                 },
175 % endfor
176             }
177         };
178         return propertyIndicies;
179     }
180 };
181 
182 struct ConfigPropertyCallbackGroups
183 {
184     using CallbackGroups = std::array<std::vector<size_t>, ${len(callbackgroups)}>;
185     static auto& get()
186     {
187         static const CallbackGroups propertyCallbackGraph =
188         {
189             {
190 % for g in callbackgroups:
191                 {${', '.join([str(x) for x in g.members])}},
192 % endfor
193             }
194         };
195         return propertyCallbackGraph;
196     }
197 };
198 
199 struct ConfigConditions
200 {
201     using Conditions = std::array<std::unique_ptr<Conditional>, ${len(conditions)}>;
202 
203     static auto& get()
204     {
205         static const Conditions propertyConditions =
206         {
207 % for c in conditions:
208             ${c.construct(loader, indent=indent +3)},
209 % endfor
210         };
211         return propertyConditions;
212     }
213 };
214 
215 struct ConfigPropertyCallbacks
216 {
217     using Callbacks = std::array<std::unique_ptr<Callback>, ${len(callbacks)}>;
218 
219     static auto& get()
220     {
221         static const Callbacks propertyCallbacks =
222         {
223 % for c in callbacks:
224             ${c.construct(loader, indent=indent +3)},
225 % endfor
226         };
227         return propertyCallbacks;
228     }
229 };
230 
231 struct ConfigPathCallbacks
232 {
233     using Callbacks = std::array<std::unique_ptr<Callback>, ${len(pathcallbacks)}>;
234 
235     static auto& get()
236     {
237         static const Callbacks pathCallbacks =
238         {
239 % for c in pathcallbacks:
240             ${c.construct(loader, indent=indent +3)},
241 % endfor
242         };
243         return pathCallbacks;
244     }
245 };
246 
247 struct ConfigPropertyWatches
248 {
249     using PropertyWatches = std::array<std::unique_ptr<Watch>, ${len(watches)}>;
250 
251     static auto& get()
252     {
253         static const PropertyWatches propertyWatches =
254         {
255 % for w in watches:
256             std::make_unique<PropertyWatchOfType<${w.datatype}, SDBusPlus>>(
257     % if w.callback is None:
258         % if w.filters is None:
259                 ConfigPropertyIndicies::get()[${w.instances}]),
260         % else:
261                 ConfigPropertyIndicies::get()[${w.instances}],
262                 ConfigPropertyFilters::get()[${w.filters}].get()),
263         % endif
264     % else:
265         % if w.filters is None:
266                 ConfigPropertyIndicies::get()[${w.instances}],
267                 *ConfigPropertyCallbacks::get()[${w.callback}]),
268         % else:
269                 ConfigPropertyIndicies::get()[${w.instances}],
270                 *ConfigPropertyCallbacks::get()[${w.callback}],
271                 ConfigPropertyFilters::get()[${w.filters}].get()),
272         % endif
273     % endif
274 % endfor
275         };
276         return propertyWatches;
277     }
278 };
279 
280 struct ConfigPathWatches
281 {
282     using PathWatches = std::array<std::unique_ptr<Watch>, ${len(pathwatches)}>;
283 
284     static auto& get()
285     {
286         static const PathWatches pathWatches =
287         {
288 % for w in pathwatches:
289             std::make_unique<PathWatch<SDBusPlus>>(
290     % if w.pathcallback is None:
291                 ConfigIntfAddPaths::get()[${w.pathinstances}]),
292     % else:
293                 ConfigIntfAddPaths::get()[${w.pathinstances}],
294                 *ConfigPathCallbacks::get()[${w.pathcallback}]),
295     % endif
296 % endfor
297         };
298         return pathWatches;
299     }
300 };
301 } // namespace monitoring
302 } // namespace dbus
303 } // namespace phosphor
304