A class to represent the application. More...
#include <application.hpp>
Public Member Functions | |
application (int &argc, char **&argv) | |
Constructor. | |
virtual | ~application () |
Destructor. | |
virtual int | run ()=0 |
Protected Attributes | |
arguments_table | m_arguments |
The arguments passed by the system. |
A class to represent the application.
The claw::application understand the following command line arguments :
Definition at line 60 of file application.hpp.
claw::application::application | ( | int & | argc, | |
char **& | argv | |||
) |
Constructor.
The constructor removes from argv all supported arguments, and updates the value of argc.
Definition at line 42 of file application.cpp.
References claw::arguments_table::add_long(), claw::arguments_table::get_integer(), claw::arguments_table::get_string(), claw::arguments_table::has_value(), claw::log_error, claw::log_verbose, claw::log_warning, claw::logger, m_arguments, claw::arguments_table::parse(), claw::log_system::set(), and claw::log_system::set_level().
00043 : m_arguments( argc, argv ) 00044 { 00045 m_arguments.add_long("--log-file", 00046 "The file to use to store log informations.", true, 00047 "file" ); 00048 m_arguments.add_long("--log-level", 00049 "Level of log informations:\n" 00050 "\t\terror: error messages,\n" 00051 "\t\twarning: warning and error messages,\n" 00052 "\t\tverbose: all messages.", true, "string" ); 00053 m_arguments.parse( argc, argv ); 00054 00055 if ( m_arguments.has_value("--log-file") ) 00056 { 00057 std::string log_file = m_arguments.get_string("--log-file"); 00058 logger.set( new file_logger(log_file) ); 00059 } 00060 else 00061 logger.set( new console_logger() ); 00062 00063 if ( m_arguments.has_value( "--log-level" ) ) 00064 { 00065 std::string level = m_arguments.get_string("--log-level"); 00066 00067 if (level == "error") 00068 logger.set_level( log_error ); 00069 else if (level == "warning") 00070 logger.set_level( log_warning ); 00071 else if (level == "verbose") 00072 logger.set_level( log_verbose ); 00073 else 00074 logger.set_level( m_arguments.get_integer("--log-level") ); 00075 } 00076 00077 } // application::application()
claw::application::~application | ( | ) | [virtual] |
Destructor.
Definition at line 83 of file application.cpp.
References claw::log_system::clear(), and claw::logger.
00084 { 00085 logger.clear(); 00086 } // application::~application()
virtual int claw::application::run | ( | ) | [pure virtual] |
arguments_table claw::application::m_arguments [protected] |
The arguments passed by the system.
Definition at line 70 of file application.hpp.
Referenced by application().