nglKernel Class Reference
#include <nglKernel.h>
Inheritance diagram for nglKernel:
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 :
- initialisation and exit callbacks
- event manager interfaces, used internally by timers, windows, etc
- a global and unique application log, which is used by almost any instance of a regular NGL class
- a global and unique application console, which is the default output for the application log. See nglConsole for more info on the default console
- various other global 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.
Member Typedef Documentation
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:
-
Unregister a callback registered with AddExit(). |
| void nglKernel::Exit |
( |
|
) |
[protected] |
|
|
|
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 nglConsole& nglKernel::GetConsole |
( |
|
) |
[virtual] |
|
|
|
Gives the application console. |
| virtual bool nglKernel::GetDebug |
( |
|
) |
[inline, virtual] |
|
| virtual nglLog& nglKernel::GetLog |
( |
|
) |
[virtual] |
|
|
|
- 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
|
|
|
- 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:
-
- 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:
-
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:
-
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] |
|
| void nglKernel::SetName |
( |
const nglString & |
rName |
) |
[protected] |
|
| void nglKernel::SetPath |
( |
const nglPath & |
rPath |
) |
[protected] |
|
Friends And Related Function Documentation
friend class nglPluginKernel [friend] |
|
Generated on Thu Feb 3 22:26:10 2005 for NGL by
1.4.1