0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-10-30 18:39:02 +01:00
construct/include/ircd/ircd.h

69 lines
2.2 KiB
C
Raw Normal View History

2018-02-04 03:22:01 +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.
2016-07-26 04:06:31 +02:00
#pragma once
#define HAVE_IRCD_H
#if defined(PIC) && defined(PCH)
2016-11-29 16:23:38 +01:00
#include "stdinc.pic.h"
#else
2016-11-29 16:23:38 +01:00
#include "stdinc.h"
#endif
2016-07-26 04:06:31 +02:00
/// \brief Internet Relay Chat daemon. This is the principal namespace for IRCd.
///
///
namespace ircd
{
struct init;
2017-11-30 20:44:23 +01:00
extern runlevel_handler runlevel_changed;
2016-09-06 01:05:16 +02:00
string_view reflect(const enum runlevel &);
2017-12-29 23:53:39 +01:00
void init(boost::asio::io_context &ios, const std::string &conf, runlevel_handler = {});
void init(boost::asio::io_context &ios, runlevel_handler = {});
bool quit() noexcept;
}
/// The runlevel allows all observers to know the coarse state of IRCd and to
/// react accordingly. This can be used by the embedder of libircd to know
/// when it's safe to use or delete libircd resources. It is also used
/// similarly by the library and its modules.
///
/// Primary modes:
///
/// * HALT is the off mode. Nothing is/will be running in libircd until
/// an invocation of ircd::init();
///
/// * RUN is the service mode. Full client and application functionality
/// exists in this mode. Leaving the RUN mode is done with ircd::quit();
///
/// - Transitional modes: Modes which are working towards the next mode.
/// - Interventional modes: Modes which are *not* working towards the next
/// mode and may require some user action to continue.
///
enum class ircd::runlevel
2017-11-30 20:44:23 +01:00
:int
{
2017-11-30 20:44:23 +01:00
HALT = 0, ///< [inter] IRCd Powered off.
READY = 1, ///< [inter] Ready for user to run ios event loop.
START = 2, ///< [trans] Starting up subsystems for service.
RUN = 3, ///< [inter] IRCd in service.
QUIT = 4, ///< [trans] Clean shutdown in progress
FAULT = -1, ///< [trans] QUIT with exception (dirty shutdown)
};
2017-11-30 20:44:23 +01:00
template<class T>
std::string
ircd::demangle()
{
return demangle(typeid(T).name());
}