expose DBus interface signal names as symbols

Enable a way to access the signal names of a given DBus interface as a
constexpr symbol via the header.

4 use-cases:

- printing error / debug logs with the signal name.
e.g. 'received signal ${SIGNAL_NAME}'

- matching on DBus signals in applications which do not yet use the PDI
generated bindings.

- preventing typos in DBus signal names

- estimating the impact of removing a given DBus signal from an
interface. When using these symbols, it would cause a build failure in
applications relying on the existence of that signal.

This change is similar to [1] and goes into the same direction.

Tested: Newly written unit test passes.

References:
[1] d2571922bfdb4f6b41ba4fbc45b8a4272793fd40

Change-Id: I9c20d744955c883302f349c5351dbdba1753466b
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
diff --git a/test/gen/test_signal_names.cpp b/test/gen/test_signal_names.cpp
new file mode 100644
index 0000000..be9bb12
--- /dev/null
+++ b/test/gen/test_signal_names.cpp
@@ -0,0 +1,47 @@
+#include "sdbusplus/asio/connection.hpp"
+#include "sdbusplus/bus/match.hpp"
+#include "server/Test2/common.hpp"
+
+#include <print>
+
+#include <gtest/gtest.h>
+
+void cb(sdbusplus::message_t& msg)
+{
+    // We can access the signal name as a symbol.
+    // The property name is constexpr.
+
+    constexpr auto sigName =
+        sdbusplus::common::server::Test2::signal_names::other_value_changed;
+
+    // The property name can be used as part of error logs.
+
+    std::println("signal {} received on path {}\n", sigName, msg.get_path());
+}
+
+int main()
+{
+    // If the signal is removed from the interface definition, it will cause a
+    // build failure in applications still using that signal. That can work
+    // even if the application is not (yet) using PDI-generated bindings for
+    // it's DBus interactions.
+
+    std::println(
+        "using signal {} \n",
+        sdbusplus::common::server::Test2::signal_names::other_value_changed);
+
+    EXPECT_EQ(
+        sdbusplus::common::server::Test2::signal_names::other_value_changed,
+        "OtherValueChanged");
+
+    boost::asio::io_context io;
+    sdbusplus::asio::connection conn(io);
+
+    std::string matchStr = std::format(
+        "type='signal',member={}",
+        sdbusplus::common::server::Test2::signal_names::other_value_changed);
+
+    auto match = sdbusplus::bus::match_t(conn, matchStr, cb);
+
+    return 0;
+}