#include <yatengine.h>
Public Types | |
enum | RunMode { Stopped = 0, Console = 1, Client = 2, Server = 3 } |
Public Member Functions | |
int | run () |
void | setHook (MessagePostHook *hook, bool remove=false) |
int | usedPlugins () |
unsigned int | messageCount () |
unsigned int | handlerCount () |
bool | loadPluginDir (const String &relPath) |
Static Public Member Functions | |
static int | main (int argc, const char **argv, const char **env, RunMode mode=Console, bool fail=false) |
static void | help (bool client, bool errout=false) |
static Engine * | self () |
static RunMode | mode () |
static bool | clientMode () |
static bool | Register (const Plugin *plugin, bool reg=true) |
static String | configFile (const char *name, bool user=false) |
static String & | configPath () |
static String & | configSuffix () |
static String & | modulePath () |
static void | extraPath (const String &path) |
static String & | moduleSuffix () |
static const char * | pathSeparator () |
static const Configuration & | config () |
static unsigned int | runId () |
static void | init () |
static void | halt (unsigned int code) |
static bool | restart (unsigned int code, bool gracefull=false) |
static bool | exiting () |
static bool | install (MessageHandler *handler) |
static bool | uninstall (MessageHandler *handler) |
static bool | enqueue (Message *msg) |
static bool | enqueue (const char *name) |
static bool | dispatch (Message *msg) |
static bool | dispatch (Message &msg) |
static bool | dispatch (const char *name) |
Protected Member Functions | |
~Engine () | |
bool | loadPlugin (const char *file, bool local=false) |
void | loadPlugins () |
void | initPlugins () |
Friends | |
class | EnginePrivate |
This class holds global information about the engine. Note: this is a singleton class.
~Engine | ( | ) | [protected] |
Destroys the engine and everything. You must not call it directly, run() will do it for you.
static int main | ( | int | argc, | |
const char ** | argv, | |||
const char ** | env, | |||
RunMode | mode = Console , |
|||
bool | fail = false | |||
) | [static] |
Main entry point to be called directly from a wrapper program
argc | Argument count | |
argv | Argument array | |
env | Environment variables | |
mode | Mode the engine must run as - Console, Client or Server | |
fail | Fail and return after parsing command line arguments |
static void help | ( | bool | client, | |
bool | errout = false | |||
) | [static] |
Display the help information on console
client | Display help for client running mode | |
errout | Display on stderr intead of stdout |
int run | ( | ) |
Run the engine.
static Engine* self | ( | ) | [static] |
Get a pointer to the unique instance.
static RunMode mode | ( | ) | [inline, static] |
Get the running mode of the engine
static bool clientMode | ( | ) | [inline, static] |
Check if the engine is running as telephony client
static bool Register | ( | const Plugin * | plugin, | |
bool | reg = true | |||
) | [static] |
Register or unregister a plugin to the engine.
plugin | A pointer to the plugin to (un)register | |
reg | True to register (default), false to unregister |
static String configFile | ( | const char * | name, | |
bool | user = false | |||
) | [static] |
Get the filename for a specific configuration
name | Name of the configuration requested | |
user | True to build a user settings path |
static String& configPath | ( | ) | [inline, static] |
Get the system configuration directory path
static String& configSuffix | ( | ) | [inline, static] |
Get the configuration file suffix
static String& modulePath | ( | ) | [inline, static] |
The module loading path
static void extraPath | ( | const String & | path | ) | [static] |
Add a relative extra module loading path. The list is empty by default but can be filled by a main program before calling main()
path | Relative path to extra modules to be loaded |
static String& moduleSuffix | ( | ) | [inline, static] |
Get the module filename suffix
static const char* pathSeparator | ( | ) | [static] |
Get the canonical path element separator for the operating system
static const Configuration& config | ( | ) | [static] |
The global configuration of the engine. You must use this resource with caution. Note that sections [general], [modules], [preload] and [postload] are reserved by the engine. Also [telephony] is reserved by the drivers.
static unsigned int runId | ( | ) | [static] |
Get a - supposedly unique - instance ID
static void init | ( | ) | [static] |
Reinitialize the plugins
static void halt | ( | unsigned int | code | ) | [static] |
Stop the engine and the entire program
code | Return code of the program |
static bool restart | ( | unsigned int | code, | |
bool | gracefull = false | |||
) | [static] |
Stop and restart the engine and the entire program
code | Return code of the program | |
gracefull | Attempt to wait until no plugin is busy |
static bool exiting | ( | ) | [inline, static] |
Check if the engine is currently exiting
static bool install | ( | MessageHandler * | handler | ) | [static] |
Installs a handler in the dispatcher.
handler | A pointer to the handler to install |
static bool uninstall | ( | MessageHandler * | handler | ) | [static] |
Uninstalls a handler drom the dispatcher.
handler | A pointer to the handler to uninstall |
static bool enqueue | ( | Message * | msg | ) | [static] |
Enqueue a message in the message queue for asynchronous dispatching
msg | The message to enqueue, will be destroyed after dispatching |
static bool enqueue | ( | const char * | name | ) | [inline, static] |
Convenience function. Enqueue a new parameterless message in the message queue
name | Name of the parameterless message to put in queue |
static bool dispatch | ( | Message * | msg | ) | [static] |
Synchronously dispatch a message to the registered handlers
msg | Pointer to the message to dispatch |
static bool dispatch | ( | Message & | msg | ) | [static] |
Synchronously dispatch a message to the registered handlers
msg | The message to dispatch |
static bool dispatch | ( | const char * | name | ) | [static] |
Convenience function. Dispatch a parameterless message to the registered handlers
name | The name of the message to create and dispatch |
void setHook | ( | MessagePostHook * | hook, | |
bool | remove = false | |||
) | [inline] |
Install or remove a hook to catch messages after being dispatched
hook | Pointer to a post-dispatching message hook | |
remove | Set to True to remove the hook instead of adding |
int usedPlugins | ( | ) |
Get a count of plugins that are actively in use
unsigned int messageCount | ( | ) | [inline] |
Get the number of messages waiting in the queue
unsigned int handlerCount | ( | ) | [inline] |
Get the number of handlers in the dispatcher
bool loadPluginDir | ( | const String & | relPath | ) |
Loads the plugins from an extra plugins directory
relPath | Path to the extra directory, relative to the main modules |
bool loadPlugin | ( | const char * | file, | |
bool | local = false | |||
) | [protected] |
Loads one plugin from a shared object file
file | Name of the plugin file to load | |
local | Attempt to keep symbols local if supported by the system |
void loadPlugins | ( | ) | [protected] |
Loads the plugins from the plugins directory
void initPlugins | ( | ) | [protected] |
Initialize all registered plugins