use crate::simulator::Config;
use core::future::Future;
pub unsafe trait Bag {
fn is_empty(&self) -> bool;
fn clear(&mut self);
}
pub unsafe trait Component {
type Input: Bag;
type Output: Bag;
fn get_t_last(&self) -> f64;
fn set_t_last(&mut self, t_last: f64);
fn get_t_next(&self) -> f64;
fn set_t_next(&mut self, t_next: f64);
fn get_input(&self) -> &Self::Input;
fn get_input_mut(&mut self) -> &mut Self::Input;
fn get_output(&self) -> &Self::Output;
fn get_output_mut(&mut self) -> &mut Self::Output;
#[inline]
fn clear_input(&mut self) {
self.get_input_mut().clear()
}
#[inline]
fn clear_output(&mut self) {
self.get_output_mut().clear()
}
}
pub unsafe trait PartialAtomic: Component {
type State;
}
pub unsafe trait AbstractSimulator: Component {
fn start(&mut self, t_start: f64) -> f64;
fn stop(&mut self, t_stop: f64);
fn lambda(&mut self, t: f64);
fn delta(&mut self, t: f64) -> f64;
}
pub trait AsyncInput {
type Input: Bag;
fn handle(
&mut self,
config: &Config,
t_from: f64,
t_until: f64,
input: &mut Self::Input,
) -> impl Future<Output = f64>;
}