1
This commit is contained in:
parent
bd11c1108e
commit
9f8a1d6889
@ -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;
|
||||
|
16
src/listhead.rs
Normal file
16
src/listhead.rs
Normal file
@ -0,0 +1,16 @@
|
||||
pub struct ListHead {
|
||||
prev: Option<Box<ListHead>>,
|
||||
next: Option<Box<ListHead>>,
|
||||
}
|
||||
|
||||
impl ListHead {
|
||||
|
||||
pub fn new() -> Self {
|
||||
let p = ListHead{
|
||||
prev: None,
|
||||
next: None,
|
||||
};
|
||||
return p;
|
||||
}
|
||||
|
||||
}
|
@ -25,14 +25,18 @@ struct MetaClass<T> {
|
||||
|
||||
impl<T: Clone + ProtoMsg> MetaClass<T> {
|
||||
|
||||
fn deserialize_json(&mut self, obj: &serde_json::Map<String, serde_json::Value>) {
|
||||
fn deserialize_json(&mut self, idx: i64, obj: &serde_json::Map<String, serde_json::Value>) {
|
||||
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<T: Clone + ProtoMsg> MetaClass<T> {
|
||||
|
||||
}
|
||||
|
||||
fn test1<T>(mgr: &MetaMgr<T>, meta: &MetaClass<T>) {
|
||||
|
||||
}
|
||||
|
||||
fn test2<T>(mgr: &MetaMgr<T>) {
|
||||
|
||||
}
|
||||
|
||||
pub struct MetaMgr<T> {
|
||||
meta_classes: Vec<MetaClass::<T>>,
|
||||
}
|
||||
@ -75,23 +87,28 @@ impl<T: Clone + ProtoMsg> MetaMgr<T> {
|
||||
self.meta_classes.push(meta);
|
||||
}
|
||||
|
||||
fn test(&self, meta: &mut MetaClass::<T>) {
|
||||
}
|
||||
|
||||
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);
|
||||
},
|
||||
_ => {
|
||||
|
||||
|
28
src/timer.rs
Normal file
28
src/timer.rs
Normal file
@ -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) {
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user