#include <Application.h>
Inheritance diagram for Tools::Application:
Public Member Functions | |
Application (void) | |
virtual | ~Application (void) |
virtual void | initialize (void) |
Here you can setup your application before any other code is executed. | |
virtual void | initialize (int argc, char **argv) |
Here you can setup your application before any other code is executed. | |
virtual void | initializeCommandLineParser (CommandLineParser *parser) |
Teach command line parser the arguments. | |
virtual void | release (void) |
Here you can do some clean up before the application quits. | |
virtual void | defaultExceptionHandler (GenericException *ex) |
This method is called in case the exception arise inside one of startUp, execute or shutDown method. | |
virtual void | run (void) |
virtual void | startUp (void) abstract |
In this method you can prepare your application to run. | |
virtual void | shutDown (void) abstract |
In this method you can do application clean up. | |
virtual void | execute (void) abstract |
This method should contain main application loop. | |
Static Public Member Functions | |
static Application * | current (void) |
Public Attributes | |
Stream * | cin |
Standard input stream. | |
Stream * | cout |
Standard output stream. | |
Stream * | cerr |
Standard error stream. | |
Static Protected Attributes | |
static Application * | _current = nil |
|
Definition at line 39 of file Application.cc. References _current, cerr, cin, and cout. 00040 { 00041 _current = this; 00042 cin = (new FileAccessor(0))->withEncoding("default")->readStream(); 00043 cout = (new FileAccessor(1))->withEncoding("default")->writeStream(); 00044 dynamic_cast<EncodedStream *>(cout)->replacementCharacter(Character::value('?')); 00045 cerr = (new FileAccessor(2))->withEncoding("default")->writeStream(); 00046 dynamic_cast<EncodedStream *>(cerr)->replacementCharacter(Character::value('?')); 00047 }
|
|
Definition at line 49 of file Application.cc.
|
|
Definition at line 55 of file Application.cc. References _current. Referenced by Tools::Daemon::globalSignalHandler(). 00056 { 00057 return _current; 00058 }
|
|
This method is called in case the exception arise inside one of startUp, execute or shutDown method. You can overwrite this to handle any uncatched exception properly. Definition at line 95 of file Application.cc. References cerr, Core::Object::printOn(), and Core::GenericException::printStackOn(). Referenced by run(). 00096 { 00097 ex->printOn(cerr); 00098 ex->printStackOn(cerr); 00099 cerr->flush(); 00100 }
|
|
This method should contain main application loop. This method is guarded by global exception handler. Referenced by run(). |
|
Here you can setup your application before any other code is executed. Command line arguments parsing in done here. This method is not ment to be overwritten by any child class (except some special cases). Overwrite the initialize() method instead. Definition at line 66 of file Application.cc. References cerr, Core::Stream::flush(), initialize(), initializeCommandLineParser(), Core::Stream::print(), and Tools::CommandLineParser::process(). 00067 { 00068 /* Let the application initialize */ 00069 initialize(); 00070 /* Parse command line arguments */ 00071 CommandLineParser *parser = new CommandLineParser; 00072 try { 00073 initializeCommandLineParser(parser); 00074 parser->process(argc, argv); 00075 } 00076 catch (CommandLineParserError *ex) { 00077 cerr->print(ex); 00078 cerr->flush(); 00079 exit(1); 00080 } 00081 }
|
|
Here you can setup your application before any other code is executed. Don't forget to call your parent's method. This method is ment to initialize the Application object. To initialize the whole application use the startUp method. Definition at line 61 of file Application.cc. Referenced by initialize(). 00062 {
00063 /* Nothing */
00064 }
|
|
Teach command line parser the arguments. If you want to parse command line arguments this is the method you want to overwrite. To setup arguments use parser methods: addMandatoryArgument(longArgumentName, [shortArgumentName,] callbackReceiver, callbackMethod [, userData]); addOptionalArgument(londArgumentName, [shortArgumentName,] callbackReceiver, callbackMethod [, userData]); addMandatoryArgumentWithParameter(longArgumentName, [shortArgumentName,] callbackReceiver, callbackMethod); addOptionalArgumentWithParameter(longArgumentName, [shortArgumentName,] callbackReceiver, callbackMethod); Definition at line 83 of file Application.cc. Referenced by initialize(). 00084 {
00085 /* nothing */
00086 }
|
|
Here you can do some clean up before the application quits. Don't forget to call your parent's method. This method is invoked even if main application (startUp, execute or shutDown method) raises an exception. This method is ment to clean up the Application object. To clean up the whole application use the shutDown method. Definition at line 88 of file Application.cc. References cerr, cout, and Core::Stream::flush().
|
|
Reimplemented in Tools::Daemon. Definition at line 103 of file Application.cc. References defaultExceptionHandler(), execute(), shutDown(), and startUp(). Referenced by Tools::Daemon::run(). 00104 { 00105 try { 00106 startUp(); 00107 execute(); 00108 shutDown(); 00109 } 00110 catch (GenericException *ex) { 00111 defaultExceptionHandler(ex); 00112 } 00113 }
|
|
In this method you can do application clean up. This method is guarded by global exception handler. Referenced by run(). |
|
In this method you can prepare your application to run. This method is guarded by global exception handler. Referenced by run(). |
|
Definition at line 37 of file Application.cc. Referenced by Application(), current(), and ~Application(). |
|
Standard error stream.
Definition at line 43 of file Application.h. Referenced by Application(), defaultExceptionHandler(), initialize(), release(), and Tools::Daemon::run(). |
|
Standard input stream.
Definition at line 41 of file Application.h. Referenced by Application(). |
|
Standard output stream.
Definition at line 42 of file Application.h. Referenced by Application(), and release(). |