Added engine checker class. Added check point after parsing the command line and changing current directory.

git-svn-id: http://voip.null.ro/svn/yate@2559 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
marian 2009-04-02 14:35:51 +00:00
parent 64ac34a375
commit 14e5a8cd94
2 changed files with 34 additions and 0 deletions

View File

@ -209,6 +209,13 @@ static ObjList plugins;
static ObjList* s_cmds = 0;
static unsigned int s_runid = 0;
static EngineCheck* s_engineCheck = 0;
void EngineCheck::setChecker(EngineCheck* ptr)
{
s_engineCheck = ptr;
}
class SLib : public String
{
public:
@ -1734,6 +1741,9 @@ int Engine::main(int argc, const char** argv, const char** env, RunMode mode, bo
if (workdir)
::chdir(workdir);
if (s_engineCheck && !s_engineCheck->check(s_cmds))
return s_haltcode;
#ifdef _WINDOWS
if ((mode == Server) && !service)
service = YSERV_RUN;

View File

@ -711,6 +711,30 @@ bool UNLOAD_PLUGIN(bool unloadNow);
#define UNLOAD_PLUGIN(arg) extern "C" bool _unload(bool arg)
#endif
/**
* Base class for engine running stage checkers.
* Descendants may check specific conditions and decide to stop the engine.
* There should be only one (static) instance of an engine checker
* @short Engine checker interface
*/
class YATE_API EngineCheck
{
public:
/**
* Check running conditions. This method is called by the engine in the initialize process
* @param cmds Optional list of strings containing extra command line parameters
* (not parsed by the engine)
* @return False to stop the program
*/
virtual bool check(const ObjList* cmds) = 0;
/**
* Set the current engine checker
* @param ptr The new engine checker. May be 0 to reset it
*/
static void setChecker(EngineCheck* ptr = 0);
};
/**
* This class holds global information about the engine.
* Note: this is a singleton class.