/**
 * $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 __OUTPUTDATAEVENT_H
#define __OUTPUTDATAEVENT_H

// Standard includes

// iWear includes
#include <iwear/refcountevent.h>

#ifndef __OUTPUTDATAFUNCTOR_H
#include <iwear_output/outputdatafunctor.h>
#endif

namespace iwear {
namespace output {

/**
 * This class is needed for event dispatching of the OutputData. It already
 * contains all functionality and should not be a base class for other
 * classes.
 */
class OutputDataEvent : public iwear::RefCountEvent<OutputDataFunctor>{

public:
    
    /**
     * Constructor for this class - please note that the SECOND parameter is
     * owned by this object after this call and will be deleted soon - so
     * don't hold a pointer to the odf_parameter after this call!
     *
     * @param odf The functor that will be called when this event is
     * dispatched.
     *
     * @param counter should be the same for all events dispatched by an
     * outputdata, because the data should only destroy itself if no events
     * are in use anymore - this is the case if the counter is zero again
     * since it is decreased when dispatched.
     *
     * @param odf_parameter The parameter that will be given to the functor -
     * it will be deleted after the call!!!
     *
     * @todo: think about deleting odf_parameter (if odf just puts it in a
     * queue - segfault!)
     */
    OutputDataEvent(OutputDataFunctor& odf,
		    AtomicCounter<uint32_t>& counter, 
		    OutputDataFunctorParameter* odf_parameter);
    
    /**
     * Destructor for OutputDataEvent.
     */
    virtual ~OutputDataEvent(void);

    /**
     * Will be called by the event dispatcher when the event is dispatched.
     */
    virtual void dispatch_this(void);

private:
    OutputDataFunctorParameter* odf_parameter;
    bool need_dispatch;
};

} // namespace output
} // namespace iwear

#endif // __OUTPUTDATAEVENT_H

