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 () |
unsigned int | postHookCount () |
unsigned int | messageRate () const |
unsigned int | messageMaxRate () const |
unsigned int | messageAge (bool usec=false) const |
void | getStats (u_int64_t &enqueued, u_int64_t &dequeued, u_int64_t &dispatched, u_int64_t &queueMax) |
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 void | setCongestion (const char *reason=0) |
static unsigned int | getCongestion () |
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 | started () |
static bool | exiting () |
static bool | install (MessageHandler *handler) |
static bool | uninstall (MessageHandler *handler) |
static bool | enqueue (Message *msg, bool skipHooks=false) |
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 const String & | trackParam () |
static bool | installHook (MessageHook *hook) |
static void | uninstallHook (MessageHook *hook) |
static void | pluginMode (PluginMode mode) |
static const ObjList * | events (const String &type) |
static void | clearEvents (const String &type) |
static SharedVars & | sharedVars () |
static void | buildCmdLine (String &line) |
static void | initLibrary (const String &line, String *output=0) |
static int | cleanupLibrary () |
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.
|
protected |
Destroys the engine and everything. You must not call it directly, run() will do it for you.
|
inlinestatic |
Get call accept status
|
static |
Append command line arguments form current config. The following parameters are added: -Dads, -v, -q, Debugger timestamp. This method should be used when starting another libyate based application
line | Destination string |
|
static |
Cleanup library. Set late abort, kill all threads. This method should be used in cleanup stage of libyate based applications
|
static |
Clear the list of captured events of a specific type
type | Type of captured events, an empty name clear engine events |
|
inlinestatic |
Check if the engine is running as telephony client
|
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 |
Get the filename for a specific configuration
name | Name of the configuration requested |
user | True to build a user settings path |
|
static |
Get the system or user configuration directory path
user | True to get the user settings path |
|
inlinestatic |
Get the configuration file suffix
|
static |
Synchronously dispatch a message to the registered handlers
msg | Pointer to the message to dispatch |
|
static |
Synchronously dispatch a message to the registered handlers
msg | The message to dispatch |
|
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
|
static |
Enqueue a message in the message queue for asynchronous dispatching
msg | The message to enqueue, will be destroyed after dispatching |
skipHooks | True to append the message directly into the main queue |
Referenced by Engine::enqueue().
|
inlinestatic |
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().
Retrive the list of captured events of a specific type
type | Type of captured events, an empty name returns engine events |
|
inlinestatic |
Check if the engine is currently exiting
Referenced by Client::valid().
|
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 |
|
inlinestatic |
Get call accept states
|
inlinestatic |
Get the congestion state counter
|
inline |
Retrieve dispatcher's statistics counters
enqueued | Returns count of enqueued messages |
dequeued | Returns count of dequeued messages |
dispatched | Returns count of all dispatched messages, including dequeued ones |
queueMax | Returns queued high watermark |
References MessageDispatcher::getStats().
|
static |
Stop the engine and the entire program
code | Return code of the program |
|
inline |
Get the number of handlers in the dispatcher
References MessageDispatcher::handlerCount().
|
static |
Display the help information on console
client | Display help for client running mode |
errout | Display on stderr intead of stdout |
|
static |
Reinitialize the plugins
|
static |
Reinitialize one plugin
name | Name of the plugin to initialize, emplty, "*" or "all" to initialize all |
Initialize library from command line arguments. Enable debugger output. This method should be used in initialization stage of libyate based applications
line | Command line arguments string |
output | Optional string to be filled with invalid argument errors or any output to be displyed later |
|
protected |
Initialize all registered plugins
|
static |
Installs a handler in the dispatcher.
handler | A pointer to the handler to install |
|
static |
Appends a new message hook to the hooks list.
hook | The message hook to append. |
|
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 |
|
protected |
Loads the plugins from the plugins directory
|
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 |
|
inline |
Get the average dequeued message age in milliseconds or microseconds
usec | True to return microseconds instead of milliseconds |
References MessageDispatcher::messageAge().
|
inline |
Get the number of messages waiting in the queue
References MessageDispatcher::messageCount().
|
inline |
Get the maximum rate of dispatched messages per second
|
inline |
Get the rate of dispatched messages per second
|
inlinestatic |
Get the running mode of the engine
|
inlinestatic |
The module loading path
|
inlinestatic |
Get the module filename suffix
|
inlinestatic |
Get the server node name, should be unique in a cluster
|
static |
Get the canonical path element separator for the operating system
|
static |
Set the load and init mode of the currently loading Plugin
mode | Load and init mode, default LoadLate |
|
inline |
Get the number of post-handling hooks in the dispatcher
References MessageDispatcher::postHookCount().
|
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 |
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 |
Get a - supposedly unique - instance ID
|
inlinestatic |
Get the engine parameters specific to this run.
|
static |
Get a pointer to the unique instance.
|
inlinestatic |
Set call accept status
ca | New call accept status as enumerated value |
|
static |
Alter the congestion state counter.
reason | Reason to enter congested state, NULL to leave congestion |
|
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 |
References MessageDispatcher::setHook().
|
inlinestatic |
Get the application's shared directory path
|
static |
Access the engine's shared variables
|
inlinestatic |
Check if the engine was started
|
inlinestatic |
Retrieve the tracker parameter name
References String::empty(), and MessageDispatcher::trackParam().
|
static |
Uninstalls a handler drom the dispatcher.
handler | A pointer to the handler to uninstall |
|
static |
Remove a message hook from the hooks list.
hook | The hook to remove. |
int usedPlugins | ( | ) |
Get a count of plugins that are actively in use
|
static |