pumpkin_core/statistics/
mod.rs1pub(crate) mod statistic_logger;
3pub(crate) mod statistic_logging;
4
5use std::fmt::Display;
6
7pub use statistic_logger::StatisticLogger;
8pub use statistic_logging::configure_statistic_logging;
9pub use statistic_logging::log_statistic;
10pub use statistic_logging::log_statistic_postfix;
11pub use statistic_logging::should_log_statistics;
12pub use statistic_logging::StatisticOptions;
13
14#[cfg(doc)]
15use crate::create_statistics_struct;
16#[cfg(doc)]
17use crate::Solver;
18
19pub trait Statistic {
23 fn log(&self, statistic_logger: StatisticLogger);
25}
26
27impl<Value: Display> Statistic for Value {
28 fn log(&self, statistic_logger: StatisticLogger) {
29 statistic_logger.log_statistic(self);
30 }
31}
32
33#[macro_export]
47macro_rules! create_statistics_struct {
48 ($(#[$struct_documentation:meta])* $name:ident { $($(#[$variable_documentation:meta])* $field:ident : $type:ident $(< $( $lt:tt $( : $clt:tt $(+ $dlt:tt )* )? ),+ >)?),+ $(,)? }) => {
49 $(#[$struct_documentation])*
50 #[derive(Default, Debug, Copy, Clone)]
51 pub(crate) struct $name {
52 $($(#[$variable_documentation])* pub(crate) $field: $type $(< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)?),+
53 }
54
55 impl $crate::statistics::Statistic for $name {
56 fn log(&self, statistic_logger: $crate::statistics::StatisticLogger) {
57 $(self.$field.log(statistic_logger.attach_to_prefix(stringify!($field),)));+
58 }
59 }
60 };
61}