rts-sim-module/repo/repo.go
walker 1101edd1d3 调整repo定义
城轨和国铁分开
2023-12-27 13:04:19 +08:00

45 lines
1.2 KiB
Go

package repo
import (
"joylink.club/rtsssimulation/repo/dto"
"joylink.club/rtsssimulation/repo/model"
"joylink.club/rtsssimulation/repo/model/impl"
)
type repo struct {
id string
idMapping *IdMapping // id映射
modelMap map[string]model.Model // 模型map,key为uid
linkMap map[string]*impl.Link // 链路map,key为uid
physicalSectionMap map[string]*impl.PhysicalSection // 物理区段map,key为uid
turnoutMap map[string]*impl.Turnout // 道岔map,key为uid
}
func BuildFrom(msgs *dto.CgRepo) (CgRepo, *ErrorRecord) {
errRecord := NewErrorRecord()
idMapping := BuildIdMapping(msgs, errRecord)
if errRecord.HasError() {
return nil, errRecord
}
repo := &repo{
id: msgs.Id,
idMapping: idMapping,
modelMap: make(map[string]model.Model, 1024),
linkMap: make(map[string]*impl.Link, 256),
physicalSectionMap: make(map[string]*impl.PhysicalSection, 256),
turnoutMap: make(map[string]*impl.Turnout, 128),
}
return repo, errRecord
}
// 模型仓库id
func (r *repo) Id() string {
return r.id
}
// 通过uid查询模型对象
func (r *repo) FindByUid(uid string) model.Model {
return nil
}