1
This commit is contained in:
parent
1d17503122
commit
374a63d8e0
@ -8,5 +8,7 @@ mod tests {
|
||||
}
|
||||
|
||||
mod xvalue;
|
||||
mod metamgr;
|
||||
|
||||
pub use xvalue::XValue;
|
||||
pub use metamgr::MetaMgr;
|
||||
|
52
src/metamgr.rs
Normal file
52
src/metamgr.rs
Normal file
@ -0,0 +1,52 @@
|
||||
use std::rc::Rc;
|
||||
use std::collections::HashMap;
|
||||
|
||||
struct MetaClass<T> {
|
||||
file_name: String,
|
||||
idx: i32,
|
||||
prim_key: String,
|
||||
sec_key: String,
|
||||
wrap_list: Vec<Rc<T>>,
|
||||
wrap_id_hash: HashMap<i64, Rc<T>>,
|
||||
wrap_name_hash: HashMap<String, Rc<T>>
|
||||
}
|
||||
|
||||
pub struct MetaMgr<T> {
|
||||
meta_classes: Vec<MetaClass::<T>>,
|
||||
}
|
||||
|
||||
impl<T> MetaMgr<T> {
|
||||
|
||||
pub fn new() -> Self {
|
||||
return MetaMgr::<T>{
|
||||
meta_classes: Vec::new()
|
||||
};
|
||||
}
|
||||
|
||||
pub fn init(&mut self) {
|
||||
|
||||
}
|
||||
|
||||
pub fn un_init(&mut self) {
|
||||
|
||||
}
|
||||
|
||||
pub fn get_byid(&mut self, idx: i32, id: i64) -> Option<&Rc<T>> {
|
||||
return self.internal_get_byid(idx as usize, id);
|
||||
}
|
||||
|
||||
pub fn internal_get_byid(&mut self, idx: usize, id: i64) -> Option<&Rc<T>> {
|
||||
if idx >= 0 && idx <= self.meta_classes.len() {
|
||||
match self.meta_classes[idx].wrap_id_hash.get(&id) {
|
||||
Some(v) => {
|
||||
return Some(v);
|
||||
}
|
||||
None => {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return None;
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user