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

#ifndef __DATASENSOREVENT_H
#include <iwsens/datasensorevent.h>
#endif


#include <string>
#include <time.h>
#include <sys/time.h>

namespace iwear{
namespace context{
    // forward declarations
    class ContextManager;
    class SensorContext;

    /**
     * Is registered at the SensorManager and will be called if an event
     * occurs.
     */
    class SensorEventFunctor : public iwear::sensor::DSEFunctor{
    private:
	/**
	 * A pointer to the ContextManager.
	 */
	ContextManager* cm;
	
	/**
	 * A pointer to the related SensorContext.
	 */
	SensorContext* sc;
	
    protected:
	
    public:
	/**
	 * Constructor of this object.
	 *
	 * @param cm the related ContextManager.
	 *
	 * @param sc the related SensorContext.
	 */
	SensorEventFunctor(ContextManager* cm, SensorContext* sc)
	    : cm(cm), sc(sc)
	{
	}

	/**
	 * The destructor of this object.
	 */
	virtual ~SensorEventFunctor(void){
	}

	/**
	 * This function will be called by the SensorManager when the
	 * sensor-data changes in a specified way. It will cause the
	 * ContextManager to revalidate its actual contexts.
	 *
	 * @param current_value is the value of the sensor when the change was
	 * detected.
	 *
	 * @param active if the context was triggered as true or false.
	 */
	virtual void operator()(const double& current_value, const bool& active);

    };
} // namespace iwear
} // namespace context
#endif // __SENSOREVENTFUNCTOR_H
