model

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2021 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssetIDListToUint64List

func AssetIDListToUint64List(assetIDList []AssetID) (idList []uint64)

Types

type Asset

type Asset struct {
	ID            AssetID        `json:"id,omitempty"`
	Name          string         `json:"name"`
	Path          string         `json:"path"`
	BoundingBoxes []*BoundingBox `json:"boundingBoxes"`
}

func NewAssetFromBytes added in v0.1.3

func NewAssetFromBytes(bytes []byte) (*Asset, error)

func NewAssetFromFilePath

func NewAssetFromFilePath(filePath string) *Asset

func (*Asset) CanBeUpdatedBy added in v0.1.6

func (a *Asset) CanBeUpdatedBy(asset *Asset) (ok bool, reason string)

func (*Asset) GetID

func (a *Asset) GetID() uint64

func (*Asset) HasAnyOneOfTagID

func (a *Asset) HasAnyOneOfTagID(tagSet *TagSet) bool

func (*Asset) HasID added in v0.1.3

func (a *Asset) HasID() bool

func (*Asset) HasPath added in v0.1.3

func (a *Asset) HasPath() bool

func (*Asset) HasTag

func (a *Asset) HasTag(tagID TagID) bool

func (*Asset) IsAddable added in v0.1.3

func (a *Asset) IsAddable() (bool, string)

func (*Asset) IsSavable added in v0.1.3

func (a *Asset) IsSavable() bool

func (*Asset) IsUpdatableByID added in v0.1.3

func (a *Asset) IsUpdatableByID() bool

IsUpdatableByID checks if this asset can be updated. If asset or box which the asset has does not have ID, the asset is not updatable.

func (*Asset) SetID

func (a *Asset) SetID(id uint64)

func (*Asset) ToCSVRow added in v0.1.3

func (a *Asset) ToCSVRow(tagSet *TagSet) (string, error)

func (*Asset) ToJson added in v0.1.3

func (a *Asset) ToJson() (string, error)

func (*Asset) UpdateBy added in v0.1.6

func (a *Asset) UpdateBy(asset *Asset) error

UpdateBy merge the itself and argument asset properties. This is destructive method. If receiver or arg asset is nil, UpdateBy method do nothing.

func (*Asset) Validate added in v0.1.3

func (a *Asset) Validate() error

type AssetID

type AssetID uint64

func NewAssetID added in v0.1.6

func NewAssetID(id int) (AssetID, error)

type BoundingBox

type BoundingBox struct {
	ID     BoundingBoxID `json:"id"`
	TagID  TagID         `json:"tagID"`
	X      int           `json:"x"`
	Y      int           `json:"y"`
	Width  int           `json:"width"`
	Height int           `json:"height"`
}

func RemoveBoundingBoxByID

func RemoveBoundingBoxByID(boxes []*BoundingBox, replaceBoxID BoundingBoxID) (newBoxes []*BoundingBox)

func ReplaceBoundingBoxByID

func ReplaceBoundingBoxByID(boxes []*BoundingBox, replaceBox *BoundingBox) (newBoxes []*BoundingBox)

func (*BoundingBox) HasID added in v0.1.3

func (b *BoundingBox) HasID() bool

func (*BoundingBox) HasTagID added in v0.1.3

func (b *BoundingBox) HasTagID() bool

func (*BoundingBox) IsSame added in v0.1.3

func (b *BoundingBox) IsSame(box *BoundingBox) bool

IsSame checks if tow boxes are the same. This method ignore ID.

type BoundingBoxID

type BoundingBoxID uint64

type BoundingBoxes added in v0.1.3

type BoundingBoxes []*BoundingBox

func (BoundingBoxes) HasSameBox added in v0.1.3

func (boxes BoundingBoxes) HasSameBox(box *BoundingBox) bool

func (BoundingBoxes) Merge added in v0.1.3

func (boxes BoundingBoxes) Merge(otherBoxes []*BoundingBox) []*BoundingBox

Merge merge boxes

type ImportAsset added in v0.1.1

type ImportAsset struct {
	*Asset        `mapstructure:",squash"`
	BoundingBoxes []*ImportBoundingBox `json:"boundingBoxes"`
}

func NewImportAsset added in v0.1.6

func NewImportAsset(id AssetID, path string, boxes []*ImportBoundingBox) *ImportAsset

func NewImportAssetFromFilePath added in v0.1.1

func NewImportAssetFromFilePath(filePath string) *ImportAsset

func NewImportAssetFromJson added in v0.1.3

func NewImportAssetFromJson(contents []byte) (*ImportAsset, error)

func (*ImportAsset) ToAsset added in v0.1.1

func (a *ImportAsset) ToAsset(tagSet *TagSet) (*Asset, error)

func (*ImportAsset) Validate added in v0.1.3

func (a *ImportAsset) Validate(tagSet *TagSet) error

type ImportBoundingBox added in v0.1.1

type ImportBoundingBox struct {
	*BoundingBox `mapstructure:",squash"`
	TagName      string `json:"tagName"`
}

func NewImportBoundingBoxFromTagID added in v0.1.6

func NewImportBoundingBoxFromTagID(tagID TagID) *ImportBoundingBox

func (*ImportBoundingBox) HasTagName added in v0.1.3

func (b *ImportBoundingBox) HasTagName() bool

func (*ImportBoundingBox) Validate added in v0.1.3

func (b *ImportBoundingBox) Validate(tagSet *TagSet) error

type Query

type Query struct {
	Op    QueryOP `json:"op"`
	Value string  `json:"value"`
}

func NewQuery added in v0.1.6

func NewQuery(opStr, value string) (*Query, error)

func (*Query) Match

func (q *Query) Match(asset *Asset, tagSet *TagSet) bool

type QueryOP

type QueryOP string
const (
	EqualsQueryOP       QueryOP = "equals"
	NotEqualsQueryOP    QueryOP = "not-equals"
	StartWithQueryOP    QueryOP = "start-with"
	NotStartWithQueryOP QueryOP = "not-start-with"
	NoTagsQueryOP       QueryOP = "no-tags"
	PathEqualsQueryOP   QueryOP = "path-equals"
)

type Tag

type Tag struct {
	*UnindexedTag
	Index int `json:"index"`
}

func NewTag added in v0.1.4

func NewTag(id TagID, name string, index int) (*Tag, error)

NewTag construct and return Tag

func (*Tag) ReRegister added in v0.1.4

func (t *Tag) ReRegister(id TagID) *Tag

func (*Tag) SafeUnregister added in v0.1.4

func (t *Tag) SafeUnregister() (*UnregisteredTag, error)

func (*Tag) Unindex added in v0.1.5

func (t *Tag) Unindex() *UnindexedTag

func (*Tag) Unregister added in v0.1.4

func (t *Tag) Unregister() *UnregisteredTag

type TagID

type TagID uint64

func BoxesToTagIDList added in v0.1.3

func BoxesToTagIDList(boxes []*BoundingBox) (idList []TagID)

type TagSet

type TagSet struct {
	// contains filtered or unexported fields
}

func NewTagSet

func NewTagSet(tags []*Tag) *TagSet

NewTagSet returns TagSet. if nil is provided as tags, empty TagSet will be return.

func (*TagSet) Get

func (t *TagSet) Get(id TagID) (*Tag, bool)

func (*TagSet) GetByName

func (t *TagSet) GetByName(name string) (*Tag, bool)

func (*TagSet) Set

func (t *TagSet) Set(tag *Tag) bool

Set set tag. If provided tag does not exists yet, set the tag and return true. If provided tag name already exists on TagSet and has different ID, do nothing and return false. Otherwise, add or update the tag, and return true. If provided tag already exists but has different ID, update the tag and return true. Otherwise do nothing and returns false.

func (*TagSet) SplitBy added in v0.1.4

func (t *TagSet) SplitBy(f func(tag *Tag) bool) (trueTagSet, falseTagSet *TagSet)

SplitBy splits TagSet to two sub sets based on return value of provided function.

func (*TagSet) SplitByID added in v0.1.4

func (t *TagSet) SplitByID(idList []TagID) (existsTagSet, nonExistsTagSet *TagSet)

SplitByID splits TagSet to two sub sets based on provided tag ID.

func (*TagSet) SplitByNames added in v0.1.4

func (t *TagSet) SplitByNames(names []string) (existsTagSet, nonExistsTagSet *TagSet)

SplitByNames splits TagSet to two sub sets based on provided tag names.

func (*TagSet) SubSetBy

func (t *TagSet) SubSetBy(f func(tag *Tag) bool) *TagSet

func (*TagSet) SubSetByID added in v0.1.4

func (t *TagSet) SubSetByID(idList []TagID) *TagSet

SubSetByID returns sub TagSet. new TagSet contains tag which have either provided ID.

func (*TagSet) SubSetByNames added in v0.1.4

func (t *TagSet) SubSetByNames(names []string) *TagSet

SubSetByNames returns sub TagSet. new TagSet contains tag which have either provided names.

func (*TagSet) ToMap added in v0.1.1

func (t *TagSet) ToMap() (map[TagID]*Tag, map[string]*Tag)

ToMap returns two maps.

func (*TagSet) ToTags added in v0.1.4

func (t *TagSet) ToTags() (tags []*Tag)

ToTags returns tags

type UnindexedTag added in v0.1.4

type UnindexedTag struct {
	ID   TagID  `json:"id"`
	Name string `json:"name"`
}

func NewUnindexedTag added in v0.1.4

func NewUnindexedTag(id TagID, name string) (*UnindexedTag, error)

NewUnindexedTag construct and returns UnindexedTag

func (*UnindexedTag) GetID added in v0.1.4

func (t *UnindexedTag) GetID() uint64

func (*UnindexedTag) Index added in v0.1.4

func (t *UnindexedTag) Index(index int) (*Tag, error)

func (*UnindexedTag) SafeUnregister added in v0.1.4

func (t *UnindexedTag) SafeUnregister() (*UnregisteredUnindexedTag, error)

func (*UnindexedTag) SetID added in v0.1.4

func (t *UnindexedTag) SetID(id uint64)

func (*UnindexedTag) Unregister added in v0.1.4

func (t *UnindexedTag) Unregister() *UnregisteredUnindexedTag

type UnregisteredTag added in v0.1.4

type UnregisteredTag struct {
	*UnregisteredUnindexedTag
	Index int
}

func NewUnregisteredTag added in v0.1.4

func NewUnregisteredTag(name string, index int) (*UnregisteredTag, error)

NewUnregisteredTag construct and return UnregisteredTag

func NewUnregisteredTagWithIndexFromUnregisteredTag added in v0.1.4

func NewUnregisteredTagWithIndexFromUnregisteredTag(tag *UnregisteredUnindexedTag, index int) (*UnregisteredTag, error)

NewUnregisteredTagWithIndexFromUnregisteredTag construct and return UnregisteredTag from UnregisteredUnindexedTag

func (*UnregisteredTag) Register added in v0.1.4

func (t *UnregisteredTag) Register(id TagID) *Tag

type UnregisteredUnindexedTag added in v0.1.4

type UnregisteredUnindexedTag struct {
	Name string
}

func NewUnregisteredUnindexedTag added in v0.1.4

func NewUnregisteredUnindexedTag(name string) (*UnregisteredUnindexedTag, error)

NewUnregisteredUnindexedTag construct and returns UnregisteredUnindexedTag

func (*UnregisteredUnindexedTag) Register added in v0.1.4

func (t *UnregisteredUnindexedTag) Register(id TagID) *UnindexedTag

type WSName

type WSName string

func (WSName) IsValid added in v0.1.3

func (w WSName) IsValid() bool

type WorkSpace

type WorkSpace struct {
	ID       WorkSpaceID `json:"id"`
	Name     WSName      `json:"name"`
	BasePath string      `json:"basePath"`
}

type WorkSpaceID

type WorkSpaceID uint64

Directories

Path Synopsis
old

Jump to

Keyboard shortcuts

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