1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
use store::StoreBase; use buffer::BufferBase; use id_manager::PrimaryIdManager; use subsystem::SubsystemBase; use idmgr_mode; use ioc::{self, 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> = ioc::Read<IdMgr>; type SubsystemSelection: InvocationMethod<'a, Key, SsysBase, Args = ()>; type StoreSelection: InvocationMethod<'a, Key, StoBase, Args = ()>; type BufferSelection: InvocationMethod<'a, Key, BufBase, Args = ()>; 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>, ){ self.update( <T::IdMgrMode as idmgr_mode::IdMgrMode<IdMgr>>::retrieve(ids), subsystems.invoke::<T::SubsystemSelection>(()).unwrap(), stores.invoke::<T::StoreSelection>(()).unwrap(), buffers.invoke::<T::BufferSelection>(()).unwrap(), ); } }