/**
 * $Id$
 * $Revision$
 * $Author$
 * $Date$
 *
 * 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 __OUTPUTDATAFUNCTOR_H
#define __OUTPUTDATAFUNCTOR_H

// Standard includes
#include <string>

// iWear includes
#ifndef __FUNCTOR_H
#include <iwear/functor.h>
#endif

#ifndef __UID_H
#include <iwear/uid.h>
#endif

namespace iwear {
namespace output {

// forward declaration - the class is actually included in the cpp
class OutputDataFunctorParameter;

class OutputDataFunctor : public Functor<OutputDataFunctorParameter> {

public:

    /**
     * Constructor
     * @param type Should fit to the TYPE variable of the
     * fitting output data
     */
    OutputDataFunctor(const std::string& type);
    
    /**
     * Destructor for OutputDataFunctor.
     */
    virtual ~OutputDataFunctor(void);

    /**
     * Get the type of the output data determining the OutputModule.
     *
     * @return The type of the outputdatafunctor as a string.
     */
    inline const std::string& get_type(void) const {
	return this->type;
    }

    /**
     * Method that is called on the delivery of an event. It has to be
     * implemented by deriving classes. The correct type of the parameter
     * should be ensured - therefore it can be casted to the appropriate type.
     *
     * @param odf_parameter The Parameter that contains further information on
     * the change that happened.
     *
     * @note: After this call returns the odf_parameter will be deleted by the
     * calling event!!! So if it's needed afterwards you need to make a copy!!!
     */
    virtual void operator()(const OutputDataFunctorParameter& odf_parameter) = 0;

    /**
     * Compares the uid's contained in the OutputData's.
     */
    inline bool operator<(const OutputDataFunctor& od) const{
        return id < od.id;
    }

    /**
     * Compares the uid's contained in the OutputData's.
     */
    inline bool operator>(const OutputDataFunctor& od) const{
        return id > od.id;
    }

    /**
     * Compares the uid's contained in the OutputData's.
     */
    inline bool operator==(const OutputDataFunctor& od) const{
        return id == od.id;
    }

    /**
     * Compares the uid's contained in the OutputData's.
     */
    inline bool operator!=(const OutputDataFunctor& od) const{
        return id != od.id;
    }

private:

    /**
     * The type of the OutputData.
     */
    const std::string type;

    const uid id;
};

} // namespace output
} // namespace iwear

#endif // __OUTPUTDATAFUNCTOR_H

