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

// Standard includes
#include <stdlib.h>


// iWear includes
#include <iwear_output/outputmodule.h>
#include <iwear_output_griffin/display.h>
#include <iwear_output_griffin/griffinoutputdatafunctor.h>

#include <iwear_output/imagedata.h>
#include <iwear_uiservices/menudata.h>
#include <iwear_output/textdata.h>
#include <iwear_output/widgetdata.h>

#include <algorithm>

using namespace iwear::uiservices;

namespace iwear{
namespace output{

    // --- Forward declarations
    class OutputManager;
    class OutputData;

/**
 * Griffin main class
 * @author Carsten Rachuy
 */
class Griffin : public OutputModule {

 public:
    
    /**
     * The standard constructor of this module. The module will register itself 
     * at the OutputManager.
     * @param output_manager the manager that is responsible for this module.
     */
    Griffin(OutputManager* output_manager, Configuration& configuration);

    /**
     * The destructor.
     */
    virtual ~Griffin(void);

    /**
     * Display
     * @param data
     */
    virtual display_state display(OutputData* data);

    /**
     * Stop displaying the output data handed over as parameter
     * @param data the output data whose display should be stopped
     */
    virtual bool stop_display(OutputData* data);

    /**
     * Implements the reaction of the module when the application
     * in focus changes
     * @param application_id The id of the application
     */
    virtual void apply_application_focus_change(const uid& application_id);

    /**
     * Inherited from Module and has to be implemened.
     * @param p_state the state to be set.
     * @return if he operation was successful. TODO: return-values?
     */
    virtual uint32_t activate_power_state(power_state p_state);

    
    /**
     * This function is to be called from the
     * GriffinOutputDataFunctor and starts the processing
     * of an event.
     */
    void handle_event(      OutputData*                 output_data,
		      const OutputDataFunctorParameter& parameter   );
 
 private:

    /**
     * Returns the nuber ob output data which can simultaniously be
     * displayed by griffin.
     */
    inline uint32_t get_number_of_displayable_output_data(const string& type) const {
	return this->griffin_display->get_number_of_displayable_output_data(type);
    }

    // Fields

    /**
     * Map for storing data functors for deletion of functors
     * It goes from application_uid to a map from 
     * output data uid to a pair of functor / appropriate data
     */
    map<uid, map<uid, pair<GriffinOutputDataFunctor*,OutputData*> > > output_data_functors;

    /**
     * Pointer to the display class
     */
    Display* griffin_display;

};

} // namespace output
} // namespace iwear

#endif // __GRIFFIN_H


