use store::StoreBase;
use buffer::BufferBase;
use id_manager::PrimaryIdManager;
use subsystem::SubsystemBase;
use idmgr_mode;
use ioc::{Ioc, InvocationMethod};
use std::any::Any;
use std::fmt::Debug;
use std::sync::RwLock;
pub trait ProcessBase<IdMgr, Key, SsysBase: ?Sized, StoBase: ?Sized, BufBase: ?Sized>: Any + Send + Sync
where
IdMgr: PrimaryIdManager,
Key: Debug + Ord,
SsysBase: SubsystemBase,
StoBase: StoreBase<Id = IdMgr::Id>,
BufBase: BufferBase,
{
fn _update(
&mut self,
ids: &RwLock<IdMgr>,
subsystems: &Ioc<Key, SsysBase>,
stores: &Ioc<Key, StoBase>,
buffers: &Ioc<Key, BufBase>,
);
}
pub trait Process<'a, IdMgr, Key, SsysBase: ?Sized, StoBase: ?Sized, BufBase: ?Sized>: Any + Send + Sync
where
IdMgr: PrimaryIdManager,
Key: Debug + Ord,
SsysBase: SubsystemBase,
StoBase: StoreBase<Id = IdMgr::Id>,
BufBase: BufferBase,
{
type IdMgrMode: idmgr_mode::IdMgrMode<'a, IdMgr>;
type SubsystemSelection: InvocationMethod<'a, Key, SsysBase>;
type StoreSelection: InvocationMethod<'a, Key, StoBase>;
type BufferSelection: InvocationMethod<'a, Key, BufBase>;
type IdMgr = <Self::IdMgrMode as idmgr_mode::IdMgrMode<'a, IdMgr>>::Ret;
type Subsystems = <Self::SubsystemSelection as InvocationMethod<'a, Key, SsysBase>>::Ret;
type Stores = <Self::StoreSelection as InvocationMethod<'a, Key, StoBase>>::Ret;
type Buffers = <Self::BufferSelection as InvocationMethod<'a, Key, BufBase>>::Ret;
fn update(
&mut self,
ids: <Self::IdMgrMode as idmgr_mode::IdMgrMode<'a, IdMgr>>::Ret,
subsystems: <Self::SubsystemSelection as InvocationMethod<'a, Key, SsysBase>>::Ret,
stores: <Self::StoreSelection as InvocationMethod<'a, Key, StoBase>>::Ret,
buffers: <Self::BufferSelection as InvocationMethod<'a, Key, BufBase>>::Ret,
);
}
impl<T, IdMgr, Key, SsysBase: ?Sized, StoBase: ?Sized, BufBase: ?Sized> ProcessBase<IdMgr, Key, SsysBase, StoBase, BufBase> for T
where
IdMgr: PrimaryIdManager,
Key: Debug + Ord,
SsysBase: SubsystemBase,
StoBase: StoreBase<Id = IdMgr::Id>,
BufBase: BufferBase,
T: for<'a> Process<'a, IdMgr, Key, SsysBase, StoBase, BufBase>,
{
fn _update(
&mut self,
ids: &RwLock<IdMgr>,
subsystems: &Ioc<Key, SsysBase>,
stores: &Ioc<Key, StoBase>,
buffers: &Ioc<Key, BufBase>,
){
use std::mem;
assert_eq!(0, mem::size_of::<<T::SubsystemSelection as InvocationMethod<_, _>>::Args>());
assert_eq!(0, mem::size_of::<<T::StoreSelection as InvocationMethod<_, _>>::Args>());
assert_eq!(0, mem::size_of::<<T::BufferSelection as InvocationMethod<_, _>>::Args>());
let nil1 = unsafe { mem::zeroed() };
let nil2 = unsafe { mem::zeroed() };
let nil3 = unsafe { mem::zeroed() };
self.update(
<T::IdMgrMode as idmgr_mode::IdMgrMode<IdMgr>>::retrieve(ids),
subsystems.invoke::<T::SubsystemSelection>(nil1).unwrap(),
stores.invoke::<T::StoreSelection>(nil2).unwrap(),
buffers.invoke::<T::BufferSelection>(nil3).unwrap(),
);
}
}