xref: /openbmc/phosphor-dbus-monitor/src/templates/generated.mako.hpp (revision 13fd8722e616dd424cd585187fb0ef65f6316023)
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 "propertywatchimpl.hpp"
9 #include "sdbusplus.hpp"
10 
11 using namespace std::string_literals;
12 
13 namespace phosphor
14 {
15 namespace dbus
16 {
17 namespace monitoring
18 {
19 
20 struct ConfigMeta
21 {
22     using Meta = std::array<std::string, ${len(meta)}>;
23 
24     static auto& get()
25     {
26         static const Meta meta =
27         {
28 % for m in meta:
29             "${m.name}"s,
30 % endfor
31         };
32         return meta;
33     }
34 };
35 
36 struct ConfigPaths
37 {
38     using Paths = std::array<std::string, ${len(paths)}>;
39 
40     static auto& get()
41     {
42         static const Paths paths =
43         {
44 % for p in paths:
45             "${p.name}"s,
46 % endfor
47         };
48         return paths;
49     }
50 };
51 
52 struct ConfigInterfaces
53 {
54     using Interfaces = std::array<std::string, ${len(interfaces)}>;
55 
56     static auto& get()
57     {
58         static const Interfaces interfaces =
59         {
60 % for i in interfaces:
61             "${i.name}"s,
62 % endfor
63         };
64         return interfaces;
65     }
66 };
67 
68 struct ConfigProperties
69 {
70     using Properties = std::array<std::string, ${len(propertynames)}>;
71 
72     static auto& get()
73     {
74         static const Properties properties =
75         {
76 % for p in propertynames:
77             "${p.name}"s,
78 % endfor
79         };
80         return properties;
81     }
82 };
83 
84 struct ConfigPropertyStorage
85 {
86     using Storage = std::array<any_ns::any, ${len(instances)}>;
87 
88     static auto& get()
89     {
90         static Storage storage;
91         return storage;
92     }
93 };
94 
95 struct ConfigPropertyIndicies
96 {
97     using PropertyIndicies = std::array<PropertyIndex, ${len(instancegroups)}>;
98 
99     static auto& get()
100     {
101         static const PropertyIndicies propertyIndicies =
102         {
103             {
104 % for g in instancegroups:
105                 {
106     % for i in g.members:
107                     {
108                         PropertyIndex::key_type
109                         {
110                             ConfigPaths::get()[${i[0]}],
111                             ConfigInterfaces::get()[${i[2]}],
112                             ConfigProperties::get()[${i[3]}]
113                         },
114                         PropertyIndex::mapped_type
115                         {
116                             ConfigMeta::get()[${i[1]}],
117                             ConfigMeta::get()[${i[4]}],
118                             ConfigPropertyStorage::get()[${i[5]}]
119                         },
120                     },
121     % endfor
122                 },
123 % endfor
124             }
125         };
126         return propertyIndicies;
127     }
128 };
129 
130 struct ConfigPropertyWatches
131 {
132     using PropertyWatches = std::array<std::unique_ptr<Watch>, ${len(watches)}>;
133 
134     static auto& get()
135     {
136         static const PropertyWatches propertyWatches =
137         {
138 % for w in watches:
139             std::make_unique<PropertyWatchOfType<${w.datatype}, SDBusPlus>>(
140                 ConfigPropertyIndicies::get()[${w.instances}]),
141 % endfor
142         };
143         return propertyWatches;
144     }
145 };
146 } // namespace monitoring
147 } // namespace dbus
148 } // namespace phosphor
149