modelinfo

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModelVersion = 5
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Entity

type Entity struct {
	Id             IdUid                 `json:"id"`
	LastPropertyId IdUid                 `json:"lastPropertyId"`
	Name           string                `json:"name"`
	Properties     []*Property           `json:"properties"`
	Relations      []*StandaloneRelation `json:"relations,omitempty"`
	// contains filtered or unexported fields
}

func CreateEntity

func CreateEntity(model *ModelInfo, id Id, uid Uid) *Entity

func (*Entity) CreateProperty

func (entity *Entity) CreateProperty() (*Property, error)

func (*Entity) CreateRelation added in v0.9.0

func (entity *Entity) CreateRelation() (*StandaloneRelation, error)

func (*Entity) FindPropertyByName

func (entity *Entity) FindPropertyByName(name string) (*Property, error)

func (*Entity) FindPropertyByUid

func (entity *Entity) FindPropertyByUid(uid Uid) (*Property, error)

func (*Entity) FindRelationByName added in v0.9.0

func (entity *Entity) FindRelationByName(name string) (*StandaloneRelation, error)

func (*Entity) FindRelationByUid added in v0.9.0

func (entity *Entity) FindRelationByUid(uid Uid) (*StandaloneRelation, error)

func (*Entity) RemoveProperty

func (entity *Entity) RemoveProperty(property *Property) error

func (*Entity) RemoveRelation added in v0.9.0

func (entity *Entity) RemoveRelation(relation *StandaloneRelation) error

func (*Entity) Validate

func (entity *Entity) Validate() (err error)

performs initial validation of loaded data so that it doesn't have to be checked in each function

type Id

type Id = uint32

type IdUid

type IdUid string

func CreateIdUid

func CreateIdUid(id Id, uid Uid) IdUid

func (*IdUid) Get

func (str *IdUid) Get() (Id, Uid, error)

func (IdUid) GetId

func (str IdUid) GetId() (Id, error)

func (*IdUid) GetUid

func (str *IdUid) GetUid() (Uid, error)

func (*IdUid) Validate

func (str *IdUid) Validate() error

performs initial validation of loaded data so that it doesn't have to be checked in each function

type ModelInfo

type ModelInfo struct {
	// NOTE don't change order of these json exported properties because it will change users' model.json files
	Note1                string    `json:"_note1"`
	Note2                string    `json:"_note2"`
	Note3                string    `json:"_note3"`
	Entities             []*Entity `json:"entities"`
	LastEntityId         IdUid     `json:"lastEntityId"`
	LastIndexId          IdUid     `json:"lastIndexId"`
	LastRelationId       IdUid     `json:"lastRelationId"`
	ModelVersion         int       `json:"modelVersion"`
	MinimumParserVersion int       `json:"modelVersionParserMinimum"`
	RetiredEntityUids    []Uid     `json:"retiredEntityUids"`
	RetiredIndexUids     []Uid     `json:"retiredIndexUids"`
	RetiredPropertyUids  []Uid     `json:"retiredPropertyUids"`
	RetiredRelationUids  []Uid     `json:"retiredRelationUids"`
	Version              int       `json:"version"` // user specified version

	Rand *rand.Rand `json:"-"` // seeded random number generator

	// Model Template
	Package string `json:"-"`
	// contains filtered or unexported fields
}

func LoadOrCreateModel

func LoadOrCreateModel(path string) (model *ModelInfo, err error)

func (*ModelInfo) CheckRelationCycles added in v0.9.0

func (model *ModelInfo) CheckRelationCycles() error

func (*ModelInfo) Close

func (model *ModelInfo) Close() error

Close and unlock model

func (*ModelInfo) CreateEntity

func (model *ModelInfo) CreateEntity(name string) (*Entity, error)

func (*ModelInfo) FindEntityByName

func (model *ModelInfo) FindEntityByName(name string) (*Entity, error)

func (*ModelInfo) FindEntityByUid

func (model *ModelInfo) FindEntityByUid(uid Uid) (*Entity, error)

func (*ModelInfo) Validate

func (model *ModelInfo) Validate() (err error)

performs initial validation of loaded data so that it doesn't have to be checked in each function

func (*ModelInfo) Write

func (model *ModelInfo) Write() error

Write current model data to file

type Property

type Property struct {
	Id             IdUid  `json:"id"`
	Name           string `json:"name"`
	IndexId        *IdUid `json:"indexId,omitempty"`
	Type           int    `json:"type"`
	Flags          int    `json:"flags,omitempty"`
	RelationTarget string `json:"relationTarget,omitempty"`
	// contains filtered or unexported fields
}

func CreateProperty

func CreateProperty(entity *Entity, id Id, uid Uid) *Property

func (*Property) CreateIndex

func (property *Property) CreateIndex() error

func (*Property) RemoveIndex

func (property *Property) RemoveIndex() error

func (*Property) Validate

func (property *Property) Validate() error

performs initial validation of loaded data so that it doesn't have to be checked in each function

type StandaloneRelation added in v0.9.0

type StandaloneRelation struct {
	Id       IdUid   `json:"id"`
	Name     string  `json:"name"`
	Target   *Entity `json:"-"`
	TargetId IdUid   `json:"targetId"`
	// contains filtered or unexported fields
}

func CreateStandaloneRelation added in v0.9.0

func CreateStandaloneRelation(entity *Entity, id IdUid) *StandaloneRelation

func (*StandaloneRelation) SetTarget added in v1.0.0

func (relation *StandaloneRelation) SetTarget(entity *Entity)

func (*StandaloneRelation) Validate added in v0.9.0

func (relation *StandaloneRelation) Validate() error

performs initial validation of loaded data so that it doesn't have to be checked in each function

type Uid

type Uid = uint64

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL