summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/managed/Events.cpp16
-rw-r--r--src/core/managed/Events.hpp12
2 files changed, 28 insertions, 0 deletions
diff --git a/src/core/managed/Events.cpp b/src/core/managed/Events.cpp
index 6036e9d..0b1bad1 100644
--- a/src/core/managed/Events.cpp
+++ b/src/core/managed/Events.cpp
@@ -19,5 +19,21 @@
#include "Events.hpp"
namespace ousia {
+
+const char *EventHandlerDescriptor::getEventTypeName(EventType type)
+{
+ switch (type) {
+ case EventType::UPDATE:
+ return "update";
+ case EventType::NAME_CHANGE:
+ return "name_change";
+ case EventType::ADD_CHILD:
+ return "add_child";
+ case EventType::DELETE_CHILD:
+ return "delete_child";
+ }
+ return "";
+}
+
}
diff --git a/src/core/managed/Events.hpp b/src/core/managed/Events.hpp
index 177824c..768f0aa 100644
--- a/src/core/managed/Events.hpp
+++ b/src/core/managed/Events.hpp
@@ -173,6 +173,18 @@ struct EventHandlerDescriptor {
: type(type), handler(handler), owner(owner), data(data)
{
}
+
+ /**
+ * Returns a human readable name of the given event type.
+ */
+ static const char *getEventTypeName(EventType type);
+
+ /**
+ * Returns the name of the current event type.
+ */
+ const char *getEventTypeName() const {
+ return getEventTypeName(this->type);
+ }
};
}