f5/metamgr.go
aozhiwei a10ae56c4f 1
2020-09-02 18:45:35 +08:00

67 lines
1.2 KiB
Go

package f5
type MetaClass struct {
FileName string
Idx int
RawMeta interface{}
WrapMeta interface{}
PrimKey string
}
type MetaMgr struct {
metaClasses *[]MetaClass
rawData []interface{}
wrapList []interface{}
wrapIdHash []map[int32]interface{}
wrapNameHash []map[string]interface{}
}
func (this *MetaMgr) Init() {
}
func (this *MetaMgr) UnInit() {
}
func (this *MetaMgr) RegisterMetaClasses(metaClasses *[]MetaClass) {
this.metaClasses = metaClasses
}
func (this *MetaMgr) Load() {
for k, _ := range this.rawData {
_ = this.wrapList[k]
}
}
func (this *MetaMgr) GetMetaById(idx int, id int32) interface{} {
if idx >=0 && idx < len(this.wrapIdHash) {
idHash := this.wrapIdHash[idx]
if v, ok := idHash[id]; ok {
return v
} else {
return nil
}
}
return nil
}
func (this *MetaMgr) GetMetaByName(idx int, name string) interface{} {
if idx >=0 && idx < len(this.wrapNameHash) {
nameHash := this.wrapNameHash[idx]
if v, ok := nameHash[name]; ok {
return v
} else {
return nil
}
}
return nil
}
func (this *MetaMgr) GetMetaList(idx int) interface{} {
if idx >=0 && idx < len(this.wrapList) {
return this.wrapList[idx]
}
return nil
}