Engine Class Reference

Engine globals. More...

#include <yatengine.h>

List of all members.

Public Types

enum  RunMode { Stopped = 0, Console = 1, Client = 2, Server = 3 }
enum  PluginMode { LoadFail = 0, LoadLate, LoadEarly }

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 Engineself ()
static RunMode mode ()
static bool clientMode ()
static bool Register (const Plugin *plugin, bool reg=true)
static const StringnodeName ()
static const StringsharedPath ()
static String configFile (const char *name, bool user=false)
static const StringconfigPath ()
static const StringconfigSuffix ()
static const StringmodulePath ()
static void extraPath (const String &path)
static const StringmoduleSuffix ()
static const char * pathSeparator ()
static const Configurationconfig ()
static unsigned int runId ()
static const NamedListrunParams ()
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)
static void pluginMode (PluginMode mode)

Protected Member Functions

 ~Engine ()
bool loadPlugin (const char *file, bool local=false)
void loadPlugins ()
void initPlugins ()

Friends

class EnginePrivate
class EngineCommand


Detailed Description

Engine globals.

This class holds global information about the engine. Note: this is a singleton class.


Member Enumeration Documentation

enum RunMode

Running modes - run the engine as Console, Client or Server.

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.


Constructor & Destructor Documentation

~Engine (  )  [protected]

Destroys the engine and everything. You must not call it directly, run() will do it for you.


Member Function Documentation

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

Parameters:
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
Returns:
Program exit code

static void help ( bool  client,
bool  errout = false 
) [static]

Display the help information on console

Parameters:
client Display help for client running mode
errout Display on stderr intead of stdout

int run (  ) 

Run the engine.

Returns:
Error code, 0 for success

static Engine* self (  )  [static]

Get a pointer to the unique instance.

Returns:
A pointer to the singleton instance of the engine

static RunMode mode (  )  [inline, static]

Get the running mode of the engine

Returns:
Engine's run mode as enumerated value

static bool clientMode (  )  [inline, static]

Check if the engine is running as telephony client

Returns:
True if the engine is running in client mode

static bool Register ( const Plugin plugin,
bool  reg = true 
) [static]

Register or unregister a plugin to the engine.

Parameters:
plugin A pointer to the plugin to (un)register
reg True to register (default), false to unregister
Returns:
True on success, false on failure

static const String& nodeName (  )  [inline, static]

Get the server node name, should be unique in a cluster

Returns:
Node identifier string, defaults to host name

static const String& sharedPath (  )  [inline, static]

Get the application's shared directory path

Returns:
The base path for shared files and directories

static String configFile ( const char *  name,
bool  user = false 
) [static]

Get the filename for a specific configuration

Parameters:
name Name of the configuration requested
user True to build a user settings path
Returns:
A full path configuration file name

static const String& configPath (  )  [inline, static]

Get the system configuration directory path

Returns:
The directory path for system configuration files

static const String& configSuffix (  )  [inline, static]

Get the configuration file suffix

Returns:
The suffix for configuration files

static const 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()

Parameters:
path Relative path to extra modules to be loaded

static const String& moduleSuffix (  )  [inline, static]

Get the module filename suffix

Returns:
The suffix for module files

static const char* pathSeparator (  )  [static]

Get the canonical path element separator for the operating system

Returns:
The operating system specific path element separator

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.

Returns:
A reference to the read-only engine configuration

static unsigned int runId (  )  [static]

Get a - supposedly unique - instance ID

Returns:
Unique ID of the current running instance

static const NamedList& runParams (  )  [inline, static]

Get the engine parameters specific to this run.

Returns:
A reference to the list of run specific parameters

static void init (  )  [static]

Reinitialize the plugins

static void halt ( unsigned int  code  )  [static]

Stop the engine and the entire program

Parameters:
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

Parameters:
code Return code of the program
gracefull Attempt to wait until no plugin is busy
Returns:
True if restart was initiated, false if exiting or no supervisor

static bool exiting (  )  [inline, static]

Check if the engine is currently exiting

Returns:
True if exiting, false in normal operation

static bool install ( MessageHandler handler  )  [static]

Installs a handler in the dispatcher.

Parameters:
handler A pointer to the handler to install
Returns:
True on success, false on failure

static bool uninstall ( MessageHandler handler  )  [static]

Uninstalls a handler drom the dispatcher.

Parameters:
handler A pointer to the handler to uninstall
Returns:
True on success, false on failure

static bool enqueue ( Message msg  )  [static]

Enqueue a message in the message queue for asynchronous dispatching

Parameters:
msg The message to enqueue, will be destroyed after dispatching
Returns:
True if enqueued, false on error (already queued)

static bool enqueue ( const char *  name  )  [inline, static]

Convenience function. Enqueue a new parameterless message in the message queue

Parameters:
name Name of the parameterless message to put in queue
Returns:
True if enqueued, false on error (already queued)

static bool dispatch ( Message msg  )  [static]

Synchronously dispatch a message to the registered handlers

Parameters:
msg Pointer to the message to dispatch
Returns:
True if one handler accepted it, false if all ignored

static bool dispatch ( Message msg  )  [static]

Synchronously dispatch a message to the registered handlers

Parameters:
msg The message to dispatch
Returns:
True if one handler accepted it, false if all ignored

static bool dispatch ( const char *  name  )  [static]

Convenience function. Dispatch a parameterless message to the registered handlers

Parameters:
name The name of the message to create and dispatch
Returns:
True if one handler accepted it, false if all ignored

void setHook ( MessagePostHook hook,
bool  remove = false 
) [inline]

Install or remove a hook to catch messages after being dispatched

Parameters:
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

Returns:
Count of plugins in use

unsigned int messageCount (  )  [inline]

Get the number of messages waiting in the queue

Returns:
Count of messages in the queue

unsigned int handlerCount (  )  [inline]

Get the number of handlers in the dispatcher

Returns:
Count of handlers

bool loadPluginDir ( const String relPath  ) 

Loads the plugins from an extra plugins directory

Parameters:
relPath Path to the extra directory, relative to the main modules
Returns:
True if the directory could at least be opened

static void pluginMode ( PluginMode  mode  )  [static]

Set the load and init mode of the currently loading Plugin

Parameters:
mode Load and init mode, default LoadLate

bool loadPlugin ( const char *  file,
bool  local = false 
) [protected]

Loads one plugin from a shared object file

Parameters:
file Name of the plugin file to load
local Attempt to keep symbols local if supported by the system
Returns:
True if success, false on failure

void loadPlugins (  )  [protected]

Loads the plugins from the plugins directory

void initPlugins (  )  [protected]

Initialize all registered plugins


The documentation for this class was generated from the following file:

Generated on Mon Aug 11 16:18:52 2008 for Yate by  doxygen 1.5.6