RUFAS.routines.animal.life_cycle.repro_state_manager module#
- class RUFAS.routines.animal.life_cycle.repro_state_manager.ReproStateManager(initial_states: set[ReproStateEnum] | None = None)#
Bases:
object
A class that manages the reproductive states of an animal.
Notes#
This class provides methods to enter and exit reproductive states and check if a specific state is active. It is designed to handle cases where typically only one state is active, but it works the same if multiple active states coexist.
Parameters#
- initial_statesset[ReproStateEnum] | None, optional
The initial reproductive states of the animal. Default is {ReproStateEnum.NONE}.
Attributes#
- _statesset[ReproStateEnum]
A set of currently active reproductive states.
Methods#
- enter(state: ReproStateEnum, keep_existing: bool = False)
Enter a new reproductive state.
- exit(state: ReproStateEnum)
Exit an active reproductive state.
- is_in(state: ReproStateEnum) -> bool
Check if a specific reproductive state is currently active.
- is_in_any(states: set[ReproStateEnum]) -> bool
Check if any of the specified reproductive states are currently active.
- reset() -> None
Clear all current states and revert the state manager to having only the NONE state.
- is_in_empty_state() -> bool
Check if the current state is in the empty state (NONE).
- __init__(initial_states: set[ReproStateEnum] | None = None) None #
Initialize the ReproStateManager with the given initial states.
Parameters#
- initial_statesset[ReproStateEnum] | None, optional
A set of initial reproductive states to start with. If None, initializes with {ReproStateEnum.NONE}.
- enter(state: ReproStateEnum, keep_existing: bool = False) None #
Enter a reproductive state.
Notes#
If keep_existing is False or the only current state is NONE, clears existing states before adding the new one. If entering NONE, it clears all other states.
Parameters#
- stateReproStateEnum
The reproductive state to enter.
- keep_existingbool, optional
If False (default), clears existing states before adding the new state.
Raises#
- ValueError
If attempting to re-enter the same state that is already active.
- exit(state: ReproStateEnum) None #
Exit a reproductive state.
Notes#
If the state to exit is NONE or the only current state is NONE, it performs no action.
Parameters#
- stateReproStateEnum
The reproductive state to exit.
Raises#
- ValueError
If attempting to exit a state that is not currently active.
- is_in(state: ReproStateEnum) bool #
Check if a specific reproductive state is currently active.
Parameters#
- stateReproStateEnum
The reproductive state to check.
Returns#
- bool
True if the specified state is active, False otherwise.
- is_in_any(states: set[ReproStateEnum]) bool #
Check if any of the specified reproductive states are currently active.
Parameters#
- statesset[ReproStateEnum]
The reproductive states to check.
Returns#
- bool
True if any of the specified states are active, False otherwise.
- reset() None #
Clear all current states and revert the state manager to having only the NONE state.