ISIS Core Library 0.7.2 (api 3.0.0)
|
00001 // -*- fill-column: 120; c-basic-offset: 4 -*- 00002 /**************************************************************** 00003 * 00004 * Copyright (C) ISIS Dev-Team 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 3 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00019 * 00020 * Author: Enrico Reimer, <reimer@cbs.mpg.de>, 2010 00021 * 00022 *****************************************************************/ 00023 00024 #ifndef APPLICATION_HPP 00025 #define APPLICATION_HPP 00026 00027 #include "progparameter.hpp" 00028 00029 namespace isis 00030 { 00031 namespace util 00032 { 00033 00047 class Application 00048 { 00049 const std::string m_name; 00050 std::string m_filename; 00051 std::list<std::pair<std::string, std::string> > m_examples; 00052 void addLoggingParameter( std::string name ); 00053 00054 protected: 00055 typedef void ( Application::*setLogFunction )( LogLevel level )const; 00056 std::map<std::string, std::list<setLogFunction> > logs; 00057 virtual boost::shared_ptr<MessageHandlerBase> getLogHandler( std::string module, isis::LogLevel level )const; 00058 00059 public: 00060 00061 ParameterMap parameters; 00062 00071 Application( const char name[] ); 00072 virtual ~Application(); 00073 00098 template<typename MODULE> void addLogging( std::string name ) { 00099 addLoggingParameter( name ); 00100 logs[name].push_back( &Application::setLog<MODULE> ); 00101 } 00107 void removeLogging( std::string name ); 00108 00114 void addExample( std::string parameters, std::string desc ); 00115 00125 virtual bool init( int argc, char **argv, bool exitOnError = true ); 00130 virtual void printHelp( bool withHidden = false )const; 00132 template<typename MODULE> void setLog( LogLevel level ) const { 00133 if ( !MODULE::use ); 00134 else _internal::Log<MODULE>::setHandler( getLogHandler( MODULE::name(), level ) ); 00135 00136 LOG( Debug, info ) << "Setting logging for module " << MSubject( MODULE::name() ) << " to level " << level; 00137 } 00138 //get the version of the coreutils 00139 static const std::string getCoreVersion( void ); 00140 }; 00141 } 00142 } 00143 #endif // APPLICATION_HPP