elem_base.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // package elem_base -- базовый объект
  2. package elem_base
  3. import (
  4. "gitp78su.ipnodns.ru/svi/goarch/lev0/alias"
  5. "gitp78su.ipnodns.ru/svi/goarch/lev1/coord"
  6. "gitp78su.ipnodns.ru/svi/goarch/lev1/label"
  7. "gitp78su.ipnodns.ru/svi/goarch/lev1/offset"
  8. "gitp78su.ipnodns.ru/svi/kern/v3"
  9. )
  10. // ElemBase -- базовый объект
  11. type ElemBase struct {
  12. Label_ *label.Label `yaml:"label"` // название объекта
  13. Id_ alias.Id `yaml:"id"` // Идентификатор объекта
  14. Type_ alias.Type `yaml:"type"` // Тип объекта
  15. Elem_ map[string]interface{} `yaml:"map_elem"` // Набор полей
  16. StrElem_ string // Строковое представление объекта
  17. }
  18. var (
  19. hassert = kern.GetFnHassert()
  20. )
  21. // NewElemBase -- возвращает новый базовый объект
  22. func NewElemBase(id alias.Id, label_ alias.Label, labelCoord *coord.Coord,
  23. labelOffset *offset.Offset, type_ alias.Type,
  24. elem map[string]interface{}, binElem []byte) *ElemBase {
  25. hassert(id != "", "NewElemBase(): id is empty")
  26. hassert(type_ != "", "NewElemBase(): type is empty")
  27. sf := &ElemBase{
  28. Elem_: elem,
  29. StrElem_: string(binElem),
  30. Label_: label.NewLabel(label_, labelCoord, labelOffset),
  31. Id_: id,
  32. Type_: type_,
  33. }
  34. return sf
  35. }
  36. // Elem -- возвращает элементы словаря
  37. func (sf *ElemBase) Elem() map[string]interface{} {
  38. return sf.Elem_
  39. }
  40. // Type -- возвращает тип объекта
  41. func (sf *ElemBase) Type() alias.Type {
  42. return sf.Type_
  43. }
  44. // Id -- возвращает ID объекта
  45. func (sf *ElemBase) Id() alias.Id {
  46. return sf.Id_
  47. }