#include <core.h>
Inheritance diagram for modules::Core:
Public Types | |
enum | { sfReload = 0x00000001, sfSync = 0x00000002, sfRestart = 0x00000004, sfStop = 0x00000008, sfFatal = 0x00000010 } |
Schedule flags. More... | |
enum | { pfForeground = 0x00000001, pfBackground = 0x00000002, pfConfigured = 0x00000004, pfReadOnly = 0x00000008, pfQuiet = 0x00000010, pfVeryQuiet = 0x00000020 } |
Program flags. More... | |
Public Member Functions | |
Core () | |
Constructor. | |
virtual void | fatal (char const *msg=0)=0 |
Exit the program immediately. | |
void | fatalf (char const *msg,...) FORMAT(printf |
Same as fatal but works like printf(). | |
void void | log (xlog::LogLevel const &level, char const *format,...) FORMAT(printf |
Logs a message. | |
void void void | log_perror (xlog::LogLevel const &level, char const *format,...) FORMAT(printf |
Logs a message with a system error. | |
virtual void | schedule (unsigned int action) |
Schedule program-related action. | |
virtual cmdline::CmdLineParser & | clp ()=0 |
Returns the parsed command-line parameters. | |
virtual conf::ConfLogger & | conf_logger ()=0 |
Returns the configuration logger object. | |
virtual unsigned int | debuglevel () const |
Returns current debug level. | |
virtual unsigned int | debuglevel (unsigned int lev) |
Sets debug level to a new value. | |
virtual unsigned int | flags () const |
Returns current program flags. | |
virtual unsigned int | flags_add (unsigned int flg) |
Adds new flags to current program flags. | |
virtual unsigned int | flags_remove (unsigned int flg) |
Removes flags from current program flags. | |
virtual xlog::Logger & | logger ()=0 |
Returns the program logger object. | |
virtual ModManager & | modules ()=0 |
Returns the modules manager object. | |
virtual bool | started () const |
Returns whether the program is started. | |
virtual time_t | start_time () const |
Returns when the program started. | |
virtual scheduler::Scheduler & | tasks ()=0 |
Returns the program scheduler object. | |
virtual std::string const | version_string () const =0 |
Returns the version string. | |
Public Attributes | |
char | exitmsg [exitmsg_size] |
Program exit message. | |
Static Public Attributes | |
static int const | exitmsg_size = 256 |
Program exit message size. | |
Protected Attributes | |
unsigned int | m_action |
Scheduled action (through schedule()). | |
unsigned int | m_debuglevel |
Debug level. | |
unsigned int | m_flags |
Program flags. | |
bool | m_started |
Started? | |
time_t | m_starttime |
When did it start? |
It encapsulates all the core features one might expect such as the command-line parser, the conf logger, the modules manager, the scheduler or the program logger. There's also a few functions that control the program flow.
Other modules will always be able to rely on a module derived from this class as the module manager ensures this module exists and can't be unloaded (yes, that wouldn't make much sense, really. :P)
|
This enum lists all possible flags for use with the schedule() function.
Reimplemented from modules::Module. |
|
This enum lists all possible flags for use with the flags() function family.
Reimplemented from modules::Module. |
|
Returns the command-line parameters, already parsed. Should be used by modules that want to handle their own command-line parameters (a parameter is never invalid so all parameters given at program start are always there). Modules must use only long options though, because they can't predict which short options will be already in use by the core.
Implemented in core::Epona. |
|
Returns the configuration logger object, that may be used by modules when they need to create configuration parsers.
Implemented in core::Epona. |
|
Sets debug level to a new value.
|
|
Returns current debug level, usually between 0 and 4 (but it can be more if user requests it). Debug messages must be logged only if debuglevel is non-zero.
|
|
When something goes so wrong that there's no way to continue execution normally, call this to exit the program.
Implemented in core::Epona. |
|
Returns current program flags controlling runtime behaviour.
|
|
Adds new flags to the current program flags that control runtime behaviour.
|
|
Removes flags from the current program flags that control runtime behaviour.
|
|
Logs a message through the program logger (the Logger::log() function is used).
|
|
Logs a message through the program logger (the Logger::log() function is used). If errno is non-zero, then a system error message (as returned by the strerror() function) will be appended to it.
|
|
Returns the program logger object, that may be used by the program to log messages through various means, as well as register log modules.
Implemented in core::Epona. |
|
Returns the modules manager object, that is used to load, unload and maintain the modules used by the program.
Implemented in core::Epona. |
|
This function schedules a program-related action to be executed once, at the next main loop iteration, allowing them to be executed in a safe manner whatever the context is when the scheduling is done. This function may be called multiple times to schedule different actions. The order in which the actions are done is undefined in that case, although sfFatal is ALWAYS processed first.
|
|
Returns when the program started (i.e. when the core module was created). |
|
Returns whether the program is started (i.e. all initialization finished, in the main loop). |
|
Returns the program scheduler object, that modules may use to schedule tasks to be run periodically. It's basically their main way to hook the main loop to get things to be done when they need to.
Implemented in core::Epona. |
|
Returns the program version string, in free format.
Implemented in core::Epona. |
|
The message that will be logged before exiting the program. Must be set prior to ask for program termination or restart through fatal(), fatalf() or schedule(). |
|
Maximum size of the exit message.
|