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
use store::StoreBase;
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, StoBase: ?Sized, SsysBase: ?Sized>: Any + Send + Sync
where
IdMgr: PrimaryIdManager,
Key: Debug + Ord,
StoBase: StoreBase<Id = IdMgr::Id>,
SsysBase: SubsystemBase,
{
fn _update(
&mut self,
ids: &RwLock<IdMgr>,
stores: &Ioc<Key, StoBase>,
subsystems: &Ioc<Key, SsysBase>,
);
}
pub trait Process<'a, IdMgr, Key, StoBase: ?Sized, SsysBase: ?Sized, >: Any + Send + Sync
where
IdMgr: PrimaryIdManager,
Key: Debug + Ord,
StoBase: StoreBase<Id = IdMgr::Id>,
SsysBase: SubsystemBase,
{
type IdMgrMode: idmgr_mode::IdMgrMode<'a, IdMgr>;
type StoreSelection: InvocationMethod<'a, Key, StoBase>;
type SubsystemSelection: InvocationMethod<'a, Key, SsysBase>;
type IdMgr = <Self::IdMgrMode as idmgr_mode::IdMgrMode<'a, IdMgr>>::Ret;
type Stores = <Self::StoreSelection as InvocationMethod<'a, Key, StoBase>>::Ret;
type Subsystems = <Self::SubsystemSelection as InvocationMethod<'a, Key, SsysBase>>::Ret;
fn update(
&mut self,
ids: <Self::IdMgrMode as idmgr_mode::IdMgrMode<'a, IdMgr>>::Ret,
stores: <Self::StoreSelection as InvocationMethod<'a, Key, StoBase>>::Ret,
subsystems: <Self::SubsystemSelection as InvocationMethod<'a, Key, SsysBase>>::Ret,
);
}
impl<T, IdMgr, Key, StoBase: ?Sized, SsysBase: ?Sized> ProcessBase<IdMgr, Key, StoBase, SsysBase> for T
where
IdMgr: PrimaryIdManager,
Key: Debug + Ord,
StoBase: StoreBase<Id = IdMgr::Id>,
SsysBase: SubsystemBase,
T: for<'a> Process<'a, IdMgr, Key, StoBase, SsysBase>,
{
fn _update(
&mut self,
ids: &RwLock<IdMgr>,
stores: &Ioc<Key, StoBase>,
subsystems: &Ioc<Key, SsysBase>,
){
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>());
let nil1 = unsafe { mem::zeroed() };
let nil2 = unsafe { mem::zeroed() };
self.update(
<T::IdMgrMode as idmgr_mode::IdMgrMode<IdMgr>>::retrieve(ids),
stores.invoke::<T::StoreSelection>(nil2).unwrap(),
subsystems.invoke::<T::SubsystemSelection>(nil1).unwrap(),
);
}
}