// {{{ the iWear header 
/**
 * @file
 * $Id$
 * $Revision$
 * $Author$
 * $Date$
 *
 * This file is part of The iWear Framework.
 * In particular this file is part of the Framework Core Library
 *
 * The iWear Framework is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by the
 * Free Software Foundation as in version 2 of the License.

 * 
 * The iWear Framework is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * The iWear Framework; if not, write to the Free Software Foundation, Inc., 59
 * Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
// }}}

#ifndef __APPLICATION_H
#define __APPLICATION_H

#ifndef __APPLICATIONBASE_H
#include <iwear_uiservices/applicationbase.h>
#endif

#ifndef __APPLICATIONSERVICE_H
#include <iwear_uiservices/applicationservice.h>
#endif

namespace iwear{
    namespace uiservices{

class Application : public ApplicationBase
{

 public:

    /**
     * Sinmplified version of the standard constructor for
     * applications in the iWear framework (should be used for
     * new applications)
     * @param application_service pointer to the application service
     * @param application_name the application's short name
     * @param application_description short descriptive text which
     *        tells a user what the application is all about (e.g.
     *        in a tooltip)
     * @param have_switch_button Should the application menu have
     *        a button to leave the application and switch to the 
     *        iWear application service? Default value is 'true'
     * @param have_quit_button Should the application menu have
     *        a button to quit the application? Default value is 'true'
     * @param have_up_button Should the application menu have
     *        a button to go up one level? Default value is 'true'
     */
    Application(ApplicationService* application_service,
		const string& application_name,
		const string& application_description,
		bool have_switch_button = true,
		bool have_quit_button = true,
		bool have_up_button = true );

    /**
     * The special constructor for dynamically loadable applications
     * in the iWear Framework
     * This constructor is special since it doesn't take any 
     * parameters. This leads to a two-stage construction of the 
     * application in question before it can be used just like the
     * normal/static applications created with the above standard 
     * constructor.
     * All intialization which is required in the second part of 
     * construction is handled by a dedicated method written below
     */
//    Application( void );

    /**
     * This function completes the construction of a dynamic
     * Application. Basically it contains outsourced constructor
     * functionality
     * @param application_service pointer to the application service
     * @param application_name the application's short name
     * @param application_description short descriptive text which
     *        tells a user what the application is all about (e.g.
     *        in a tooltip)
     * @param have_switch_button Should the application menu have
     *        a button to leave the application and switch to the 
     *        iWear application service? Default value is 'true'
     * @param have_quit_button Should the application menu have
     *        a button to quit the application? Default value is 'true'
     * @param have_up_button Should the application menu have
     *        a button to go up one level? Default value is 'true'
     * @deprecated
     */
    /*
    virtual void 
    complete_construction(ApplicationService* application_service,
			  const string& application_name,
			  const string& application_description,
			  bool have_switch_button = true,
			  bool have_quit_button = true,
			  bool have_up_button = true);
*/
    /**
     * The destructor
     */
    virtual ~Application(void);

    /**
     * This method is called when the application thread is started
     */
    virtual void Run(void) = 0;

    /**
     * Use dispatch from application service. Therefore this is only
     * a convenience method
     */
    inline virtual void dispatch(EventBase& evt,
			    event_priority prio = prio_normal)
    {
	this->application_service->dispatch(evt, prio);
    }

 protected:

    /**
     * Pointer to the system's application service
     */
    ApplicationService* application_service;

};

    } // namespace uiservices
} // namespace iwear

#endif // __APPLICATION_H

