2019-03-30 23:53:40 +01:00
|
|
|
// Matrix Construct
|
|
|
|
//
|
|
|
|
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
|
|
|
// Copyright (C) 2016-2019 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_ROOM_MEMBERS_H
|
|
|
|
|
|
|
|
/// Interface to the aliases
|
|
|
|
///
|
2019-03-31 01:04:35 +01:00
|
|
|
/// This interface focuses specifically on room aliases. These are aliases
|
|
|
|
/// contained in a room's state. There is also an aliases::cache which stores
|
|
|
|
/// the result of directory lookups as well as the contents found through this
|
|
|
|
/// interface in order to resolve aliases to room_ids.
|
2019-03-30 23:53:40 +01:00
|
|
|
///
|
|
|
|
struct ircd::m::room::aliases
|
|
|
|
{
|
2019-03-31 01:04:35 +01:00
|
|
|
struct cache;
|
2019-03-30 23:53:40 +01:00
|
|
|
using closure_bool = std::function<bool (const alias &)>;
|
|
|
|
|
2019-03-31 00:02:40 +01:00
|
|
|
static bool for_each(const m::room &, const string_view &server, const closure_bool &);
|
|
|
|
|
2019-03-30 23:53:40 +01:00
|
|
|
m::room room;
|
|
|
|
|
2019-03-31 00:02:40 +01:00
|
|
|
public:
|
2019-03-30 23:53:40 +01:00
|
|
|
bool for_each(const string_view &server, const closure_bool &) const;
|
|
|
|
bool for_each(const closure_bool &) const;
|
|
|
|
bool has(const alias &) const;
|
|
|
|
size_t count(const string_view &server) const;
|
|
|
|
size_t count() const;
|
|
|
|
|
|
|
|
aliases(const m::room &room)
|
|
|
|
:room{room}
|
|
|
|
{}
|
|
|
|
};
|
2019-03-31 01:04:35 +01:00
|
|
|
|
|
|
|
struct ircd::m::room::aliases::cache
|
|
|
|
{
|
2019-08-03 00:59:58 +02:00
|
|
|
struct entity;
|
2019-03-31 01:04:35 +01:00
|
|
|
using closure_bool = std::function<bool (const alias &, const id &)>;
|
|
|
|
|
2019-08-03 06:16:42 +02:00
|
|
|
static string_view make_key(const mutable_buffer &, const alias &);
|
2019-08-03 00:59:58 +02:00
|
|
|
static event::idx getidx(const alias &); // nothrow
|
|
|
|
static milliseconds age(const event::idx &); // nothrow
|
|
|
|
static bool expired(const event::idx &); // nothrow
|
|
|
|
|
|
|
|
public:
|
|
|
|
static system_point expires(const alias &);
|
|
|
|
static bool has(const alias &);
|
|
|
|
|
2019-03-31 01:04:35 +01:00
|
|
|
static bool for_each(const string_view &server, const closure_bool &);
|
|
|
|
static bool for_each(const closure_bool &);
|
2019-08-03 00:59:58 +02:00
|
|
|
|
2019-03-31 01:52:28 +01:00
|
|
|
static void fetch(const alias &, const net::hostport &remote);
|
|
|
|
static bool fetch(std::nothrow_t, const alias &, const net::hostport &remote);
|
2019-08-03 00:59:58 +02:00
|
|
|
|
2019-03-31 01:04:35 +01:00
|
|
|
static bool get(std::nothrow_t, const alias &, const id::closure &);
|
|
|
|
static void get(const alias &, const id::closure &);
|
2019-03-31 01:52:28 +01:00
|
|
|
static id::buf get(std::nothrow_t, const alias &);
|
2019-03-31 01:04:35 +01:00
|
|
|
static id::buf get(const alias &);
|
2019-08-03 00:59:58 +02:00
|
|
|
|
2019-03-31 01:04:35 +01:00
|
|
|
static bool set(const alias &, const id &);
|
2019-08-03 00:59:58 +02:00
|
|
|
|
2019-03-31 01:04:35 +01:00
|
|
|
static bool del(const alias &);
|
|
|
|
};
|