aboutsummaryrefslogtreecommitdiff
path: root/lib/events/event.cpp
diff options
context:
space:
mode:
authorAlexey Rusakov <Kitsune-Ral@users.sf.net>2021-12-28 21:34:03 +0100
committerAlexey Rusakov <Kitsune-Ral@users.sf.net>2021-12-29 18:17:51 +0100
commit27bb7ba696ae803c6a6903f85fe14074b23b7bcc (patch)
tree66ffc7615b80c5c70992f82aa5daa69c4e618456 /lib/events/event.cpp
parentac7ee73cb4fa1ac05f7bcae1800cb79b36c7647f (diff)
downloadlibquotient-27bb7ba696ae803c6a6903f85fe14074b23b7bcc.tar.gz
libquotient-27bb7ba696ae803c6a6903f85fe14074b23b7bcc.zip
Use QLatin1String for event typeId's
Before all, this fixes the problem with double-initialising of type ids; it could have been fixed with a smaller change but EventTypeRegistry is fairly superfluous now when inline variables are a thing and it's possible to have an extensible registry system using literally pointers to the memory that are guaranteed to be unique. That being said, event_type_t is still QLatin1String and not a bare const char* (or void*), mostly to stay on the safe side when it comes to type identities: unlike const char*, QLatin1String's are deep-compared, meaning that matching for switchOnType (former visit) occurs a bit slower now. This may change in the future; but this is the first step in getting rid of EventTypeRegistry. This change means that initializeTypeId is no more needed; also, two static member functions, typeId() and matrixTypeId(), are being replaced with a single inline static member variable, TypeId. This commit doesn't apply that transition across the event types, meaning that you'll get a pile of warnings when compiling the library. These warnings will be tackled in further commits within this branch.
Diffstat (limited to 'lib/events/event.cpp')
-rw-r--r--lib/events/event.cpp22
1 files changed, 3 insertions, 19 deletions
diff --git a/lib/events/event.cpp b/lib/events/event.cpp
index 715e7da2..4c304a3c 100644
--- a/lib/events/event.cpp
+++ b/lib/events/event.cpp
@@ -9,28 +9,12 @@
using namespace Quotient;
-event_type_t EventTypeRegistry::initializeTypeId(event_mtype_t matrixTypeId)
-{
- const auto id = get().eventTypes.size();
- get().eventTypes.push_back(matrixTypeId);
- if (strncmp(matrixTypeId, "", 1) == 0)
- qDebug(EVENTS) << "Initialized unknown event type with id" << id;
- else
- qDebug(EVENTS) << "Initialized event type" << matrixTypeId << "with id"
- << id;
- return id;
-}
-
-QString EventTypeRegistry::getMatrixType(event_type_t typeId)
-{
- return typeId < get().eventTypes.size() ? get().eventTypes[typeId]
- : QString();
-}
+QString EventTypeRegistry::getMatrixType(event_type_t typeId) { return typeId; }
-void _impl::EventFactoryBase::logAddingMethod(event_mtype_t matrixType,
+void _impl::EventFactoryBase::logAddingMethod(event_type_t TypeId,
size_t newSize)
{
- qDebug(EVENTS) << "Adding factory method for" << matrixType << "events;"
+ qDebug(EVENTS) << "Adding factory method for" << TypeId << "events;"
<< newSize << "methods will be in the" << name
<< "chain";
}