/* libzz
*
* This program is distributed under the GNU General Public License, version 2.
* A copy of this license is included with this source.
*
* Copyright 2000-2006, Toni Thomsson <toni@tonjac.org>
*/
#ifndef zz_application_h
#define zz_application_h
#include <zz_log.h>
#include <zz_string.h>
#include <zz_exception.h>
#include <zz_arguments.h>
#include <zz_export.h>
/**
Base for a application
@author Toni Thomsson, toni@tonjac.org
*/
class ZZ_API CzzApplication
{
public:
/**
Creates a application object with a logger
logging with given application name
@see CzzLog
@param name Name
*/
CzzApplication( const CzzString& name );
// Description: Destruktor
virtual ~CzzApplication();
/**
Called by the main() function if you link main.obj
to your application
@param args Arguments to main
*/
void Run( CzzArguments& args );
/**
Called by Run() when the application starts.
Default implementation just
creates a logger (CzzLog).
@see CzzLog
*/
virtual void OnStart( void );
/**
Called by main when the before the application terminates.
Default implementation releases the logger.
*/
virtual void OnEnd( void );
/**
Called when an CzzException is caught in main.
Default implementation doesn't do anything.
@param e Error
*/
virtual void OnException( CzzException& e ) { };
/**
Called when a undefined exception is caught in main.
Default implementation doesn't do anything.
*/
virtual void OnUnhandledException( void ) { };
/**
Returns the singleton object
*/
static CzzApplication* getInstance( void );
protected:
/** Logger */
CzzLog* m_Log;
/** Argument map */
CzzArguments m_Arguments;
/** Application name */
CzzString m_Name;
/** Singleton */
static CzzApplication* m_pThis;
};
#endif // zz_application_h