From b657cd22aa64f24f2e0f9f31ef8a5d4e38a26a3a Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Tue, 1 May 2018 17:06:20 +0900 Subject: Event and Room: further abstract event pointers So that eventual switch from std::unique_ptr to some other pointer (as a case - QSharedPointer) would be as painless as possible. --- lib/room.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'lib/room.h') diff --git a/lib/room.h b/lib/room.h index 86a7b245..288db5fb 100644 --- a/lib/room.h +++ b/lib/room.h @@ -46,10 +46,12 @@ namespace QMatrixClient using index_t = int; TimelineItem(RoomEventPtr&& e, index_t number) - : evt(move(e)), idx(number) { } + : evt(std::move(e)), idx(number) { } - RoomEvent* event() const { return evt.get(); } - RoomEvent* operator->() const { return evt.operator->(); } + const RoomEvent* event() const { return rawPtr(evt); } + template + const EventT* viewAs() const { return weakPtr(evt); } + const RoomEventPtr& operator->() const { return evt; } index_t index() const { return idx; } // Used for event redaction @@ -407,12 +409,12 @@ namespace QMatrixClient protected: virtual void processStateEvents(const RoomEvents& events); - virtual void processEphemeralEvent(EventPtr event); - virtual void processAccountDataEvent(EventPtr event); + virtual void processEphemeralEvent(EventPtr&& event); + virtual void processAccountDataEvent(EventPtr&& event); virtual void onAddNewTimelineEvents(timeline_iter_t from) { } virtual void onAddHistoricalTimelineEvents(rev_iter_t from) { } - virtual void onRedaction(const RoomEvent* prevEvent, - const RoomEvent* after) { } + virtual void onRedaction(const RoomEvent& prevEvent, + const RoomEvent& after) { } private: class Private; -- cgit v1.2.3