// {{{ the iWear header
/**
 * $Id$
 * $Revision$
 * $Author$
 * $Date$
 * 
 * Author: cob
 *
 * 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 __CONSOLEOUTPUTMODULE_H
#define __CONSOLEOUTPUTMODULE_H

#ifndef __OUTPUTMODULE_H
#include <iwear_output/outputmodule.h>
#endif

#ifndef __OUTPUTMANAGER_H
#include <iwear_output/outputmanager.h>
#endif

#ifndef __TEXTDATAFUNCTOR_H
#include <iwear_console_output/textdatafunctor.h>
#endif

namespace iwear{
    namespace output{

/**
 * This class ConsoleOutputModule derives from OutputModule and at least has 
 * to implement the display-function that should contain the main finctionality
 * of this module.
 */
class ConsoleOutputModule : 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.
     */
    ConsoleOutputModule(OutputManager* output_manager, Configuration& c);

    /**
     * The destructor.
     */
    virtual ~ConsoleOutputModule();

    /**
     * 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);

    /**
     * The most important funtion of this class. Inherited from OutputModule
     * and implemented here. It just takes the string out of the OutputData
     * and writes it to std::cout.
     * @param data
     */
    virtual display_state display(OutputData* data);

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

    /**
     * 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);

    /**
     * Handle method which is called by the consolemodulefunctor which
     * inherits from outputdatafunctor
     */
    virtual void handle_text_content_changed(TextDataFunctor* tdf);


 protected:

    /**
     * mapping from TextDataFunctor to TextData where the
     * functor is registered
     */
    map<const TextDataFunctor*, OutputData*, deref_less<const TextDataFunctor*> > functor2output;

    /**
     * mapping from TextData to TextDataFunctor 
     */
    map<const OutputData*, TextDataFunctor*, deref_less<const OutputData*> > output2functor;

};

    } // namespace output
} // namespace iwear

#endif // __CONSOLEOUTPUTMODULE_H

