From 1e273212eca1dfa294d1a4bb9271261bf5671aa3 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Mon, 11 Feb 2019 08:05:31 +0900 Subject: SimpleContent: don't derive from Base as it gives zero added value Originally there was an idea to make a common base class for all event content. Aside from really trivial unification of toJson() this doesn't span across various types of events, and since state events use static, rather than dynamic, polymorphism (StateEvent<> is a template with the aggregated content vs. RoomMessageEvent with the aggregated pointer-to-content-base), there's no considerable value in using the base class. If state events start using the same approach as message events, this may be brought back but not until then. --- lib/events/simplestateevents.h | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'lib') diff --git a/lib/events/simplestateevents.h b/lib/events/simplestateevents.h index 5aa24c15..2c23d9ca 100644 --- a/lib/events/simplestateevents.h +++ b/lib/events/simplestateevents.h @@ -19,7 +19,6 @@ #pragma once #include "stateevent.h" -#include "eventcontent.h" #include "converters.h" @@ -28,7 +27,7 @@ namespace QMatrixClient namespace EventContent { template - class SimpleContent: public Base + class SimpleContent { public: using value_type = T; @@ -39,23 +38,19 @@ namespace QMatrixClient : value(std::forward(value)), key(std::move(keyName)) { } SimpleContent(const QJsonObject& json, QString keyName) - : Base(json) - , value(QMatrixClient::fromJson(json[keyName])) + : value(fromJson(json[keyName])) , key(std::move(keyName)) { } + QJsonObject toJson() const + { + return { { key, QMatrixClient::toJson(value) } }; + } public: T value; protected: QString key; - - private: - void fillJson(QJsonObject* json) const override - { - Q_ASSERT(json); - json->insert(key, QMatrixClient::toJson(value)); - } }; } // namespace EventContent -- cgit v1.2.3