pub struct Model {
world: World,
resources: Resources,
initialized: bool,
map_initialization: Option<Box<dyn MapInitialization>>,
population_initialization: Option<Box<dyn PopulationInitialization>>,
systems: Vec<Box<dyn System>>,
}
Expand description
Model(seed)
The basic model object to hold sub-models and resources, and to run simulations.
Parameters:
seed - the random seed for this model. Default from entropy (i.e. “random”).
Fields
world: World
resources: Resources
initialized: bool
map_initialization: Option<Box<dyn MapInitialization>>
population_initialization: Option<Box<dyn PopulationInitialization>>
systems: Vec<Box<dyn System>>
Implementations
sourceimpl Model
impl Model
pub fn new(seed: Option<u64>) -> Self
sourcepub fn add_resource(&mut self, resource: &mut ResourceWrapper)
pub fn add_resource(&mut self, resource: &mut ResourceWrapper)
Add a resource to the model.
sourcepub fn set_map_init(&mut self, init: &mut MapInitializationWrapper)
pub fn set_map_init(&mut self, init: &mut MapInitializationWrapper)
Set the model’s map initialization system.
sourcepub fn set_pop_init(&mut self, init: &mut PopulationInitializationWrapper)
pub fn set_pop_init(&mut self, init: &mut PopulationInitializationWrapper)
Set the model’s population initialization system.
sourcepub fn add_system(&mut self, system: &mut SystemWrapper)
pub fn add_system(&mut self, system: &mut SystemWrapper)
Add a system (sub-model) to the model.
fn _initialize(&mut self)
fn _step(&mut self) -> bool
fn _finalize(&mut self)
Trait Implementations
sourceimpl PyClass for Model
impl PyClass for Model
type Dict = PyClassDummySlot
type Dict = PyClassDummySlot
Specify this class has #[pyclass(dict)]
or not.
type WeakRef = PyClassDummySlot
type WeakRef = PyClassDummySlot
Specify this class has #[pyclass(weakref)]
or not.
type BaseNativeType = PyAny
type BaseNativeType = PyAny
The closest native ancestor. This is PyAny
by default, and when you declare
#[pyclass(extends=PyDict)]
, it’s PyDict
. Read more
sourceimpl PyClassImpl for Model
impl PyClassImpl for Model
sourceconst IS_BASETYPE: bool
const IS_BASETYPE: bool
#[pyclass(subclass)]
sourceconst IS_SUBCLASS: bool
const IS_SUBCLASS: bool
#[pyclass(extends=…)]
sourceconst IS_MAPPING: bool
const IS_MAPPING: bool
#[pyclass(mapping)]
type Layout = PyCell<Self>
type Layout = PyCell<Self>
Layout
type BaseType = PyAny
type BaseType = PyAny
Base class
type ThreadChecker = ThreadCheckerImpl<Model>
type ThreadChecker = ThreadCheckerImpl<Model>
This handles following two situations: Read more
fn for_all_items(visitor: &mut dyn FnMut(&PyClassItems))
fn dict_offset() -> Option<isize>
fn weaklist_offset() -> Option<isize>
sourceimpl PyMethods<Model> for PyClassImplCollector<Model>
impl PyMethods<Model> for PyClassImplCollector<Model>
fn py_methods(self) -> &'static PyClassItems
sourceimpl PyTypeInfo for Model
impl PyTypeInfo for Model
type AsRefTarget = PyCell<Self>
type AsRefTarget = PyCell<Self>
Utility type to make Py::as_ref work.
sourcefn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
PyTypeObject instance for this type.
fn is_type_of(object: &PyAny) -> bool
fn is_type_of(object: &PyAny) -> bool
Checks if object
is an instance of this type or a subclass of this type.
fn is_exact_type_of(object: &PyAny) -> bool
fn is_exact_type_of(object: &PyAny) -> bool
Checks if object
is an instance of this type.
Auto Trait Implementations
impl !RefUnwindSafe for Model
impl !Send for Model
impl !Sync for Model
impl Unpin for Model
impl !UnwindSafe for Model
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> PyTypeObject for T where
T: PyTypeInfo,
impl<T> PyTypeObject for T where
T: PyTypeInfo,
pub fn type_object(py: Python<'_>) -> &PyType
pub fn type_object(py: Python<'_>) -> &PyType
Returns the safe abstraction over the type object.