diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-05-01 17:06:20 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-05-01 20:47:02 +0900 |
commit | b657cd22aa64f24f2e0f9f31ef8a5d4e38a26a3a (patch) | |
tree | 5878e26a3719ace45d49ee08ccb2a99057426d1d /lib/room.h | |
parent | 5c61bb08e3fe87591884e0440a85d64482500199 (diff) | |
download | libquotient-b657cd22aa64f24f2e0f9f31ef8a5d4e38a26a3a.tar.gz libquotient-b657cd22aa64f24f2e0f9f31ef8a5d4e38a26a3a.zip |
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.
Diffstat (limited to 'lib/room.h')
-rw-r--r-- | lib/room.h | 16 |
1 files changed, 9 insertions, 7 deletions
@@ -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 <typename EventT> + const EventT* viewAs() const { return weakPtr<const EventT>(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; |