// package elem_base -- базовый объект package elem_base import ( "github.com/google/uuid" "gitp78su.ipnodns.ru/svi/goarch/lev0/alias" "gitp78su.ipnodns.ru/svi/goarch/lev0/types" "gitp78su.ipnodns.ru/svi/kern/v3" ) // ElemBase -- базовый объект type ElemBase struct { Id_ alias.Id `yaml:"id"` // Идентификатор объекта Type_ alias.Type `yaml:"type"` // Тип объекта Coord_ types.ICoord `yaml:"coord"` // Координаты элемента } var ( hassert = kern.GetFnHassert() ) // NewElemBase -- возвращает новый базовый объект func NewElemBase(coord types.ICoord, type_ alias.Type) types.IElemBase { sf := &ElemBase{ Coord_: coord, Id_: alias.Id(uuid.New().String()), Type_: type_, } sf.SelfCheck() return sf } // Coord -- возвращает координаты элемента // //go:fix inline func (sf *ElemBase) Coord() types.ICoord { return sf.Coord_ } // Type -- возвращает тип объекта // //go:fix inline func (sf *ElemBase) Type() alias.Type { return sf.Type_ } // Id -- возвращает ID объекта // //go:fix inline func (sf *ElemBase) Id() alias.Id { return sf.Id_ } // SelfCheck -- самопроверка базового элемента func (sf *ElemBase) SelfCheck() { hassert(sf.Id_ != "", "ElemBase.SelfCheck(): Id_ is empty") hassert(sf.Type_ != "", "NewElemBase(): Type_ is empty") hassert(sf.Coord_ != nil, "NewElemBase(): Coord_ == nil") }