diff --git a/src/lib.rs b/src/lib.rs index ab25a24..b75f0ad 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,7 +9,11 @@ mod tests { mod xvalue; mod metamgr; +mod timer; +mod listhead; pub use xvalue::XValue; pub use metamgr::MetaMgr; pub use metamgr::ProtoMsg; +pub use timer::Timer; +pub use listhead::ListHead; diff --git a/src/listhead.rs b/src/listhead.rs new file mode 100644 index 0000000..b565dfd --- /dev/null +++ b/src/listhead.rs @@ -0,0 +1,16 @@ +pub struct ListHead { + prev: Option>, + next: Option>, +} + +impl ListHead { + + pub fn new() -> Self { + let p = ListHead{ + prev: None, + next: None, + }; + return p; + } + +} diff --git a/src/metamgr.rs b/src/metamgr.rs index f2fb2d3..97155e4 100644 --- a/src/metamgr.rs +++ b/src/metamgr.rs @@ -25,14 +25,18 @@ struct MetaClass { impl MetaClass { - fn deserialize_json(&mut self, obj: &serde_json::Map) { + fn deserialize_json(&mut self, idx: i64, obj: &serde_json::Map) { let msg = Rc::new(self.dummy.clone()); let id_key = &mut 0; let name_key = &mut String::new(); msg.deserialize(&obj, id_key, name_key); self.wrap_list.push(msg.clone()); - if *id_key != 0 { - self.wrap_id_hash.insert(*id_key, msg.clone()); + if self.prim_key.is_empty() { + self.wrap_id_hash.insert(idx, msg.clone()); + } else { + if *id_key != 0 { + self.wrap_id_hash.insert(*id_key, msg.clone()); + } } if !name_key.is_empty() { self.wrap_name_hash.insert(name_key.to_string(), msg.clone()); @@ -41,6 +45,14 @@ impl MetaClass { } +fn test1(mgr: &MetaMgr, meta: &MetaClass) { + +} + +fn test2(mgr: &MetaMgr) { + +} + pub struct MetaMgr { meta_classes: Vec>, } @@ -75,23 +87,28 @@ impl MetaMgr { self.meta_classes.push(meta); } + fn test(&self, meta: &mut MetaClass::) { + } + pub fn load(&mut self) { for i in 0..self.meta_classes.len() { - let meta = &mut self.meta_classes[i]; + let meta = &self.meta_classes[i]; match File::open(&meta.file_name) { Ok(f) => { match serde_json::from_reader(f) { Ok(data) => { match (data) { serde_json::Value::Array(arr) =>{ + let mut idx = 0; for item in arr { if let serde_json::Value::Object(obj) = item { - meta.deserialize_json(&obj); + //meta.deserialize_json(idx, &obj); + idx = idx + 1; } } }, serde_json::Value::Object(obj) =>{ - meta.deserialize_json(&obj); + //meta.deserialize_json(0, &obj); }, _ => { diff --git a/src/timer.rs b/src/timer.rs new file mode 100644 index 0000000..9e8da6f --- /dev/null +++ b/src/timer.rs @@ -0,0 +1,28 @@ +pub struct Timer { + +} + +impl Timer { + +/* pub fn init(&mut self, + get_tick_count: fn () -> i64, + get_fxied_timer_expires: fn (i32, i64) -> i64, + context: (), + gctime: i32, + cache_timer_num: i32) { + + }*/ + + pub fn uninit(&mut self) { + + } + + fn clear(&mut self) { + + } + + pub fn update(&mut self) { + + } + +}