presence: New parser
Adopt an easy on the tongue acronym similar to other projects.
Add a robust parser with support for sensors and policies.
Sensors: gpio, tach
Policies: fallback
Add an example yaml file.
Change-Id: I9158a0ce2a08ef6b7bb3f5d659ea0e0433af5b96
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/presence/templates/generated.mako.hpp b/presence/templates/generated.mako.hpp
new file mode 100644
index 0000000..3afd29f
--- /dev/null
+++ b/presence/templates/generated.mako.hpp
@@ -0,0 +1,78 @@
+## This file is a template, the comment below is emitted into the generated file
+/* This is an auto generated file. Do not edit. */
+#pragma once
+
+#include <array>
+#include <memory>
+#include <string>
+#include "fallback.hpp"
+#include "fan.hpp"
+#include "gpio.hpp"
+#include "tach.hpp"
+
+using namespace std::string_literals;
+
+namespace phosphor
+{
+namespace fan
+{
+namespace presence
+{
+
+struct ConfigPolicy;
+
+struct ConfigSensors
+{
+ using Sensors = std::array<std::unique_ptr<PresenceSensor>, ${len(sensors)}>;
+
+ static auto& get()
+ {
+ static const Sensors sensors =
+ {
+% for s in sensors:
+ ${s.construct(loader, indent=indent +3)},
+% endfor
+ };
+ return sensors;
+ }
+};
+
+struct ConfigFans
+{
+ using Fans = std::array<Fan, ${len(fans)}>;
+
+ static auto& get()
+ {
+ static const Fans fans =
+ {
+ {
+% for f in fans:
+ Fans::value_type{
+ "${f.name}"s,
+ "${f.path}"s,
+ },
+% endfor
+ }
+ };
+ return fans;
+ }
+};
+
+struct ConfigPolicy
+{
+ using Policies = std::array<std::unique_ptr<RedundancyPolicy>, ${len(policies)}>;
+
+ static auto& get()
+ {
+ static const Policies policies =
+ {
+% for p in policies:
+ ${p.construct(loader, indent=indent +3)},
+% endfor
+ };
+ return policies;
+ }
+};
+} // namespace presence
+} // namespace fan
+} // namespace phosphor