|
From: Christian P. <cp...@us...> - 2005-01-16 00:00:07
|
Update of /cvsroot/pclasses/pclasses2/src/App In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23225/src/App Modified Files: Makefile.am Added Files: SimpleApp.cpp Log Message: Fixed install pkgincludedir in Makefile.am Added SimpleApp. --- NEW FILE: SimpleApp.cpp --- /*************************************************************************** * 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. * ***************************************************************************/ #include "pclasses/App/SimpleApp.h" #include <signal.h> namespace P { namespace App { SimpleApp* SimpleApp::_theApp = 0; SimpleApp::SimpleApp(const AppDetails& details) throw() : _exitCode(0), _details(details) { _theApp = this; } SimpleApp::~SimpleApp() throw() { _theApp = 0; } const AppDetails& SimpleApp::details() const throw() { return _details; } int SimpleApp::exitCode() const throw() { return _exitCode; } int SimpleApp::run(int argc, char* argv[]) { int ret = init(argc, argv); if(!ret) { ret = main(); cleanup(); } return ret; } int SimpleApp::init(int argc, char* argv[]) { #ifdef WIN32 { //SetConsoleCtrlHandler((PHANDLER_ROUTINE)SIGTERM_handler, TRUE); signal(SIGTERM, &signal_handler); signal(SIGINT, &signal_handler); } #else { signal(SIGTERM, &signal_handler); signal(SIGQUIT, &signal_handler); signal(SIGINT, &signal_handler); } #endif return 0; } int SimpleApp::main() { _exitSem.wait(); return _exitCode; } void SimpleApp::stop(int code) { _exitCode = code; _exitSem.post(); } void SimpleApp::cleanup() { } void SimpleApp::terminate(int signal) { stop(1); } PCLASSES_RETSIGTYPE SimpleApp::signal_handler(int sig) { #ifdef WIN32 { _theApp->terminate(sig); } #else { if(sig == SIGTERM || sig == SIGQUIT || sig == SIGINT) { signal(sig, SIG_IGN); _theApp->terminate(sig); signal(sig, &signal_handler); } } #endif } SimpleApp* theApp() throw() { return SimpleApp::_theApp; } } // !namespace App } // !namespace P Index: Makefile.am =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/App/Makefile.am,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Makefile.am 11 Jan 2005 14:55:50 -0000 1.2 +++ Makefile.am 15 Jan 2005 23:59:53 -0000 1.3 @@ -3,7 +3,7 @@ lib_LTLIBRARIES = libpclasses_app.la libpclasses_app_la_SOURCES = AppDetails.cpp LogMessage.cpp LogTarget.cpp \ - LogChannel.cpp LogManager.cpp + LogChannel.cpp LogManager.cpp SimpleApp.cpp libpclasses_app_la_LDFLAGS = -no-undefined |