2018-04-18 09:33:38 +02:00
|
|
|
// 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_EVENTS_H
|
|
|
|
|
|
|
|
namespace ircd::m::events
|
|
|
|
{
|
2019-01-10 02:06:50 +01:00
|
|
|
struct range;
|
2018-04-18 09:33:38 +02:00
|
|
|
using closure_bool = std::function<bool (const event::idx &, const event &)>;
|
2019-04-17 00:36:44 +02:00
|
|
|
using closure_type_bool = std::function<bool (const string_view &, const event::idx &)>;
|
2019-04-16 23:40:12 +02:00
|
|
|
using closure_sender_bool = std::function<bool (const id::user &, const event::idx &)>;
|
|
|
|
|
2019-04-17 00:36:44 +02:00
|
|
|
bool for_each_in_type(const string_view &, const closure_type_bool &);
|
2019-04-16 23:40:12 +02:00
|
|
|
bool for_each_in_sender(const id::user &, const closure_sender_bool &);
|
|
|
|
bool for_each_in_origin(const string_view &, const closure_sender_bool &);
|
2018-04-18 09:33:38 +02:00
|
|
|
|
2019-04-16 23:42:28 +02:00
|
|
|
bool for_each(const range &, const event::closure_idx_bool &);
|
|
|
|
bool for_each(const range &, const event_filter &, const event::closure_idx_bool &);
|
|
|
|
|
2019-01-10 02:06:50 +01:00
|
|
|
bool for_each(const range &, const closure_bool &);
|
|
|
|
bool for_each(const range &, const event_filter &, const closure_bool &);
|
2018-04-18 09:33:38 +02:00
|
|
|
}
|
2019-01-10 02:06:50 +01:00
|
|
|
|
|
|
|
/// Range to start (inclusive) and stop (exclusive). If start is greater than
|
|
|
|
/// stop a reverse iteration will occur. -1 (or unsigned max value) can be used
|
|
|
|
/// to start or stop at the end. 0 can be used to start or stop at the beginning.
|
2019-01-13 23:02:54 +01:00
|
|
|
/// (event::idx of 0 is a sentinel)
|
2019-01-10 02:06:50 +01:00
|
|
|
///
|
|
|
|
struct ircd::m::events::range
|
2019-02-28 23:39:15 +01:00
|
|
|
:event::idx_range
|
2019-01-10 02:06:50 +01:00
|
|
|
{
|
2019-01-10 02:57:13 +01:00
|
|
|
const event::fetch::opts *fopts {nullptr};
|
|
|
|
|
|
|
|
range(const event::idx &start,
|
|
|
|
const event::idx &stop = -1,
|
|
|
|
const event::fetch::opts *const &fopts = nullptr)
|
2019-02-28 23:39:15 +01:00
|
|
|
:event::idx_range{start, stop}
|
2019-01-10 02:57:13 +01:00
|
|
|
,fopts{fopts}
|
2019-01-10 02:06:50 +01:00
|
|
|
{}
|
|
|
|
};
|