#ifndef __FORENSICS_MINSEARCH_HH__
#define __FORENSICS_MINSEARCH_HH__

#include "forensics-gecode.hh"
#include "datasource.hh"
#include "unsafe.hh"
#include "minsearcher.hh"


class MinSearch : public Gecode::Propagator
{
protected:
  GetDataSource m_callback;
  DataSource& ds;
  Gecode::Int::IntView clusterStart;
  Gecode::Int::IntView offsetStart;
  Gecode::Int::IntView clusterEnd;
  Gecode::Int::IntView offsetEnd;
  MinSearcher& m_ms;

public:
  MinSearch (Gecode::Space& home, Gecode::Int::IntView clusterStart, Gecode::Int::IntView offsetStart, Gecode::Int::IntView clusterEnd, Gecode::Int::IntView offsetEnd, MinSearcher& ms, GetDataSource callback);

  MinSearch (Gecode::Space& home, bool share, MinSearch& p);

  virtual Gecode::Propagator* copy (Gecode::Space& home, bool share);

  virtual size_t dispose (Gecode::Space& home);

  virtual Gecode::PropCost cost (const Gecode::Space& home, const Gecode::ModEventDelta& med) const;

  virtual Gecode::ExecStatus propagate (Gecode::Space& home, const Gecode::ModEventDelta& med);

  static Gecode::ExecStatus post (Gecode::Space& home, Gecode::Int::IntView clusterStart, Gecode::Int::IntView offsetStart, Gecode::Int::IntView clusterEnd, Gecode::Int::IntView offsetEnd, MinSearcher& ms, GetDataSource callback);
};


void pattern_min_search (Gecode::Space& home, Gecode::IntVar clusterStart, Gecode::IntVar offsetStart, Gecode::IntVar clusterEnd, Gecode::IntVar offsetEnd, std::list<unsigned char>& pattern, GetDataSource callback);

#endif

