#ifndef __FORENSICS_DATASOURCEREAD_HH__
#define __FORENSICS_DATASOURCEREAD_HH__

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


class DataSourceRead : public Gecode::Propagator
{
protected:
  GetDataSource m_callback;
  DataSource& ds;
  Gecode::Int::IntView offsetV; 
  Gecode::Int::IntView resultV;
  Gecode::Int::IntView unavailableV;

public:
  DataSourceRead (Gecode::Space& home, Gecode::Int::IntView offsetV, Gecode::Int::IntView resultV, GetDataSource callback);

  DataSourceRead (Gecode::Space& home, bool share, DataSourceRead& 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 offsetV, Gecode::Int::IntView resultV, GetDataSource callback);
};


void data_source_read (Gecode::Space& home, Gecode::IntVar offset, Gecode::IntVar result, GetDataSource callback);

#endif
