diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-12-27 19:28:38 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-12-27 19:28:38 +0900 |
commit | 1dce783c4ac9ca37343648114885d332bdfe7fa1 (patch) | |
tree | 7d713b9b0ed1fed46a9719c3df6190c2cf21150c /events/event.h | |
parent | 00bd1be842f58b87633371a76587c103533baff5 (diff) | |
download | libquotient-1dce783c4ac9ca37343648114885d332bdfe7fa1.tar.gz libquotient-1dce783c4ac9ca37343648114885d332bdfe7fa1.zip |
Introduce StateEventBase - a non-template base for StateEvent<>
This will hold common logic for all state events, including the newly introduced repeatsState() that returns true when prev_content repeats content. This will be used to address QMatrixClient/Quaternion#245.
Diffstat (limited to 'events/event.h')
-rw-r--r-- | events/event.h | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/events/event.h b/events/event.h index 00dc4d5c..319c3443 100644 --- a/events/event.h +++ b/events/event.h @@ -240,8 +240,23 @@ namespace QMatrixClient RoomEvents::iterator end() { return to; } }; + class StateEventBase: public RoomEvent + { + public: + explicit StateEventBase(Type type, const QJsonObject& obj) + : RoomEvent(obj.contains("state_key") ? type : Type::Unknown, + obj) + { } + explicit StateEventBase(Type type) + : RoomEvent(type) + { } + ~StateEventBase() override = 0; + + virtual bool repeatsState() const; + }; + template <typename ContentT> - class StateEvent: public RoomEvent + class StateEvent: public StateEventBase { public: using content_type = ContentT; @@ -249,8 +264,7 @@ namespace QMatrixClient template <typename... ContentParamTs> explicit StateEvent(Type type, const QJsonObject& obj, ContentParamTs&&... contentParams) - : RoomEvent(obj.contains("state_key") ? type : Type::Unknown, - obj) + : StateEventBase(type, obj) , _content(contentJson(), std::forward<ContentParamTs>(contentParams)...) { @@ -262,7 +276,7 @@ namespace QMatrixClient } template <typename... ContentParamTs> explicit StateEvent(Type type, ContentParamTs&&... contentParams) - : RoomEvent(type) + : StateEventBase(type) , _content(std::forward<ContentParamTs>(contentParams)...) { } |