// File: inputmanager.cpp
// Created by: <Joern Reimerdes>
// Created on: 25.02.1005

/**
 * inputmodule.h - is part of the iwear-framework
 * @file
 * $Id$
 * $Revision$
 * $Author$
 * $Date$
 *
 * This file is part of The iWear Framework.
 * In particular this file is part of the Framework Input 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 __INPUTMODULE_H
#define __INPUTMODULE_H

#include <list>

#ifndef __CONSTANTS_H
#include <iwear/constants.h>
#endif

#ifndef __MODULE_H
#include <iwear/module.h>
#endif

#ifndef __INPUTDATA_H
#include <iwear_input/inputdata.h>
#endif

#ifndef __INPUTENUMS_H
#include <iwear_input/inputenums.h>
#endif

#ifndef __CONFIGURATION_H
#include <iwear/configuration.h>
#endif

using namespace iwear;

namespace iwear { 
namespace input {
    class InputManager;

    /** Interface for all InputModules that will be implemented.
     * The InputModule implements all features which are needed by 
     * all InputModules. 
     * Inheriting classes must add the InputEventTypes to the
     * input_event_types list.
     */
    class InputModule : public Module{
	/* So InputManager can set the input_manager-member when an
	   InputModule is registered externally. */
	friend class InputManager;

    public:
		

   	/** Creates a new InputModule. 
	 * The InputModule should be added to the input_manager at the
	 * end of the constructor of every special InputModule. This
	 * way we make sure that the Module is registered after
	 * the module has initialised itself.
   	 * @param input_manager A pointer to the
	 *  input_manager to which the InputModule should be registered
	 *  to.
	 * @param name The type/name of the input module.
	 */
	InputModule(InputManager* input_manager, 
		    const string& name,
		    Configuration& conf);

	/** Destroys the InputModule.  
	 * @note: All inplemented InputModules should deregister
	 *  itself from the InputManager.
	 */
	virtual ~InputModule();
	
	/** Gets the basic type of the module. 
	 * Overrides the inherited pure virtual function from Module.
	 * @return module_type Returns the enum value input_module for
	 *  all inheriting Modules.
	 */
	inline virtual module_type get_module_type( void ) const { 
	    return input_module; 
	}

	/** Gets teh special type of the InputModule.
	 * @return const string The type name of the InputModule. 
	 *  This should be unique.
	 */
	inline const string get_input_module_type( void ) const {
	    return this->get_name();
	}

	/** Dispatches an input event.
	 * Should be called by the subclass to fire an event.
	 * @param input_data A reference to the InputData
	 *  which should be dispatched by the InputManager.
	 */
	void dispatch_input_event(InputData& input_data);		

    protected:

	Configuration& configuration;
	
	/** The global InputManager. */
	InputManager* input_manager;

	/** Adds an InputEventType to the list of capable events.
	 * @param input_event_type The event type
	 *  which should be added to the list of capable event types.
	 */
	inline void add_input_event_type(InputEventType input_event_type){
	    this->input_event_types->push_back(input_event_type);
	}

    private:
	
	/** The event types which are supported by the input module.
	 */
	list<InputEventType>* input_event_types;

    };
} // namespace input
} //namespace iwear

#endif	// __INPUTMODULE_H

