setProperty: Allow multiple objects
Allow multiple objects when using the setProperty action.
Change-Id: Ie65b9abee6240d6a6541b9778d4bf776010f865d
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/actions.hpp b/actions.hpp
index 5b13a46..31932b2 100644
--- a/actions.hpp
+++ b/actions.hpp
@@ -64,7 +64,7 @@
* function that sets the property.
* @tparam V - The property value type.
*
- * @param[in] path - The DBus path on which the property should
+ * @param[in] paths - The DBus paths on which the property should
* be set.
* @param[in] iface - The DBus interface hosting the property.
* @param[in] member - Pointer to sdbusplus server binding member.
@@ -75,18 +75,21 @@
*/
template <typename T, typename U, typename V>
auto setProperty(
- const char* path, const char* iface,
+ std::vector<const char*>&& paths, const char* iface,
U&& member, V&& value)
{
// The manager is the only parameter passed to actions.
// Bind the path, interface, interface member function pointer,
// and value to a lambda. When it is called, forward the
// path, interface and value on to the manager member function.
- return [path, iface, member,
+ return [paths, iface, member,
value = std::forward<V>(value)](auto&, auto & m)
{
- m.template invokeMethod<T>(
- path, iface, member, value);
+ for (auto p : paths)
+ {
+ m.template invokeMethod<T>(
+ p, iface, member, value);
+ }
};
}
diff --git a/example/events.d/match1.yaml b/example/events.d/match1.yaml
index afc2974..7133271 100644
--- a/example/events.d/match1.yaml
+++ b/example/events.d/match1.yaml
@@ -25,7 +25,8 @@
- name: setProperty
interface: xyz.openbmc_project.Example.Iface1
property: ExampleProperty1
- path: /changeme
+ paths:
+ - /changeme
value:
type: string
value: changed
diff --git a/pimgen.py b/pimgen.py
index 226c5d8..be66bb0 100755
--- a/pimgen.py
+++ b/pimgen.py
@@ -306,7 +306,10 @@
member_type = cppTypeName(value['type'])
member_cast = '{0} ({1}::*)({0})'.format(member_type, t.qualified())
- args.append(TrivialArgument(value=kw.pop('path'), type='string'))
+ paths = [{'value': x, 'type': 'string'} for x in kw.pop('paths')]
+ args.append(InitializerList(
+ values=[TrivialArgument(**x) for x in paths]))
+
args.append(TrivialArgument(value=str(iface), type='string'))
args.append(TrivialArgument(
value=member, decorators=[Cast('static', member_cast)]))