Modify parser and add mako scripts for watch on object path
Added support for watch and callback on 'interface added'
signal for the specified object paths.
Added mako scripts for events to auto create callback
and watch objects for the specified object path groups.
Clients specify object paths to watch and callbacks to
invoke in the config.yaml file
Change-Id: I3fa2ea1520649120b927c0cb83a16e5cace2f24e
Signed-off-by: Marri Devender Rao <devenrao@in.ibm.com>
diff --git a/src/templates/generated.mako.hpp b/src/templates/generated.mako.hpp
index 1b73198..8dbaa20 100644
--- a/src/templates/generated.mako.hpp
+++ b/src/templates/generated.mako.hpp
@@ -12,9 +12,11 @@
#include "errors.hpp"
#include "method.hpp"
#include "propertywatchimpl.hpp"
+#include "pathwatchimpl.hpp"
#include "resolve_errors.hpp"
#include "sdbusplus.hpp"
#include "event.hpp"
+#include "snmp_trap.hpp"
#include "sdevent.hpp"
using namespace std::string_literals;
@@ -75,6 +77,22 @@
}
};
+struct ConfigIntfAddPaths
+{
+ using Paths = std::array<std::string, ${len(pathinstances)}>;
+
+ static auto& get()
+ {
+ static const Paths paths =
+ {
+% for p in pathinstances:
+ "${p.path}"s,
+% endfor
+ };
+ return paths;
+ }
+};
+
struct ConfigProperties
{
using Properties = std::array<std::string, ${len(propertynames)}>;
@@ -186,6 +204,22 @@
}
};
+struct ConfigPathCallbacks
+{
+ using Callbacks = std::array<std::unique_ptr<Callback>, ${len(pathcallbacks)}>;
+
+ static auto& get()
+ {
+ static const Callbacks pathCallbacks =
+ {
+% for c in pathcallbacks:
+ ${c.construct(loader, indent=indent +3)},
+% endfor
+ };
+ return pathCallbacks;
+ }
+};
+
struct ConfigPropertyWatches
{
using PropertyWatches = std::array<std::unique_ptr<Watch>, ${len(watches)}>;
@@ -207,6 +241,28 @@
return propertyWatches;
}
};
+
+struct ConfigPathWatches
+{
+ using PathWatches = std::array<std::unique_ptr<Watch>, ${len(pathwatches)}>;
+
+ static auto& get()
+ {
+ static const PathWatches pathWatches =
+ {
+% for w in pathwatches:
+ std::make_unique<PathWatch<SDBusPlus>>(
+ % if w.pathcallback is None:
+ ConfigIntfAddPaths::get()[${w.pathinstances}]),
+ % else:
+ ConfigIntfAddPaths::get()[${w.pathinstances}],
+ *ConfigPathCallbacks::get()[${w.pathcallback}]),
+ % endif
+% endfor
+ };
+ return pathWatches;
+ }
+};
} // namespace monitoring
} // namespace dbus
} // namespace phosphor