From 191167f7ba71712a1040465567ced7ad1fae6944 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sat, 24 Feb 2018 19:52:02 -0800 Subject: [PATCH] ircd::m: Add count() interface to room::state. --- include/ircd/m/room.h | 4 ++++ ircd/m/room.cc | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/include/ircd/m/room.h b/include/ircd/m/room.h index 925e8e160..97356c2e4 100644 --- a/include/ircd/m/room.h +++ b/include/ircd/m/room.h @@ -188,6 +188,10 @@ struct ircd::m::room::state bool test(const event::id::closure_bool &view) const; bool test(const event::closure_bool &view) const; + // Counting / Statistics + size_t count(const string_view &type) const; + size_t count() const; + // Existential bool has(const string_view &type, const string_view &state_key) const; bool has(const string_view &type) const; diff --git a/ircd/m/room.cc b/ircd/m/room.cc index 4916de811..176555c5f 100644 --- a/ircd/m/room.cc +++ b/ircd/m/room.cc @@ -427,6 +427,20 @@ const }); } +size_t +ircd::m::room::state::count() +const +{ + return m::state::count(root_id); +} + +size_t +ircd::m::room::state::count(const string_view &type) +const +{ + return m::state::count(root_id, type); +} + bool ircd::m::room::state::test(const event::closure_bool &closure) const