0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-03 04:18:55 +01:00
construct/include/ircd/m/dbs.h
2018-01-29 09:36:05 -08:00

60 lines
2 KiB
C++

// 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_DBS_H
namespace ircd::m::dbs
{
struct init;
extern std::map<std::string, ircd::module> modules;
extern std::map<std::string, import_shared<database>> databases;
bool exists(const event::id &);
void append_indexes(const event &, db::iov &iov);
void append_nodes(const event &, db::iov &iov);
void write(const event &, db::iov &txn);
}
class ircd::m::dbs::init
{
void _modules();
void _databases();
public:
init();
~init() noexcept;
};
namespace ircd::m::dbs
{
using closure = std::function<void (const event &)>;
using closure_bool = std::function<bool (const event &)>;
bool _query(const query<> &, const closure_bool &);
bool _query_event_id(const query<> &, const closure_bool &);
bool _query_in_room_id(const query<> &, const closure_bool &, const id::room &);
bool _query_for_type_state_key_in_room_id(const query<> &, const closure_bool &, const id::room &, const string_view &type, const string_view &state_key);
int _query_where_event_id(const query<where::equal> &, const closure_bool &);
int _query_where_room_id_at_event_id(const query<where::equal> &, const closure_bool &);
int _query_where_room_id(const query<where::equal> &, const closure_bool &);
int _query_where(const query<where::equal> &where, const closure_bool &closure);
int _query_where(const query<where::logical_and> &where, const closure_bool &closure);
}
namespace ircd::m
{
void _index_special0(const event &event, db::iov &iov, const db::op &, const string_view &prev_event_id);
void _index_special1(const event &event, db::iov &iov, const db::op &, const string_view &prev_event_id);
}