mirror of
https://github.com/matrix-construct/construct
synced 2024-12-26 23:44:01 +01:00
ircd:Ⓜ️ Add convenience interface for rooms / iterations.
This commit is contained in:
parent
6dda8d70eb
commit
fe90dd4d63
3 changed files with 75 additions and 0 deletions
|
@ -59,6 +59,7 @@ namespace ircd
|
|||
#include "state.h"
|
||||
#include "vm.h"
|
||||
#include "room.h"
|
||||
#include "rooms.h"
|
||||
#include "user.h"
|
||||
#include "node.h"
|
||||
#include "login.h"
|
||||
|
|
22
include/ircd/m/rooms.h
Normal file
22
include/ircd/m/rooms.h
Normal file
|
@ -0,0 +1,22 @@
|
|||
// Matrix Construct
|
||||
//
|
||||
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
||||
// Copyright (C) 2016-2018 Jason Volk <jason@zemos.net>
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
||||
// copyright notice and this permission notice is present in all copies. The
|
||||
// full license for this software is available in the LICENSE file.
|
||||
|
||||
#pragma once
|
||||
#define HAVE_IRCD_M_ROOMS_H
|
||||
|
||||
/// Convenience iterface for iterations of rooms
|
||||
///
|
||||
namespace ircd::m::rooms
|
||||
{
|
||||
void for_each(const room::id::closure_bool &);
|
||||
void for_each(const room::id::closure &);
|
||||
void for_each(const room::closure_bool &);
|
||||
void for_each(const room::closure &);
|
||||
}
|
52
ircd/m/m.cc
52
ircd/m/m.cc
|
@ -1229,6 +1229,58 @@ ircd::m::user::room::room(const m::user &user)
|
|||
static_cast<m::room &>(*this) = room_id;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// m/rooms.h
|
||||
//
|
||||
|
||||
void
|
||||
ircd::m::rooms::for_each(const room::closure &closure)
|
||||
{
|
||||
for_each(room::closure_bool{[&closure]
|
||||
(const room &room)
|
||||
{
|
||||
closure(room);
|
||||
return true;
|
||||
}});
|
||||
}
|
||||
|
||||
void
|
||||
ircd::m::rooms::for_each(const room::closure_bool &closure)
|
||||
{
|
||||
for_each(room::id::closure_bool{[&closure]
|
||||
(const room::id &room_id)
|
||||
{
|
||||
return closure(room_id);
|
||||
}});
|
||||
}
|
||||
|
||||
void
|
||||
ircd::m::rooms::for_each(const room::id::closure &closure)
|
||||
{
|
||||
for_each(room::id::closure_bool{[&closure]
|
||||
(const room::id &room_id)
|
||||
{
|
||||
closure(room_id);
|
||||
return true;
|
||||
}});
|
||||
}
|
||||
|
||||
void
|
||||
ircd::m::rooms::for_each(const room::id::closure_bool &closure)
|
||||
{
|
||||
const room::state state
|
||||
{
|
||||
my_room
|
||||
};
|
||||
|
||||
state.test("ircd.room", room::state::keys_bool{[&closure]
|
||||
(const string_view &key)
|
||||
{
|
||||
return !closure(key);
|
||||
}});
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// m/room.h
|
||||
|
|
Loading…
Reference in a new issue