Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

nglKernel Class Reference

#include <nglKernel.h>

Inheritance diagram for nglKernel:

nglError nglEvent nglApplication List of all members.

Detailed Description

Kernel, application abstraction base class.

NGL is a framework which can run in various environments. The most trivial one is a regular application. A more advanced scenario would be running as a plugin into a hosting application, such as a web browser for instance.

The kernel is the common interface to all these environments : wether your program is compiled as a regular application or a plugin, one and only one instance of nglKernel is always available in a single environment (to be more precise, in a single process). It provides these essential services :

nglKernel is an abstract class. You must refer to nglKernel derivates to create an instance. See the ubiquitous nglApplication for instance.

The unique nglKernel object is always available via the App pointer.


Public Types

typedef void(* ExitFunc )(void)

Public Member Functions

Life cycle
virtual void Quit (int Code=0)
virtual void AddExit (ExitFunc Func)
virtual void DelExit (ExitFunc Func)
Runtime debugging
virtual void SetDebug (bool Debug)
virtual bool GetDebug ()
Logging and output
virtual nglLogGetLog ()
virtual nglConsoleGetConsole ()
virtual void SetConsole (nglConsole *pConsole)
Application context
nglPath GetPath ()
nglString GetName ()
int GetArgCount ()
nglString GetArg (int Index)
Clipboard
virtual nglClipBoardGetClipBoard ()
virtual nglString GetClipboard ()
virtual bool SetClipboard (const nglString &rString)
User callbacks
virtual void OnInit ()
virtual void OnExit (int Code)

Protected Member Functions

 nglKernel ()
virtual ~nglKernel ()
void IncRef ()
void DecRef ()
void Init ()
void Exit ()
void SetName (const nglString &rName)
void SetPath (const nglPath &rPath)
void ParseCmdLine (char *pCmdLine)
void AddArg (const nglString &rArg)
void DelArg (int Pos, int Count=1)
void CallOnInit ()
void CallOnExit (int Code)
virtual const nglCharOnError (uint &rError) const

Friends

class nglPluginKernel
class nglPlugin


Member Typedef Documentation

typedef void(* nglKernel::ExitFunc)(void)
 

Cleanup callback type. See AddExit().


Constructor & Destructor Documentation

nglKernel::nglKernel  )  [protected]
 

virtual nglKernel::~nglKernel  )  [protected, virtual]
 


Member Function Documentation

void nglKernel::AddArg const nglString rArg  )  [protected]
 

virtual void nglKernel::AddExit ExitFunc  Func  )  [virtual]
 

Register a shutdown callback

Parameters:
Func callback function, must be either a C function or a static C++ method
Register a callback to be triggered when the application is shuting down. Handlers are called in reverse order of registering (last registered is called first).

void nglKernel::CallOnExit int  Code  )  [protected]
 

void nglKernel::CallOnInit  )  [protected]
 

void nglKernel::DecRef  )  [protected]
 

void nglKernel::DelArg int  Pos,
int  Count = 1
[protected]
 

virtual void nglKernel::DelExit ExitFunc  Func  )  [virtual]
 

Unregister a shutdown callback

Parameters:
Func callback function
Unregister a callback registered with AddExit().

void nglKernel::Exit  )  [protected]
 

nglString nglKernel::GetArg int  Index  ) 
 

Return one of the user arguments passed along the execution of the program. Index must be between 0 (first argument) and GetArgCount() - 1. Caution ! The executable name (or invocation name) is not included, use GetName() for this purpose. If Index is out of range, returns an empty string.

int nglKernel::GetArgCount  ) 
 

Return the number of user arguments passed along the execution of the program. Caution ! The executable name (or invocation name) is not included, use GetName() for this purpose.

virtual nglString nglKernel::GetClipboard  )  [virtual]
 

Get the clipboard text content

Returns:
If there is text in the clipboard, returns it, or return an empty string

virtual nglClipBoard& nglKernel::GetClipBoard  )  [virtual]
 

virtual nglConsole& nglKernel::GetConsole  )  [virtual]
 

Gives the application console.

virtual bool nglKernel::GetDebug  )  [inline, virtual]
 

Return run-time debug status

See SetDebug().

virtual nglLog& nglKernel::GetLog  )  [virtual]
 

Gives the application log.

Notably used by the NGL_OUT() and NGL_LOG() macros.

nglString nglKernel::GetName  ) 
 

Returns:
current application name
The application name is implicitely obtained from the application's executable name. However it can be set explicitely with SetName() at any time. The application name serves at least two purposes :

  • allow per-application resources settings (TODO: resources!)
  • nglWindow objects will use the application name as their default title

nglPath nglKernel::GetPath  ) 
 

Returns:
current application's path (includes the binary file name)

void nglKernel::IncRef  )  [protected]
 

void nglKernel::Init  )  [protected]
 

virtual const nglChar* nglKernel::OnError uint rError  )  const [protected, virtual]
 

Parameters:
rError error code
Returns:
error message, or NULL if rError is out of bounds
When the user invokes GetErrorStr() on an object, the OnError() callback is called with the given error code and should return the corresponding message. When several classes have different string error tables in the same hierarchy, the latest derivation's OnError() is called : it should then use a parent-first search. Example :

const nglChar** ChildErrorTable = {_T("no error"), _T("Bad luck"), NULL};

const nglChar* Child::OnError (uint& rError) const
{
  return FetchError(ChildErrorTable, Parent::OnError(rError), rError);
}

Implements nglError.

Reimplemented in nglApplication.

virtual void nglKernel::OnExit int  Code  )  [virtual]
 

This method is called when the application exits.

Parameters:
Code exit code
The exit code is returned by the process to the system. It should be 0 for normal termination (ie. no error encountered), positive otherwise.

The application only quits if :

  • Quit() has been explicitely called and the control has been given back to the event loop
  • the process received a signal (Unix only). HUP, INT, QUIT, PIPE and TERM are currently intercepted.

virtual void nglKernel::OnInit  )  [virtual]
 

This method is called at startup time, as soon as the application is ready to run.

There is always at least one argument, (ArgCnt > 0) and it contains the application name. User parameters are not available on all platforms (MacOS being one of them).

void nglKernel::ParseCmdLine char *  pCmdLine  )  [protected]
 

virtual void nglKernel::Quit int  Code = 0  )  [virtual]
 

Request application ending

Parameters:
Code exit code
Note that some instances (such as plugins) might ignore a call to this method.

Reimplemented in nglApplication.

virtual bool nglKernel::SetClipboard const nglString rString  )  [virtual]
 

Set the text content of the clipboard

Parameters:
rString the text to put into the clipboard
Returns:
returns false if the clipboard is not available (maybe temporarily)

virtual void nglKernel::SetConsole nglConsole pConsole  )  [virtual]
 

Set application console. User still owns the pConsole objects (ie. remember to delete it on application exit).

virtual void nglKernel::SetDebug bool  Debug  )  [virtual]
 

Set run-time debug status

Code enclosed in the DEBUG() macro can be (des)activated at run-time either with SetDebug(), either with the '--nodebug' command-line option if you invoke nglApplication::ParseDefaultArgs().

void nglKernel::SetName const nglString rName  )  [protected]
 

void nglKernel::SetPath const nglPath rPath  )  [protected]
 


Friends And Related Function Documentation

friend class nglPlugin [friend]
 

friend class nglPluginKernel [friend]
 


Generated on Thu Feb 3 22:26:10 2005 for NGL by  doxygen 1.4.1