use std::{collections::BTreeMap, fmt::Debug};
use interruptible::InterruptibilityState;
use own::{OwnedOrMutRef, OwnedOrRef};
use peace_flow_rt::Flow;
use peace_params::ParamsSpecs;
use peace_profile_model::Profile;
use peace_resource_rt::{
paths::{FlowDir, PeaceAppDir, PeaceDir, ProfileDir, ProfileHistoryDir, WorkspaceDir},
resources::ts::SetUp,
states::StatesCurrentStored,
Resources,
};
use peace_rt_model::{
params::{FlowParams, ProfileParams, WorkspaceParams},
ParamsSpecsTypeReg, StatesTypeReg, Workspace,
};
use type_reg::untagged::{BoxDt, TypeReg};
use crate::{CmdCtxMpsfParams, CmdCtxMpsfParamsBuilder, CmdCtxTypes};
#[derive(Debug)]
pub struct CmdCtxMpsf<'ctx, CmdCtxTypesT>
where
CmdCtxTypesT: CmdCtxTypes,
{
pub output: OwnedOrMutRef<'ctx, CmdCtxTypesT::Output>,
pub fields: CmdCtxMpsfFields<'ctx, CmdCtxTypesT>,
}
#[derive(Debug)]
pub struct CmdCtxMpsfFields<'ctx, CmdCtxTypesT>
where
CmdCtxTypesT: CmdCtxTypes,
{
pub interruptibility_state: InterruptibilityState<'static, 'static>,
pub workspace: OwnedOrRef<'ctx, Workspace>,
pub profiles: Vec<Profile>,
pub profile_dirs: BTreeMap<Profile, ProfileDir>,
pub profile_history_dirs: BTreeMap<Profile, ProfileHistoryDir>,
pub flow: OwnedOrRef<'ctx, Flow<CmdCtxTypesT::AppError>>,
pub flow_dirs: BTreeMap<Profile, FlowDir>,
pub workspace_params_type_reg: TypeReg<CmdCtxTypesT::WorkspaceParamsKey, BoxDt>,
pub workspace_params: WorkspaceParams<CmdCtxTypesT::WorkspaceParamsKey>,
pub profile_params_type_reg: TypeReg<CmdCtxTypesT::ProfileParamsKey, BoxDt>,
pub profile_to_profile_params: BTreeMap<Profile, ProfileParams<CmdCtxTypesT::ProfileParamsKey>>,
pub flow_params_type_reg: TypeReg<CmdCtxTypesT::FlowParamsKey, BoxDt>,
pub profile_to_flow_params: BTreeMap<Profile, FlowParams<CmdCtxTypesT::FlowParamsKey>>,
pub profile_to_states_current_stored: BTreeMap<Profile, Option<StatesCurrentStored>>,
pub params_specs_type_reg: ParamsSpecsTypeReg,
pub profile_to_params_specs: BTreeMap<Profile, ParamsSpecs>,
pub states_type_reg: StatesTypeReg,
pub resources: Resources<SetUp>,
}
impl<'ctx, CmdCtxTypesT> CmdCtxMpsf<'ctx, CmdCtxTypesT>
where
CmdCtxTypesT: CmdCtxTypes,
{
pub fn builder<'ctx_local>() -> CmdCtxMpsfParamsBuilder<'ctx_local, CmdCtxTypesT> {
CmdCtxMpsfParams::<'ctx_local, CmdCtxTypesT>::builder()
}
pub fn output(&self) -> &CmdCtxTypesT::Output {
&self.output
}
pub fn output_mut(&mut self) -> &mut CmdCtxTypesT::Output {
&mut self.output
}
pub fn fields(&self) -> &CmdCtxMpsfFields<'_, CmdCtxTypesT> {
&self.fields
}
pub fn fields_mut(&mut self) -> &mut CmdCtxMpsfFields<'ctx, CmdCtxTypesT> {
&mut self.fields
}
}
impl<CmdCtxTypesT> CmdCtxMpsfFields<'_, CmdCtxTypesT>
where
CmdCtxTypesT: CmdCtxTypes,
{
pub fn interruptibility_state(&mut self) -> InterruptibilityState<'_, '_> {
self.interruptibility_state.reborrow()
}
pub fn workspace(&self) -> &Workspace {
&self.workspace
}
pub fn workspace_dir(&self) -> &WorkspaceDir {
self.workspace.dirs().workspace_dir()
}
pub fn peace_dir(&self) -> &PeaceDir {
self.workspace.dirs().peace_dir()
}
pub fn peace_app_dir(&self) -> &PeaceAppDir {
self.workspace.dirs().peace_app_dir()
}
pub fn profiles(&self) -> &[Profile] {
self.profiles.as_ref()
}
pub fn profile_dirs(&self) -> &BTreeMap<Profile, ProfileDir> {
&self.profile_dirs
}
pub fn profile_history_dirs(&self) -> &BTreeMap<Profile, ProfileHistoryDir> {
&self.profile_history_dirs
}
pub fn flow(&self) -> &Flow<CmdCtxTypesT::AppError> {
&self.flow
}
pub fn flow_dirs(&self) -> &BTreeMap<Profile, FlowDir> {
&self.flow_dirs
}
pub fn workspace_params_type_reg(&self) -> &TypeReg<CmdCtxTypesT::WorkspaceParamsKey, BoxDt> {
&self.workspace_params_type_reg
}
pub fn workspace_params_type_reg_mut(
&mut self,
) -> &mut TypeReg<CmdCtxTypesT::WorkspaceParamsKey, BoxDt> {
&mut self.workspace_params_type_reg
}
pub fn workspace_params(&self) -> &WorkspaceParams<CmdCtxTypesT::WorkspaceParamsKey> {
&self.workspace_params
}
pub fn workspace_params_mut(
&mut self,
) -> &mut WorkspaceParams<CmdCtxTypesT::WorkspaceParamsKey> {
&mut self.workspace_params
}
pub fn profile_params_type_reg(&self) -> &TypeReg<CmdCtxTypesT::ProfileParamsKey, BoxDt> {
&self.profile_params_type_reg
}
pub fn profile_params_type_reg_mut(
&mut self,
) -> &mut TypeReg<CmdCtxTypesT::ProfileParamsKey, BoxDt> {
&mut self.profile_params_type_reg
}
pub fn profile_to_profile_params(
&self,
) -> &BTreeMap<Profile, ProfileParams<CmdCtxTypesT::ProfileParamsKey>> {
&self.profile_to_profile_params
}
pub fn profile_to_profile_params_mut(
&mut self,
) -> &mut BTreeMap<Profile, ProfileParams<CmdCtxTypesT::ProfileParamsKey>> {
&mut self.profile_to_profile_params
}
pub fn flow_params_type_reg(&self) -> &TypeReg<CmdCtxTypesT::FlowParamsKey, BoxDt> {
&self.flow_params_type_reg
}
pub fn flow_params_type_reg_mut(&mut self) -> &mut TypeReg<CmdCtxTypesT::FlowParamsKey, BoxDt> {
&mut self.flow_params_type_reg
}
pub fn profile_to_flow_params(
&self,
) -> &BTreeMap<Profile, FlowParams<CmdCtxTypesT::FlowParamsKey>> {
&self.profile_to_flow_params
}
pub fn profile_to_flow_params_mut(
&mut self,
) -> &mut BTreeMap<Profile, FlowParams<CmdCtxTypesT::FlowParamsKey>> {
&mut self.profile_to_flow_params
}
pub fn profile_to_states_current_stored(
&self,
) -> &BTreeMap<Profile, Option<StatesCurrentStored>> {
&self.profile_to_states_current_stored
}
pub fn params_specs_type_reg(&self) -> &ParamsSpecsTypeReg {
&self.params_specs_type_reg
}
pub fn profile_to_params_specs(&self) -> &BTreeMap<Profile, ParamsSpecs> {
&self.profile_to_params_specs
}
pub fn states_type_reg(&self) -> &StatesTypeReg {
&self.states_type_reg
}
pub fn resources(&self) -> &Resources<SetUp> {
&self.resources
}
pub fn resources_mut(&mut self) -> &mut Resources<SetUp> {
&mut self.resources
}
}