2018-12-01 23:55:15 +01: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_EVENT_PREV_H
|
|
|
|
|
|
|
|
namespace ircd::m
|
|
|
|
{
|
|
|
|
bool for_each(const event::prev &, const event::id::closure_bool &);
|
|
|
|
size_t degree(const event::prev &);
|
|
|
|
size_t count(const event::prev &);
|
|
|
|
|
|
|
|
std::ostream &pretty(std::ostream &, const event::prev &);
|
|
|
|
std::string pretty(const event::prev &);
|
|
|
|
|
|
|
|
std::ostream &pretty_oneline(std::ostream &, const event::prev &);
|
|
|
|
std::string pretty_oneline(const event::prev &);
|
|
|
|
}
|
|
|
|
|
2019-04-29 19:59:33 +02:00
|
|
|
/// Interface to the previous-references of an event. This interface overlays
|
|
|
|
/// on the m::event tuple and adds functionality focused specifically on the
|
|
|
|
/// various reference properties in the event data.
|
|
|
|
///
|
|
|
|
/// Instances of this class "overlay" on the event tuple, meaning one just
|
|
|
|
/// passes an m::event (or a json::object which would be passed to an m::event)
|
|
|
|
/// to the constructor of this class. This class only has the properties of
|
|
|
|
/// the event which contain references, and a suite of functions to work with
|
|
|
|
/// those references.
|
2018-12-01 23:55:15 +01:00
|
|
|
struct ircd::m::event::prev
|
|
|
|
:json::tuple
|
|
|
|
<
|
|
|
|
json::property<name::auth_events, json::array>,
|
|
|
|
json::property<name::prev_events, json::array>
|
|
|
|
>
|
|
|
|
{
|
2020-09-17 08:55:48 +02:00
|
|
|
static constexpr const size_t &MAX
|
|
|
|
{
|
|
|
|
20
|
|
|
|
};
|
|
|
|
|
2019-07-03 22:24:01 +02:00
|
|
|
std::tuple<event::id, json::object> auth_events(const size_t &idx) const;
|
|
|
|
std::tuple<event::id, json::object> prev_events(const size_t &idx) const;
|
2018-12-01 23:55:15 +01:00
|
|
|
|
2019-04-29 19:57:43 +02:00
|
|
|
event::id auth_event(const size_t &idx) const;
|
|
|
|
event::id prev_event(const size_t &idx) const;
|
2018-12-01 23:55:15 +01:00
|
|
|
|
2019-04-29 20:05:43 +02:00
|
|
|
bool auth_event_exists(const size_t &idx) const;
|
|
|
|
bool prev_event_exists(const size_t &idx) const;
|
2018-12-01 23:55:15 +01:00
|
|
|
|
|
|
|
bool auth_events_has(const event::id &) const;
|
|
|
|
bool prev_events_has(const event::id &) const;
|
|
|
|
|
2019-04-29 20:05:43 +02:00
|
|
|
size_t auth_events_count() const;
|
|
|
|
size_t prev_events_count() const;
|
|
|
|
|
2019-09-05 23:38:41 +02:00
|
|
|
size_t auth_events_exist() const;
|
|
|
|
size_t prev_events_exist() const;
|
|
|
|
|
2020-06-10 08:07:34 +02:00
|
|
|
bool auth_exist() const;
|
|
|
|
bool prev_exist() const;
|
|
|
|
|
2018-12-01 23:55:15 +01:00
|
|
|
using super_type::tuple;
|
|
|
|
using super_type::operator=;
|
|
|
|
};
|