subtr_actor/stats/
resolved_boost_pad_collector.rs1use crate::stats::analysis_graph::{self, AnalysisNodeCollector};
2use crate::*;
3
4pub struct ResolvedBoostPadCollector {
5 collector: AnalysisNodeCollector,
6}
7
8impl Default for ResolvedBoostPadCollector {
9 fn default() -> Self {
10 Self::new()
11 }
12}
13
14impl ResolvedBoostPadCollector {
15 pub fn new() -> Self {
16 let graph = analysis_graph::graph_with_builtin_analysis_nodes(["boost"])
17 .expect("builtin boost analysis graph should be valid");
18 Self {
19 collector: AnalysisNodeCollector::new(graph),
20 }
21 }
22
23 pub fn resolved_boost_pads(&self) -> Vec<ResolvedBoostPad> {
24 self.collector
25 .graph()
26 .state::<BoostCalculator>()
27 .map(BoostCalculator::resolved_boost_pads)
28 .unwrap_or_default()
29 }
30
31 pub fn into_resolved_boost_pads(self) -> Vec<ResolvedBoostPad> {
32 let graph = self.collector.into_graph();
33 graph
34 .state::<BoostCalculator>()
35 .map(BoostCalculator::resolved_boost_pads)
36 .unwrap_or_default()
37 }
38}
39
40impl Collector for ResolvedBoostPadCollector {
41 fn process_frame(
42 &mut self,
43 processor: &ReplayProcessor,
44 frame: &boxcars::Frame,
45 frame_number: usize,
46 current_time: f32,
47 ) -> SubtrActorResult<TimeAdvance> {
48 self.collector
49 .process_frame(processor, frame, frame_number, current_time)
50 }
51
52 fn finish_replay(&mut self, processor: &ReplayProcessor) -> SubtrActorResult<()> {
53 self.collector.finish_replay(processor)
54 }
55}