// {{{ the iWear header
/**
 * $Id$
 * $Revision$
 * $Author$
 * $Date$
 *
 * This file is part of The iWear Framework.
 * In particular this file is part of the Framework Output
 *
 * 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 __APPLICATIONSERVICEEXITFUNCTOR_H
#define __APPLICATIONSERVICEEXITFUNCTOR_H

#ifndef __MENUFUNCTOR_H
#include <iwear_uiservices/menufunctor.h>
#endif

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

#ifndef __UID_H
#include <iwear/uid.h>
#endif


namespace iwear{
    namespace uiservices{


class ApplicationServiceExitFunctor : public MenuFunctor
{

 public:

    /**
     * The constructor
     * @param app_serv pointer to the application service
     * @param app_id pointer to the application id
     */
    ApplicationServiceExitFunctor(ApplicationService* app_serv,
				  const uid* app_id)
	: app_serv(app_serv),
	  app_id(app_id)
    {
	// Nothing yet to do!
    }

    /**
     * The destructor
     */
    virtual ~ApplicationServiceExitFunctor(void)
    {
	// Nothing yet to be done!
    }

 protected:

    /**
     * When an application switches back to the application 
     * service we need to switch the application focus
     */
    inline void on_event_switch( void ){
	this->app_serv->switch_application_focus();
    }

    /**
     * Push a quit request into the dedicated event queue of
     * the application service. This should be lightweight enough
     */
    inline void on_event_quit( void ){
	this->app_serv->push_exit_event(this->app_id);
    }

    /**
     * pointer to the application service
     */
    ApplicationService* app_serv;

    /**
     * pointer to the application whose menu is under scrutiny
     */
    const uid* app_id;

};

    } // namespace uiservices
} // namespace iwear

#endif // __APPLICATIONSERVICEEXITFUNCTOR_H


