claw::application Class Reference

A class to represent the application. More...

#include <application.hpp>

List of all members.

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.

Detailed Description

A class to represent the application.

The claw::application understand the following command line arguments :

Author:
Julien Jorge

Definition at line 60 of file application.hpp.


Constructor & Destructor Documentation

claw::application::application ( int &  argc,
char **&  argv 
)

Constructor.

Parameters:
argc Number of arguments to the program.
argv The arguments of the program.

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()


Member Function Documentation

virtual int claw::application::run (  )  [pure virtual]

Member Data Documentation

The arguments passed by the system.

Definition at line 70 of file application.hpp.

Referenced by application().


The documentation for this class was generated from the following files:

Generated on 9 Nov 2009 for CLAW Library (a C++ Library Absolutely Wonderful) by  doxygen 1.6.1