Age | Commit message (Collapse) | Author |
|
Now that StateEvent name is vacated, the naming for event core classes
can be completely unified: Event, RoomEvent, CallEvent, StateEvent.
|
|
This gives a more conventional API compared to queryOr() that can be
used for event objects that have content() defined - with the downside
being that content() unpacks the entire object instead of retrieving
one particular piece (but for state events and single key-value content
it's not a problem, and those make for the vast majority of events).
|
|
This commit introduces a few things to further reduce the boilerplate
across event type definitions:
- Event type is no more separately stored in Event and therefore no more
passed to base event constructors. Until the previous commit, it was
used by is() to quickly match the event type; with the new event
metatype class, the same is achieved even quicker by comparing
metatype pointers.
- EventTemplate is a generalisation of StateEvent for all event types
providing common constructor signatures and content() for (most) leaf
event types. StateEvent therefore has become a partial specialisation
of EventTemplate for types derived from StateEventBase; as the known
client code base does not use it directly, a compatibility alias is
not provided. Also, DEFINE_SIMPLE_EVENT now expands into a class
deriving from EventTemplate.
- On top of StateEvent->EventTemplate specialisation,
KeyedStateEventBase and KeylessStateEventBase types are introduced
with appropriate constructor signatures (with or without state_key,
respectively) to allow `using` of them from derived event types.
To facilitate writing of constraints, concepts for keyed and keyless
state event types are also introduced; RoomStateView, e.g., makes use
of those to provide appropriate method signatures.
- typeId(), unknownEventTypeId(), UnknownEventTypeId are no more
provided - they weren't used throughout the known code base
(Quaternion, NeoChat), and the concept of "unknown event types" is
hereby eliminated entirely.
- RoomKeyEvent no more accepts senderId as a parameter; it has never
been a good practice as the sender is assigned by Connection anyway.
|
|
Fixing link errors at non-template RoomStateView::get() when building
with libQuotient as a shared object. There's also a test in quotest.cpp
now to cover that case.
|
|
This class is called to provide an arbitrary snapshot of a room state;
as the first step, Room::currentState() returns an instance of this
class that stores, well, the current state. Implelementation-wise it's
the same hash map of two-part state event keys to const event pointers;
however, RoomStateView provides additional operations:
- get(), that deprecates Room::getCurrentState(), returns a pointer to
a particular event if the current state has it. Unlike the original
method, the pointer returned from this one can be nullptr; this is
done to get rid of stubbed state events that have to be created
everytime a "state miss" occurred (i.e., when getCurrentState()
does not find an existing event in the current state).
- eventsOfType() - this is a new place for Room::stateEventsOfType()
introduced recently.
- query() - this is a way to specify a piece of the state content that
you need to retrieve by passing a member function or a function object
that retrieves it. That is especially convenient with member functions
of the event class; just pass the pointer to this member function,
and query() will parse the event type it has to retrieve out of it and
call that member function on the event object. Returns an Omittable<>;
if the respective piece of state doesn't exist, you'll get
`Quotient::none` (the same as `std::nullopt`).
- queryOr() - the same but with the fallback value; instead of an
Omittable<>, the fallback value will be returned if the needed event
is not found.
|