From: Christian P. <cp...@us...> - 2005-01-18 17:52:37
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/App In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31834/include/pclasses/App Modified Files: SimpleApp.h Log Message: Export SimpleApp. Added SimpleApp::finish(). Re-worked signal handling. Index: SimpleApp.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/App/SimpleApp.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- SimpleApp.h 15 Jan 2005 23:59:53 -0000 1.1 +++ SimpleApp.h 18 Jan 2005 17:52:24 -0000 1.2 @@ -21,7 +21,8 @@ #ifndef P_App_SimpleApp_h #define P_App_SimpleApp_h -#include <pclasses/pclasses-config.h> +#include <pclasses/pclasses-config.h> // reqd for PCLASSES_RETSIGTYPE +#include <pclasses/Export.h> #include <pclasses/NonCopyable.h> #include <pclasses/System/Semaphore.h> #include <pclasses/App/AppDetails.h> @@ -31,7 +32,7 @@ namespace App { //! Simple application base class -class SimpleApp: public NonCopyable { +class PAPP_EXPORT SimpleApp: public NonCopyable { public: //! Simple application constructor /*! @@ -43,10 +44,10 @@ //! Init & run the application /*! - This method initializes the application by calling - init(). When initialization was successfull the main - method will be called. Before returning with the app's - exit code, cleanup() will be called. + This method initializes the application by calling init(). When + initialization was successfull the main method will be called. + Before returning with the app's exit code, cleanup() will be called, + but only when init() was successfull. \return the applications exit code, returned by the main() method */ int run(int argc, char* argv[]); @@ -59,9 +60,6 @@ */ void stop(int code); - //! Terminate application on signal - virtual void terminate(int signal); - //! Returns a reference to the about data const AppDetails& details() const throw(); @@ -74,7 +72,7 @@ Overload this method to implement application initialization. Remember to call the default implementation to initialize the process signal handlers. - \return returns zero if initialization was successfull, + \return should return zero when initialization was successfull, otherwise the exit code of the application. */ virtual int init(int argc, char* argv[]); @@ -95,16 +93,21 @@ exiting. */ virtual void cleanup(); - - //! Process signal handler - static PCLASSES_RETSIGTYPE signal_handler(int); - + + //! Called right before exiting the process, but after cleanup(). + virtual void finish(); + + //! Signal handler + virtual void signal(int sig); + //! Returns a reference to the exit-semaphore System::Semaphore& exitSem() const throw(); //! Returns the application's exit code int exitCode() const throw(); + static PCLASSES_RETSIGTYPE signalHandler(int); + private: System::Semaphore _exitSem; int _exitCode; |