use component::*;
use components::*;
use store::*;
use std::borrow::Borrow;
use std::sync::Arc;
pub struct SimState
{
pub components: Arc<Components>,
pub store: Arc<Store>,
}
impl SimState
{
pub fn was_removed(&self, id: ComponentID) -> bool
{
let store:&Store = self.store.borrow();
let key = self.components.full_path(id) + ".removed";
store.contains(&key)
}
pub fn contains(&self, id: ComponentID, key: &str) -> bool
{
let store:&Store = self.store.borrow();
let path = format!("{}.{}", self.components.full_path(id), key);
store.contains(&path)
}
pub fn get_int(&self, id: ComponentID, key: &str) -> i64
{
let store:&Store = self.store.borrow();
let path = format!("{}.{}", self.components.full_path(id), key);
store.get_int(&path)
}
pub fn get_float(&self, id: ComponentID, key: &str) -> f64
{
let store:&Store = self.store.borrow();
let path = format!("{}.{}", self.components.full_path(id), key);
store.get_float(&path)
}
pub fn get_string(&self, id: ComponentID, key: &str) -> String
{
let store:&Store = self.store.borrow();
let path = format!("{}.{}", self.components.full_path(id), key);
store.get_string(&path)
}
}