1use kernel::*;
16use gcollections::ops::*;
17use search::space::*;
18use search::search_tree_visitor::*;
19use std::io::{self};
20use concept::*;
21use model::*;
22
23pub struct Debugger<C> {
24 model: Model,
25 child: C
26}
27
28impl<C> Debugger<C> {
29 pub fn new(model: Model, child: C) -> Debugger<C> {
30 Debugger {
31 model: model,
32 child: child
33 }
34 }
35}
36
37impl<VStore, CStore, Domain, R, C> SearchTreeVisitor<Space<VStore, CStore, R>> for Debugger<C> where
38 VStore: VStoreConcept<Item=Domain> + Clone,
39 CStore: IntCStore<VStore> + DisplayStateful<(Model, VStore)>,
40 C: SearchTreeVisitor<Space<VStore, CStore, R>>,
41 Domain: IsSingleton,
42 R: FreezeSpace<VStore, CStore> + Snapshot<State=Space<VStore, CStore, R>>
43{
44 fn start(&mut self, root: &Space<VStore, CStore, R>) {
45 self.child.start(root);
46 }
47
48 fn enter(&mut self, current: Space<VStore, CStore, R>)
49 -> (<Space<VStore, CStore, R> as Freeze>::FrozenState, Status<Space<VStore, CStore, R>>)
50 {
51 let (frozen, status) = self.child.enter(current);
52 let current = frozen.unfreeze();
53 println!("Variable store:");
54 println!(" Number of variables: {}", current.vstore.size());
55 println!(" Number of variables assigned: {}", current.vstore.iter().filter(|v| v.is_singleton()).count());
56 current.vstore.display(&self.model);
57 println!("Constraint store:");
58 current.cstore.display(&(self.model.clone(), current.vstore.clone()));
59 println!("Status {:?}", status);
60 println!("Press enter to continue...");
61 let mut buffer = String::new();
62 io::stdin().read_line(&mut buffer).unwrap();
63 (current.freeze(), status)
64 }
65}