diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2019-10-01 13:14:30 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2019-10-01 13:14:30 +0900 |
commit | f71d16b56ab90e494d6a41c276210a4ce593987e (patch) | |
tree | 72a029da3aea15952c673c1bc15a44f29f6e51b2 /lib/room.h | |
parent | d0a0f8cda88d644ca38b2b90024303fbe362602c (diff) | |
download | libquotient-f71d16b56ab90e494d6a41c276210a4ce593987e.tar.gz libquotient-f71d16b56ab90e494d6a41c276210a4ce593987e.zip |
Room::getCurrentState()
Diffstat (limited to 'lib/room.h')
-rw-r--r-- | lib/room.h | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -434,6 +434,24 @@ public: Q_INVOKABLE bool supportsCalls() const; + /// Get a state event with the given event type and state key + /*! This method returns a (potentially empty) state event corresponding + * to the pair of event type \p evtType and state key \p stateKey. + */ + Q_INVOKABLE const StateEventBase* + getCurrentState(const QString& evtType, const QString& stateKey = {}) const; + + template <typename EvT> + const EvT* getCurrentState(const QString& stateKey = {}) const + { + const auto* evt = + eventCast<const EvT>(getCurrentState(EvT::matrixTypeId(), stateKey)); + Q_ASSERT(evt); + Q_ASSERT(evt->matrixTypeId() == EvT::matrixTypeId() + && evt->stateKey() == stateKey); + return evt; + } + template <typename EvT, typename... ArgTs> auto setState(ArgTs&&... args) const { |