00001 // baseApp.C 00002 00003 #include <iostream> 00004 00005 using std::cerr ; 00006 using std::endl ; 00007 00008 #include "baseApp.h" 00009 #include "BESGlobalIQ.h" 00010 #include "BESException.h" 00011 00012 Application *Application::_theApplication = 0 ; 00013 00014 baseApp:: 00015 baseApp(void) 00016 { 00017 Application::_theApplication = this ; 00018 } 00019 00020 baseApp:: 00021 ~baseApp(void) 00022 { 00023 Application::_theApplication = 0 ; 00024 } 00025 00026 int baseApp:: 00027 main( int argC, char **argV ) 00028 { 00029 int retVal = 0 ; 00030 if((retVal = initialize(argC, argV)) != 0) 00031 { 00032 cerr << "baseApp::initialize - failed" << endl ; 00033 } 00034 else 00035 { 00036 retVal = run() ; 00037 retVal = terminate(retVal) ; 00038 } 00039 return retVal ; 00040 } 00041 00042 int baseApp:: 00043 initialize( int argC, char **argV ) 00044 { 00045 int retVal = 0 ; 00046 00047 // set the locale for the applications, currently only C and POSIX are 00048 // supported 00049 setlocale( LC_ALL, "" ) ; 00050 00051 // initialize application information 00052 try 00053 { 00054 if( BESGlobalIQ::BESGlobalInit( argC, argV ) != true ) 00055 { 00056 retVal = 1 ; 00057 } 00058 } 00059 catch( BESException &e ) 00060 { 00061 cerr << "Global Initialization failed" << endl ; 00062 cerr << e.get_message() << endl ; 00063 } 00064 00065 return retVal ; 00066 } 00067 00068 int baseApp:: 00069 run( void ) 00070 { 00071 return 1 ; 00072 } 00073 00074 int baseApp:: 00075 terminate( int sig ) 00076 { 00077 if( sig ) 00078 { 00079 cerr << "baseApp::terminating with value " << sig << endl ; 00080 } 00081 BESGlobalIQ::BESGlobalQuit() ; 00082 00083 return sig ; 00084 } 00085