/**
 * @file
 * $Id$
 * $Revision$
 * $Author$
 * $Date$
 *
 * This file is part of The iWear Framework.
 *
 * 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 __IWEAR_EVENTBASE_H
#define __IWEAR_EVENTBASE_H

namespace iwear
{
/**
 * The EventBase is the all-base class of events that will be delivered. They
 * need to implement two functions, dispatch() and is_triggered()
 */
class EventBase
{
private:
protected:
public:
    virtual ~EventBase() {}
    /**
     * This will do the actual call to the functor. So Parameters must be saved
     * within the Event to be passed to the functor later on.
     * For your convinience, we have template classes Event from that you need
     * to derive and implement a dispatch() there that will call the Functor.
     */
    virtual void dispatch( void ) = 0;

    /**
     * Evaluates to true if the event conditions went true, false otherwise.
     * Subsequent calls should lead to false then, although the conditions may
     * still be the same. E.g. the Event should be triggered if a sensor
     * reaches a certain value. At this point the Event can be seen as
     * triggered, but we certainly only want to be informed once if this
     * happens.
     */
    virtual bool is_triggered( void ) = 0;
};

/**
 * This is the Event class you will mostly want to derive from. Its parameter
 * is a Functor whose type you can define yourself. You need to implement a
 * dispatch() function that will call the functor you will save within this
 * Event, since only you know what parameteres the Functor will need and how to
 * get them.
 */
template<class functor_type>    
class Event : public EventBase
{
private:
protected:
    functor_type& Fun;
    Event( functor_type& fun )
	: Fun(fun) { }
//    something like a reference to functor and virtual functions for asking if event is on/off
public:
};

}

#endif

