mirror of
https://github.com/matrix-construct/construct
synced 2024-06-25 21:38:18 +02:00
ircd:Ⓜ️:room::events: Cleanup/simplify; reorg interface.
This commit is contained in:
parent
5d9ec170f8
commit
9cb0f46440
|
@ -62,28 +62,29 @@ struct ircd::m::room::events
|
|||
explicit operator bool() const { return bool(it); }
|
||||
bool operator!() const { return !it; }
|
||||
|
||||
event::id::buf event_id() const; // deprecated; will remove
|
||||
event::idx event_idx() const; // Available from the iterator key.
|
||||
uint64_t depth() const; // Available from the iterator key.
|
||||
|
||||
// Observers from the current valid iterator
|
||||
uint64_t depth() const;
|
||||
event::idx event_idx() const;
|
||||
explicit operator event::idx() const;
|
||||
|
||||
const m::event &fetch(std::nothrow_t);
|
||||
const m::event &fetch();
|
||||
|
||||
bool prefetch(const string_view &event_prop);
|
||||
bool prefetch(); // uses property keys from any fetch::opts supplied.
|
||||
|
||||
// Perform a new lookup / iterator
|
||||
bool seek_idx(const event::idx &);
|
||||
bool seek(const uint64_t &depth = -1);
|
||||
bool seek(const event::id &);
|
||||
|
||||
// These are reversed on purpose
|
||||
// Move the iterator
|
||||
auto &operator++() { return --it; }
|
||||
auto &operator--() { return ++it; }
|
||||
|
||||
// Fetch the actual event data at the iterator's position
|
||||
const m::event &operator*();
|
||||
const m::event *operator->() { return &operator*(); }
|
||||
const m::event &fetch(std::nothrow_t);
|
||||
const m::event &fetch();
|
||||
|
||||
// Prefetch the actual event data at the iterator's position
|
||||
bool prefetch(const string_view &event_prop);
|
||||
bool prefetch(); // uses supplied fetch::opts.
|
||||
|
||||
events(const m::room &,
|
||||
const uint64_t &depth,
|
||||
|
|
|
@ -1669,6 +1669,33 @@ ircd::m::room::events::events(const m::room &room,
|
|||
seek(1);
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::room::events::prefetch()
|
||||
{
|
||||
assert(_event.fopts);
|
||||
return m::prefetch(event_idx(), *_event.fopts);
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::room::events::prefetch(const string_view &event_prop)
|
||||
{
|
||||
return m::prefetch(event_idx(), event_prop);
|
||||
}
|
||||
|
||||
const ircd::m::event &
|
||||
ircd::m::room::events::fetch()
|
||||
{
|
||||
m::seek(_event, event_idx());
|
||||
return _event;
|
||||
}
|
||||
|
||||
const ircd::m::event &
|
||||
ircd::m::room::events::fetch(std::nothrow_t)
|
||||
{
|
||||
m::seek(_event, event_idx(), std::nothrow);
|
||||
return _event;
|
||||
}
|
||||
|
||||
const ircd::m::event &
|
||||
ircd::m::room::events::operator*()
|
||||
{
|
||||
|
@ -1735,33 +1762,6 @@ catch(const db::not_found &e)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::room::events::prefetch()
|
||||
{
|
||||
assert(_event.fopts);
|
||||
return m::prefetch(event_idx(), *_event.fopts);
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::room::events::prefetch(const string_view &event_prop)
|
||||
{
|
||||
return m::prefetch(event_idx(), event_prop);
|
||||
}
|
||||
|
||||
const ircd::m::event &
|
||||
ircd::m::room::events::fetch()
|
||||
{
|
||||
m::seek(_event, event_idx());
|
||||
return _event;
|
||||
}
|
||||
|
||||
const ircd::m::event &
|
||||
ircd::m::room::events::fetch(std::nothrow_t)
|
||||
{
|
||||
m::seek(_event, event_idx(), std::nothrow);
|
||||
return _event;
|
||||
}
|
||||
|
||||
ircd::m::room::events::operator
|
||||
ircd::m::event::idx()
|
||||
const
|
||||
|
@ -1769,26 +1769,6 @@ const
|
|||
return event_idx();
|
||||
}
|
||||
|
||||
ircd::m::event::id::buf
|
||||
ircd::m::room::events::event_id()
|
||||
const
|
||||
{
|
||||
return m::event_id(this->event_idx(), std::nothrow);
|
||||
}
|
||||
|
||||
uint64_t
|
||||
ircd::m::room::events::depth()
|
||||
const
|
||||
{
|
||||
assert(bool(*this));
|
||||
const auto part
|
||||
{
|
||||
dbs::room_events_key(it->first)
|
||||
};
|
||||
|
||||
return std::get<0>(part);
|
||||
}
|
||||
|
||||
ircd::m::event::idx
|
||||
ircd::m::room::events::event_idx()
|
||||
const
|
||||
|
@ -1802,6 +1782,19 @@ const
|
|||
return std::get<1>(part);
|
||||
}
|
||||
|
||||
uint64_t
|
||||
ircd::m::room::events::depth()
|
||||
const
|
||||
{
|
||||
assert(bool(*this));
|
||||
const auto part
|
||||
{
|
||||
dbs::room_events_key(it->first)
|
||||
};
|
||||
|
||||
return std::get<0>(part);
|
||||
}
|
||||
|
||||
//
|
||||
// room::state
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue