Engine's running mode can be read by any component.

git-svn-id: http://yate.null.ro/svn/yate/trunk@1233 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
paulc 2007-03-26 17:38:50 +00:00
parent c013598dc4
commit 25f9f72297
2 changed files with 23 additions and 3 deletions

View File

@ -139,6 +139,7 @@ String Engine::s_modpath(MOD_PATH);
String Engine::s_extramod;
String Engine::s_modsuffix(DLL_SUFFIX);
Engine::RunMode Engine::s_mode = Engine::Stopped;
Engine* Engine::s_self = 0;
int Engine::s_haltcode = -1;
int EnginePrivate::count = 0;
@ -556,6 +557,7 @@ Engine::~Engine()
m_dispatcher.clear();
plugins.clear();
m_libs.clear();
s_mode = Stopped;
s_self = 0;
}
@ -1227,6 +1229,8 @@ int Engine::main(int argc, const char** argv, const char** env, RunMode mode, bo
if (fail)
return EINVAL;
s_mode = mode;
s_cfgfile = cfgfile;
if (s_cfgfile.endsWith(".exe") || s_cfgfile.endsWith(".EXE"))
s_cfgfile = s_cfgfile.substr(0,s_cfgfile.length()-4);

View File

@ -693,9 +693,10 @@ public:
* Running modes - run the engine as Console, Client or Server.
*/
enum RunMode {
Console = 0,
Client = 1,
Server = 2
Stopped = 0,
Console = 1,
Client = 2,
Server = 3,
};
/**
@ -729,6 +730,20 @@ public:
*/
static Engine* self();
/**
* Get the running mode of the engine
* @return Engine's run mode as enumerated value
*/
static RunMode mode()
{ return s_mode; }
/**
* Check if the engine is running as telephony client
* @return True if the engine is running in client mode
*/
inline static bool clientMode()
{ return s_mode == Client; }
/**
* Register or unregister a plugin to the engine.
* @param plugin A pointer to the plugin to (un)register
@ -949,6 +964,7 @@ private:
static String s_extramod;
static String s_modsuffix;
static int s_haltcode;
static RunMode s_mode;
};
}; // namespace TelEngine