#ifndef __FORENSICS_EXECPROPAGATOR_HH__
#define __FORENSICS_EXECPROPAGATOR_HH__

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


class ExecPropagator : public Gecode::Propagator
{
protected:
  GetBlockDataSource m_callback;
  BlockDataSource& ds;
  Gecode::ViewArray<Gecode::Int::IntView> m_blocks;
  Gecode::Int::IntView m_unavailable;
  Gecode::Int::IntView m_start;
  Gecode::Int::IntView m_length;
  std::string m_executable;

public:
  ExecPropagator (Gecode::Space& home, Gecode::Int::IntView start, Gecode::Int::IntView length, std::string& executable, GetBlockDataSource callback);

  ExecPropagator (Gecode::Space& home, bool share, ExecPropagator& 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 start, Gecode::Int::IntView length, std::string& executable, GetBlockDataSource callback);
};

void exec_propagator (Gecode::Space& home, Gecode::IntVar start, Gecode::IntVar length, std::string& executable, GetBlockDataSource callback);

extern int64_t num_bytes_written_to_exec;

#endif

