pub struct AgentTypeData<State: DataLike, StateId: IndexLike, Payload: DataLike> { /* private fields */ }
Expand description
The data we need to implement an agent type.
This should be placed in a Singleton
to allow the agent states to get services from it.
Implementations§
Source§impl<State: DataLike, StateId: IndexLike, Payload: DataLike> AgentTypeData<State, StateId, Payload>
impl<State: DataLike, StateId: IndexLike, Payload: DataLike> AgentTypeData<State, StateId, Payload>
Sourcepub fn new(
name: &'static str,
instances: Instances,
prev_agent_type: Option<Rc<dyn AgentType<StateId, Payload>>>,
) -> Self
pub fn new( name: &'static str, instances: Instances, prev_agent_type: Option<Rc<dyn AgentType<StateId, Payload>>>, ) -> Self
Create new agent type data with the specified name and number of instances.
Trait Implementations§
Source§impl<State: DataLike, StateId: IndexLike, Payload: DataLike> AgentInstances<StateId, Payload> for AgentTypeData<State, StateId, Payload>
impl<State: DataLike, StateId: IndexLike, Payload: DataLike> AgentInstances<StateId, Payload> for AgentTypeData<State, StateId, Payload>
Source§fn prev_agent_type(&self) -> Option<Rc<dyn AgentType<StateId, Payload>>>
fn prev_agent_type(&self) -> Option<Rc<dyn AgentType<StateId, Payload>>>
Return the previous agent type in the chain, if any.
Source§fn first_index(&self) -> usize
fn first_index(&self) -> usize
The index of the first agent of this type.
Source§fn next_index(&self) -> usize
fn next_index(&self) -> usize
The next index after the last agent of this type.
Source§fn is_singleton(&self) -> bool
fn is_singleton(&self) -> bool
Whether this type only has a single instance. Read more
Source§fn instances_count(&self) -> usize
fn instances_count(&self) -> usize
The number of agents of this type that will be used in the system.
Source§fn instance_order(&self, instance: usize) -> usize
fn instance_order(&self, instance: usize) -> usize
The order of the agent (for sequence diagrams).
Source§fn terse_id(&self, state_id: StateId) -> StateId
fn terse_id(&self, state_id: StateId) -> StateId
Convert the full state identifier to the terse state identifier.
Source§fn display_terse(&self, terse_id: StateId) -> String
fn display_terse(&self, terse_id: StateId) -> String
Return the name of the terse state (just the state name).
Source§impl<State: DataLike + AgentState<State, Payload>, StateId: IndexLike, Payload: DataLike> AgentType<StateId, Payload> for AgentTypeData<State, StateId, Payload>
impl<State: DataLike + AgentState<State, Payload>, StateId: IndexLike, Payload: DataLike> AgentType<StateId, Payload> for AgentTypeData<State, StateId, Payload>
Source§fn reaction(
&self,
instance: usize,
state_ids: &[StateId],
payload: &Payload,
) -> Reaction<StateId, Payload>
fn reaction( &self, instance: usize, state_ids: &[StateId], payload: &Payload, ) -> Reaction<StateId, Payload>
Return the actions that may be taken by an agent instance with some state when receiving a
payload.
Source§fn activity(&self, instance: usize, state_ids: &[StateId]) -> Activity<Payload>
fn activity(&self, instance: usize, state_ids: &[StateId]) -> Activity<Payload>
Return the actions that may be taken by an agent with some state when time passes.
Source§fn state_is_deferring(&self, instance: usize, state_ids: &[StateId]) -> bool
fn state_is_deferring(&self, instance: usize, state_ids: &[StateId]) -> bool
Whether any agent in the state is deferring messages.
Source§fn state_invalid_because(
&self,
instance: usize,
state_ids: &[StateId],
) -> Option<&'static str>
fn state_invalid_because( &self, instance: usize, state_ids: &[StateId], ) -> Option<&'static str>
Return a reason that a state is invalid (unless it is valid).
Source§fn state_max_in_flight_messages(
&self,
instance: usize,
state_ids: &[StateId],
) -> Option<usize>
fn state_max_in_flight_messages( &self, instance: usize, state_ids: &[StateId], ) -> Option<usize>
The maximal number of messages sent by an agent which may be in-flight when it is in the
state.
Source§fn states_count(&self) -> usize
fn states_count(&self) -> usize
The total number of states seen so far.
Source§fn compute_terse(&self)
fn compute_terse(&self)
Compute mapping from full states to terse states (name only).
Source§impl<State: DataLike, StateId: IndexLike, Payload: DataLike> Name for AgentTypeData<State, StateId, Payload>
impl<State: DataLike, StateId: IndexLike, Payload: DataLike> Name for AgentTypeData<State, StateId, Payload>
Source§impl<State: DataLike, StateId: IndexLike, Payload: DataLike> PartType<State, StateId> for AgentTypeData<State, StateId, Payload>
impl<State: DataLike, StateId: IndexLike, Payload: DataLike> PartType<State, StateId> for AgentTypeData<State, StateId, Payload>
Source§fn part_state_by_id(&self, state_id: StateId) -> State
fn part_state_by_id(&self, state_id: StateId) -> State
Access the part state by the state identifier.
Source§fn part_first_index(&self) -> usize
fn part_first_index(&self) -> usize
The index of the first agent of this type.
Source§fn parts_count(&self) -> usize
fn parts_count(&self) -> usize
The number of agent instances of this type.
Auto Trait Implementations§
impl<State, StateId, Payload> !Freeze for AgentTypeData<State, StateId, Payload>
impl<State, StateId, Payload> !RefUnwindSafe for AgentTypeData<State, StateId, Payload>
impl<State, StateId, Payload> !Send for AgentTypeData<State, StateId, Payload>
impl<State, StateId, Payload> !Sync for AgentTypeData<State, StateId, Payload>
impl<State, StateId, Payload> Unpin for AgentTypeData<State, StateId, Payload>
impl<State, StateId, Payload> !UnwindSafe for AgentTypeData<State, StateId, Payload>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more