#ifndef vs_ImageSink_H
#define vs_ImageSink_H

/*
 *
 * nucleo/image/sink/ImageSink.H --
 *
 * Copyright (C) Nicolas Roussel
 *
 * See the file LICENSE for information on usage and redistribution of
 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 */

#include <nucleo/core/ReactiveObject.H>
#include <nucleo/utils/TimeUtils.H>
#include <nucleo/core/URL.H>
#include <nucleo/image/Image.H>

#include <string>

namespace nucleo {

  // ----------------------------------------------------------------------------

  class ImageSink : public ReactiveObject {

  protected:

    Chronometer _chrono ;

  public:

    virtual bool start(void)=0 ;
    virtual bool isActive(void)=0 ;
    virtual bool handle(Image *img)=0 ;
    virtual bool stop(void)=0 ;

    void resetFrameRate(void) { _chrono.start() ; }
    double getFrameRate(void) { return _chrono.average() ; }
    double getFrameNumber(void) { return _chrono.count() ; }

    static ImageSink *create(const char *url) ;
    static ImageSink *create(std::string url) {
	 return create(url.c_str()) ;
    }

  } ;

  typedef ImageSink * (*ImageSinkFactory) (const URL *url) ;

  // ----------------------------------------------------------------------------

}

#endif
