sdbus++: common: move PropertiesVariant from server
PropertiesVariant is currently useful outside of the server constructor,
such as cases where someone wants to create a signal match against
the PropertiesChanged signal. Move it to common since we don't have a
better solution for signals presently.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I7ce53a8c796fac0713ac42fe29e364bf9b2e745c
diff --git a/tools/sdbusplus/templates/interface.common.hpp.mako b/tools/sdbusplus/templates/interface.common.hpp.mako
index d64090d..50893ca 100644
--- a/tools/sdbusplus/templates/interface.common.hpp.mako
+++ b/tools/sdbusplus/templates/interface.common.hpp.mako
@@ -8,6 +8,12 @@
#include <sdbusplus/exception.hpp>
#include <sdbusplus/message.hpp>
+#include <sdbusplus/utility/dedup_variant.hpp>
+<%
+ def setOfPropertyTypes():
+ return set(p.cppTypeParam(interface.name) for p in
+ interface.properties);
+%>\
namespace sdbusplus::common::${interface.cppNamespace()}
{
@@ -25,6 +31,11 @@
};
% endfor
+ % if interface.properties:
+ using PropertiesVariant = sdbusplus::utility::dedup_variant_t<
+ ${",\n ".join(sorted(setOfPropertyTypes()))}>;
+ % endif \
+
% for p in interface.paths:
% if p.description:
/** ${p.description.strip()} */
diff --git a/tools/sdbusplus/templates/interface.server.hpp.mako b/tools/sdbusplus/templates/interface.server.hpp.mako
index 2d807fb..5d203c5 100644
--- a/tools/sdbusplus/templates/interface.server.hpp.mako
+++ b/tools/sdbusplus/templates/interface.server.hpp.mako
@@ -3,19 +3,13 @@
#include <map>
#include <sdbusplus/sdbus.hpp>
#include <sdbusplus/server.hpp>
-#include <sdbusplus/utility/dedup_variant.hpp>
#include <string>
#include <systemd/sd-bus.h>
% for h in interface.cpp_includes():
#include <${h}>
% endfor
-#include <${interface.headerFile()}> \
-<%
- def setOfPropertyTypes():
- return set(p.cppTypeParam(interface.name) for p in
- interface.properties);
-%>
+#include <${interface.headerFile()}>
namespace sdbusplus::server::${interface.cppNamespace()}
{
@@ -50,8 +44,6 @@
_sdbusplus_bus(bus) {}
% if interface.properties:
- using PropertiesVariant = sdbusplus::utility::dedup_variant_t<
- ${",\n ".join(sorted(setOfPropertyTypes()))}>;
/** @brief Constructor to initialize the object from a map of
* properties.
*