Yate
|
#include <yatengine.h>
Public Types | |
enum | RunMode { Stopped = 0, Console = 1, Server = 2, Client = 3, ClientProxy = 4 } |
enum | CallAccept { Accept = 0, Partial = 1, Congestion = 2, Reject = 3 } |
enum | PluginMode { LoadFail = 0, LoadLate, LoadEarly } |
Public Member Functions | |
int | engineInit () |
int | engineCleanup () |
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, EngineLoop loop=0, bool fail=false) |
static void | help (bool client, bool errout=false) |
static Engine * | self () |
static RunMode | mode () |
static CallAccept | accept () |
static void | setAccept (CallAccept ca) |
static const TokenDict * | getCallAcceptStates () |
static bool | clientMode () |
static bool | Register (const Plugin *plugin, bool reg=true) |
static const String & | nodeName () |
static const String & | sharedPath () |
static String | configFile (const char *name, bool user=false) |
static const String & | configPath (bool user=false) |
static const String & | configSuffix () |
static const String & | modulePath () |
static void | extraPath (const String &path) |
static void | userPath (const String &path) |
static const String & | moduleSuffix () |
static const char * | pathSeparator () |
static const Configuration & | config () |
static unsigned int | runId () |
static const NamedList & | runParams () |
static void | init () |
static bool | init (const String &name) |
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, bool broadcast=false) |
static bool | dispatch (Message *msg) |
static bool | dispatch (Message &msg) |
static bool | dispatch (const char *name, bool broadcast=false) |
static void | pluginMode (PluginMode mode) |
static const ObjList * | events (const String &type) |
static void | clearEvents (const String &type) |
Protected Member Functions | |
~Engine () | |
bool | loadPlugin (const char *file, bool local=false, bool nounload=false) |
void | loadPlugins () |
void | initPlugins () |
Friends | |
class | EnginePrivate |
class | EngineCommand |
Engine globals.
This class holds global information about the engine. Note: this is a singleton class.
enum PluginMode |
Plugin load and initialization modes. Default is LoadLate that initailizes the plugin after others. LoadEarly will move the plugin to the front of the init order. LoadFail causes the plugin to be unloaded.
~Engine | ( | ) | [protected] |
Destroys the engine and everything. You must not call it directly, run() will do it for you.
static CallAccept accept | ( | ) | [inline, static] |
Get call accept status
static void clearEvents | ( | const String & | type | ) | [static] |
Clear the list of captured events of a specific type
type | Type of captured events, an empty name clear engine events |
static bool clientMode | ( | ) | [inline, static] |
Check if the engine is running as telephony client
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 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 const String& configPath | ( | bool | user = false | ) | [static] |
Get the system or user configuration directory path
user | True to get the user settings path |
static const String& configSuffix | ( | ) | [inline, static] |
Get the configuration file suffix
Synchronously dispatch a message to the registered handlers
msg | Pointer to the message to dispatch |
Synchronously dispatch a message to the registered handlers
msg | The message to dispatch |
static bool dispatch | ( | const char * | name, |
bool | broadcast = false |
||
) | [static] |
Convenience function. Dispatch a parameterless message to the registered handlers
name | The name of the message to create and dispatch |
broadcast | Broadcast flag, true if handling the mesage must not stop it |
int engineCleanup | ( | ) |
Do engine cleanup
int engineInit | ( | ) |
Initialize the engine
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, |
bool | broadcast = false |
||
) | [inline, static] |
Convenience function. Enqueue a new parameterless message in the message queue
name | Name of the parameterless message to put in queue |
broadcast | Broadcast flag, true if handling the mesage must not stop it |
References Engine::enqueue().
Referenced by Engine::enqueue().
Retrive the list of captured events of a specific type
type | Type of captured events, an empty name returns engine events |
static bool exiting | ( | ) | [inline, static] |
Check if the engine is currently exiting
Referenced by Client::valid().
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 const TokenDict* getCallAcceptStates | ( | ) | [inline, static] |
Get call accept states
static void halt | ( | unsigned int | code | ) | [static] |
Stop the engine and the entire program
code | Return code of the program |
unsigned int handlerCount | ( | ) | [inline] |
Get the number of handlers in the dispatcher
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 |
static void init | ( | ) | [static] |
Reinitialize the plugins
Reinitialize one plugin
name | Name of the plugin to initialize, emplty, "*" or "all" to initialize all |
void initPlugins | ( | ) | [protected] |
Initialize all registered plugins
static bool install | ( | MessageHandler * | handler | ) | [static] |
Installs a handler in the dispatcher.
handler | A pointer to the handler to install |
bool loadPlugin | ( | const char * | file, |
bool | local = false , |
||
bool | nounload = 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 |
nounload | Never unload the module from memory, finalize if possible |
bool loadPluginDir | ( | const String & | relPath | ) |
Loads the plugins from an extra plugins directory or just an extra plugin
relPath | Path to the extra directory, relative to the main modules |
void loadPlugins | ( | ) | [protected] |
Loads the plugins from the plugins directory
static int main | ( | int | argc, |
const char ** | argv, | ||
const char ** | env, | ||
RunMode | mode = Console , |
||
EngineLoop | loop = 0 , |
||
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 |
loop | Callback function to the main thread's loop |
fail | Fail and return after parsing command line arguments |
unsigned int messageCount | ( | ) | [inline] |
Get the number of messages waiting in the queue
Get the running mode of the engine
static const String& modulePath | ( | ) | [inline, static] |
The module loading path
static const String& moduleSuffix | ( | ) | [inline, static] |
Get the module filename suffix
Get the server node name, should be unique in a cluster
static const char* pathSeparator | ( | ) | [static] |
Get the canonical path element separator for the operating system
static void pluginMode | ( | PluginMode | mode | ) | [static] |
Set the load and init mode of the currently loading Plugin
mode | Load and init mode, default LoadLate |
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 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 |
int run | ( | ) |
Run the engine.
static unsigned int runId | ( | ) | [static] |
Get a - supposedly unique - instance ID
Get the engine parameters specific to this run.
Get a pointer to the unique instance.
static void setAccept | ( | CallAccept | ca | ) | [inline, static] |
Set call accept status
ca | New call accept status as enumerated value |
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 |
static const String& sharedPath | ( | ) | [inline, static] |
Get the application's shared directory path
static bool uninstall | ( | MessageHandler * | handler | ) | [static] |
Uninstalls a handler drom the dispatcher.
handler | A pointer to the handler to uninstall |
int usedPlugins | ( | ) |
Get a count of plugins that are actively in use