aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-07-08 09:08:02 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2018-07-08 09:08:02 +0900
commit97acdeeb4249bf4b8660425d080de4499266895b (patch)
tree859347d7ea4dca1b2c39c9137546de71f4cdd1e2 /lib
parentc0c1f47926cb01ddcfe9ed6556af2623d462b770 (diff)
downloadlibquotient-97acdeeb4249bf4b8660425d080de4499266895b.tar.gz
libquotient-97acdeeb4249bf4b8660425d080de4499266895b.zip
TimelineItem: get(); validating viewAs<>()
Having get() allows to work with TimelineItem as a smart pointer.
Diffstat (limited to 'lib')
-rw-r--r--lib/room.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/room.h b/lib/room.h
index 975e6caf..7216d625 100644
--- a/lib/room.h
+++ b/lib/room.h
@@ -54,8 +54,9 @@ namespace QMatrixClient
}
const RoomEvent* event() const { return rawPtr(evt); }
+ const RoomEvent* get() const { return event(); }
template <typename EventT>
- const EventT* viewAs() const { return weakPtrCast<const EventT>(evt); }
+ const EventT* viewAs() const { return eventCast<const EventT*>(evt); }
const RoomEventPtr& operator->() const { return evt; }
const RoomEvent& operator*() const { return *evt; }
index_t index() const { return idx; }
@@ -67,6 +68,14 @@ namespace QMatrixClient
RoomEventPtr evt;
index_t idx;
};
+
+ template<>
+ inline const StateEventBase* TimelineItem::viewAs<StateEventBase>() const
+ {
+ return evt->isStateEvent() ? weakPtrCast<const StateEventBase>(evt)
+ : nullptr;
+ }
+
inline QDebug& operator<<(QDebug& d, const TimelineItem& ti)
{
QDebugStateSaver dss(d);