solverforge_solver/scope/
step.rs1use solverforge_core::domain::PlanningSolution;
4use solverforge_scoring::ScoreDirector;
5
6use super::PhaseScope;
7
8pub struct StepScope<'t, 'a, 'b, S: PlanningSolution, D: ScoreDirector<S>> {
17 phase_scope: &'a mut PhaseScope<'t, 'b, S, D>,
19 step_index: u64,
21 step_score: Option<S::Score>,
23}
24
25impl<'t, 'a, 'b, S: PlanningSolution, D: ScoreDirector<S>> StepScope<'t, 'a, 'b, S, D> {
26 pub fn new(phase_scope: &'a mut PhaseScope<'t, 'b, S, D>) -> Self {
28 let step_index = phase_scope.step_count();
29 Self {
30 phase_scope,
31 step_index,
32 step_score: None,
33 }
34 }
35
36 pub fn step_index(&self) -> u64 {
38 self.step_index
39 }
40
41 pub fn step_score(&self) -> Option<&S::Score> {
43 self.step_score.as_ref()
44 }
45
46 pub fn set_step_score(&mut self, score: S::Score) {
48 self.step_score = Some(score);
49 }
50
51 pub fn complete(&mut self) {
53 self.phase_scope.increment_step_count();
54 }
55
56 pub fn phase_scope(&self) -> &PhaseScope<'t, 'b, S, D> {
58 self.phase_scope
59 }
60
61 pub fn phase_scope_mut(&mut self) -> &mut PhaseScope<'t, 'b, S, D> {
63 self.phase_scope
64 }
65
66 pub fn score_director(&self) -> &D {
68 self.phase_scope.score_director()
69 }
70
71 pub fn score_director_mut(&mut self) -> &mut D {
73 self.phase_scope.score_director_mut()
74 }
75
76 pub fn calculate_score(&mut self) -> S::Score {
78 self.phase_scope.calculate_score()
79 }
80}