1use gcollections::*;
16use gcollections::ops::*;
17use kernel::*;
18use model::*;
19use term::ops::*;
20use propagation::events::*;
21use propagation::concept::*;
22use interval::ops::Range;
23use num::{Signed, Integer};
24use std::ops::*;
25use std::fmt::Debug;
26
27pub use variable::concept::*;
28
29pub trait IntBound:
30 Integer + Clone + Debug
31 + Signed {}
33
34impl<R> IntBound for R where
35 R: Integer + Clone + Debug
36 + Signed
37{}
38
39pub trait IntDomain:
40 Bounded + Cardinality + Empty + IsEmpty + Singleton + IsSingleton + Range + Contains +
41 ShrinkLeft + ShrinkRight + StrictShrinkLeft + StrictShrinkRight +
42 Difference<<Self as Collection>::Item, Output=Self> +
43 Intersection<Output=Self> + Difference<Output=Self> + Overlap + Subset + Disjoint +
44 Add<<Self as Collection>::Item, Output=Self> + Sub<<Self as Collection>::Item, Output=Self> +
45 Add<Output=Self> + Sub<Output=Self> + Mul<Output=Self> +
46 Clone + Debug
47where
48 <Self as Collection>::Item: IntBound
49{}
50
51impl<R> IntDomain for R where
52 R: Bounded + Cardinality + Empty + IsEmpty + Singleton + IsSingleton + Range + Contains,
53 R: ShrinkLeft + ShrinkRight + StrictShrinkLeft + StrictShrinkRight,
54 R: Difference<<R as Collection>::Item, Output=R>,
55 R: Intersection<Output=R> + Difference<Output=R> + Overlap + Subset + Disjoint,
56 R: Add<<R as Collection>::Item, Output=R> + Sub<<R as Collection>::Item, Output=R>,
57 R: Add<Output=R> + Sub<Output=R> + Mul<Output=R>,
58 R: Clone + Debug,
59 <R as Collection>::Item: IntBound
60{}
61
62pub trait IntVariable_<VStore>:
63 ViewDependencies<FDEvent> +
64 StoreMonotonicUpdate<VStore> +
65 StoreRead<VStore> +
66 Debug + DisplayStateful<Model>
67 where VStore: Collection
68{}
69
70impl<R, VStore> IntVariable_<VStore> for R where
71 R: ViewDependencies<FDEvent>,
72 R: StoreMonotonicUpdate<VStore>,
73 R: StoreRead<VStore>,
74 R: Debug + DisplayStateful<Model>,
75 VStore: Collection
76{}
77
78pub type Var<VStore> = Box<dyn IntVariable<VStore>>;
79
80pub trait IntVariable<VStore>: IntVariable_<VStore>
81 where VStore: Collection
82{
83 fn bclone(&self) -> Box<dyn IntVariable<VStore>>;
84}
85
86impl<VStore, R> IntVariable<VStore> for R where
87 R: IntVariable_<VStore>,
88 R: Clone + 'static,
89 VStore: Collection
90{
91 fn bclone(&self) -> Box<dyn IntVariable<VStore>> {
92 Box::new(self.clone())
93 }
94}
95
96pub trait IntCStore<VStore>:
97 Alloc + Empty + Clone + Freeze + DisplayStateful<Model> + DisplayStateful<(Model, VStore)> +
98 Collection<Item=Box<dyn PropagatorConcept<VStore, FDEvent>>> +
99 Consistency<VStore>
100{}
101
102impl<R, VStore> IntCStore<VStore> for R where
103 R: Alloc + Empty + Clone + Freeze + DisplayStateful<Model> + DisplayStateful<(Model, VStore)>,
104 R: Collection<Item=Box<dyn PropagatorConcept<VStore, FDEvent>>>,
105 R: Consistency<VStore>
106{}
107
108pub type Formula<VStore> = Box<dyn PropagatorConcept<VStore, FDEvent>>;