aboutsummaryrefslogtreecommitdiff
path: root/lib/events/event.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-07-02 13:39:33 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2018-07-04 20:12:34 +0900
commited467d27b07781fdd2f7ddef043568954ce50b69 (patch)
treea0782b0d87de8cbd851c6a008764dd6ae07836db /lib/events/event.cpp
parentbd853f392aaf5b05e0a8023da85a38e91d90a6e0 (diff)
downloadlibquotient-ed467d27b07781fdd2f7ddef043568954ce50b69.tar.gz
libquotient-ed467d27b07781fdd2f7ddef043568954ce50b69.zip
Events: use a template structure instead of template variables; rearrange code into blocks
A template member variable in it seemed to cause internal compiler error in MSVC 2017, let alone MSVC 2015...
Diffstat (limited to 'lib/events/event.cpp')
-rw-r--r--lib/events/event.cpp24
1 files changed, 8 insertions, 16 deletions
diff --git a/lib/events/event.cpp b/lib/events/event.cpp
index 3f507347..447068af 100644
--- a/lib/events/event.cpp
+++ b/lib/events/event.cpp
@@ -18,14 +18,6 @@
#include "event.h"
-#include "roommessageevent.h"
-#include "simplestateevents.h"
-#include "roommemberevent.h"
-#include "roomavatarevent.h"
-#include "typingevent.h"
-#include "receiptevent.h"
-#include "accountdataevents.h"
-#include "directchatevent.h"
#include "redactionevent.h"
#include "logging.h"
@@ -33,12 +25,6 @@
using namespace QMatrixClient;
-event_type_t EventTypeRegistry::nextTypeId()
-{
- static event_type_t typeIndex = unknownTypeId();
- return ++typeIndex;
-}
-
Event::Event(Type type, const QJsonObject& json)
: _type(type), _json(json)
{
@@ -77,7 +63,7 @@ const QJsonObject Event::unsignedJson() const
}
[[gnu::unused]] static auto roomEventTypeInitialised =
- EventTypeRegistry::chainFactories<Event, RoomEvent>();
+ Event::factory_t::chainFactory<RoomEvent>();
RoomEvent::RoomEvent(Type type, event_mtype_t matrixType,
const QJsonObject& contentJson)
@@ -134,10 +120,16 @@ void RoomEvent::addId(const QString& newId)
}
[[gnu::unused]] static auto stateEventTypeInitialised =
- EventTypeRegistry::chainFactories<RoomEvent, StateEventBase>();
+ RoomEvent::factory_t::chainFactory<StateEventBase>();
bool StateEventBase::repeatsState() const
{
const auto prevContentJson = unsignedJson().value(PrevContentKeyL);
return fullJson().value(ContentKeyL) == prevContentJson;
}
+
+event_type_t QMatrixClient::nextTypeId()
+{
+ static event_type_t _id = EventTypeTraits<void>::id;
+ return ++_id;
+}