|
From: Christian P. <cp...@us...> - 2005-01-16 00:00:05
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/App In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23225/include/pclasses/App Modified Files: Makefile.am Added Files: SimpleApp.h Log Message: Fixed install pkgincludedir in Makefile.am Added SimpleApp. Index: Makefile.am =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/App/Makefile.am,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Makefile.am 10 Jan 2005 02:38:57 -0000 1.1 +++ Makefile.am 15 Jan 2005 23:59:53 -0000 1.2 @@ -1,3 +1,6 @@ +pclasses_app_includedir=$(pkgincludedir)/App + INCLUDES = METASOURCES = AUTO -pkginclude_HEADERS = AppDetails.h LogMessage.h LogTarget.h LogChannel.h LogManager.h +pclasses_app_include_HEADERS = AppDetails.h LogMessage.h LogTarget.h \ + LogChannel.h LogManager.h SimpleApp.h --- NEW FILE: SimpleApp.h --- /*************************************************************************** * Copyright (C) 2004 by Christian Prochnow * * cp...@se... * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU Library General Public License as * * published by the Free Software Foundation; either version 2 of the * * License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef P_App_SimpleApp_h #define P_App_SimpleApp_h #include <pclasses/pclasses-config.h> #include <pclasses/NonCopyable.h> #include <pclasses/System/Semaphore.h> #include <pclasses/App/AppDetails.h> namespace P { namespace App { //! Simple application base class class SimpleApp: public NonCopyable { public: //! Simple application constructor /*! Simple application constructor. \param about A reference to the applications about data. */ SimpleApp(const AppDetails& details) throw(); virtual ~SimpleApp() throw(); //! 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. \return the applications exit code, returned by the main() method */ int run(int argc, char* argv[]); //! Stop the application /*! The stop functions increases a semaphore to tell the main-loop that it should exit. \param code applications exit code */ 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(); //! Returns a pointer to the application object friend SimpleApp* theApp() throw(); protected: //! Application init /*! 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, otherwise the exit code of the application. */ virtual int init(int argc, char* argv[]); //! Application main loop /*! Overload this method to implement the application main-loop. The default implementation does nothing except waiting for the exit semaphore to become increased and will then return with the value given to the stop() method. \return the applications exit code */ virtual int main(); //! Application cleanup function /*! Implement this method for cleaning up the application before exiting. */ virtual void cleanup(); //! Process signal handler static PCLASSES_RETSIGTYPE signal_handler(int); //! Returns a reference to the exit-semaphore System::Semaphore& exitSem() const throw(); //! Returns the application's exit code int exitCode() const throw(); private: System::Semaphore _exitSem; int _exitCode; const AppDetails& _details; static SimpleApp* _theApp; }; } // !namespace App } // !namespace P #endif |