db

package
v0.0.0-...-313f127 Latest Latest
Warning

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

Go to latest
Published: May 6, 2016 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Layer

type Layer struct {
	ID      int64  `db:"id"`
	WorldID int64  `db:"world_id"`
	Name    string `db:"name"`
}

Layer represents a collection of scenes that combined form 'a layer'.

All scenes in a layer is visualized together, but grouping scenes into layers allow updating one scene without having to update all scenes in the layer.

A layer lives in a 'world'

type Layers

type Layers interface {
	// GetAll returns all layers of the given world.
	GetAll() ([]*Layer, error)
	// Get returns the layer with the specified ID.
	Get(layerid int64) (*Layer, error)
	// Add creates a new layer and returns the ID, or an error.
	Add(layer *Layer) (int64, error)
	// Delete deletes the layer with the given ID.
	Delete(layerid int64) error
}

Layers provide functionality for accessing layers from a database.

func NewLayersDB

func NewLayersDB(tx *sqlx.Tx, worldID int64) Layers

type MockLayers

type MockLayers struct {
	mock.Mock
}

func (*MockLayers) Add

func (_m *MockLayers) Add(layer *Layer) (int64, error)

Add provides a mock function with given fields: layer

func (*MockLayers) Delete

func (_m *MockLayers) Delete(layerid int64) error

Delete provides a mock function with given fields: layerid

func (*MockLayers) Get

func (_m *MockLayers) Get(layerid int64) (*Layer, error)

Get provides a mock function with given fields: layerid

func (*MockLayers) GetAll

func (_m *MockLayers) GetAll() ([]*Layer, error)

GetAll provides a mock function with given fields:

type MockObject

type MockObject struct {
	mock.Mock
}

func (*MockObject) Bounds

func (_m *MockObject) Bounds() *vec3.Box

Bounds provides a mock function with given fields:

func (*MockObject) GeometryData

func (_m *MockObject) GeometryData() []byte

GeometryData provides a mock function with given fields:

func (*MockObject) ID

func (_m *MockObject) ID() int64

ID provides a mock function with given fields:

func (*MockObject) LayerID

func (_m *MockObject) LayerID() int64

LayerID provides a mock function with given fields:

func (*MockObject) Metadata

func (_m *MockObject) Metadata() interface{}

Metadata provides a mock function with given fields:

func (*MockObject) SceneID

func (_m *MockObject) SceneID() int64

SceneID provides a mock function with given fields:

func (*MockObject) WorldID

func (_m *MockObject) WorldID() int64

WorldID provides a mock function with given fields:

type MockObjects

type MockObjects struct {
	mock.Mock
}

func (*MockObjects) Add

func (_m *MockObjects) Add(o Object) (int64, error)

Add provides a mock function with given fields: o

func (*MockObjects) GetAll

func (_m *MockObjects) GetAll() (<-chan Object, <-chan error)

GetAll provides a mock function with given fields:

func (*MockObjects) GetMany

func (_m *MockObjects) GetMany(ids []int64) (<-chan Object, <-chan error)

GetMany provides a mock function with given fields: ids

type MockScenes

type MockScenes struct {
	mock.Mock
}

func (*MockScenes) Add

func (_m *MockScenes) Add(scene *Scene) (int64, error)

Add provides a mock function with given fields: scene

func (*MockScenes) Delete

func (_m *MockScenes) Delete(sceneid int64) error

Delete provides a mock function with given fields: sceneid

func (*MockScenes) Get

func (_m *MockScenes) Get(id int64) (*Scene, error)

Get provides a mock function with given fields: id

func (*MockScenes) GetAll

func (_m *MockScenes) GetAll() ([]*Scene, error)

GetAll provides a mock function with given fields:

type MockWorlds

type MockWorlds struct {
	mock.Mock
}

func (*MockWorlds) Add

func (_m *MockWorlds) Add(world *World) (int64, error)

Add provides a mock function with given fields: world

func (*MockWorlds) Delete

func (_m *MockWorlds) Delete(worldid int64) error

Delete provides a mock function with given fields: worldid

func (*MockWorlds) Get

func (_m *MockWorlds) Get(id int64) (*World, error)

Get provides a mock function with given fields: id

func (*MockWorlds) GetAll

func (_m *MockWorlds) GetAll() ([]*World, error)

GetAll provides a mock function with given fields:

type Object

type Object interface {
	// ID returns an unique ID of the object
	ID() int64

	// WorldID returns the ID of the world the object 'lives' in
	WorldID() int64
	// LayerID returns the ID of the layer the object is a part of
	LayerID() int64
	// SceneID returns the ID of the scene the object is a part of
	SceneID() int64

	// Bounds returns the bounding box of the object.
	Bounds() *vec3.Box
	// GeometryData returns raw geometry data of the object
	GeometryData() []byte
	// Metadata returns arbitrary JSON-convertible metadata for
	// the object.
	Metadata() interface{}
}

type ObjectSelector

type ObjectSelector interface {
	CreateWhereClause() (string, []interface{})
}

type Objects

type Objects interface {
	Add(o Object) (int64, error)
	GetMany(ids []int64) (<-chan Object, <-chan error)
	GetAll() (<-chan Object, <-chan error)
}

Objects represents a collection of geometric entities assosciated with a 'world'. Note that this collection holds all objects for all layers and scenes in a world. To restrict the result from the queries to only include certain layers and/or scenes 'ObjectSelector's can be used.

func NewObjectsDb

func NewObjectsDb(tx *sqlx.Tx, world *World) Objects

type Scene

type Scene struct {
	ID      int64  `db:"id"`
	LayerID int64  `db:"layer_id"`
	Name    string `db:"name"`
}

Scene represents a set of geometric objects in a 'layer'. Scenes is the smallest updatable entity - to add or update geometric objects an entire scene must be added/updated.

type Scenes

type Scenes interface {
	// GetAll returns all scenes in a layer.
	GetAll() ([]*Scene, error)
	// Get returns the scene with the given ID.
	Get(id int64) (*Scene, error)
	// Add creates a new scene in the database and returns the ID.
	Add(scene *Scene) (int64, error)
	// Delete deletes the scene with the given ID from the database.
	Delete(sceneid int64) error
}

Scenes contains functionality for adding and deleting scenes of a layer.

func NewScenesDB

func NewScenesDB(tx *sqlx.Tx, layerID int64) Scenes

type SimpleObject

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

func NewSimpleObject

func NewSimpleObject(bounds vec3.Box, geometryData []byte, metadata interface{}) *SimpleObject

func (*SimpleObject) Bounds

func (o *SimpleObject) Bounds() *vec3.Box

func (*SimpleObject) GeometryData

func (o *SimpleObject) GeometryData() []byte

func (*SimpleObject) ID

func (o *SimpleObject) ID() int64

func (*SimpleObject) LayerID

func (o *SimpleObject) LayerID() int64

func (*SimpleObject) Metadata

func (o *SimpleObject) Metadata() interface{}

func (*SimpleObject) SceneID

func (o *SimpleObject) SceneID() int64

func (*SimpleObject) WorldID

func (o *SimpleObject) WorldID() int64

type World

type World struct {
	ID   int64  `db:"id"`
	Name string `db:"name"`
}

World represents collection of data that relates to each other, but not necessarily to data in other worlds. A world consists of many 'layers' - e.g. buildings, roads, landscape etc.

type Worlds

type Worlds interface {
	// GetAll returns all known 'worlds'.
	GetAll() ([]*World, error)
	// Get returns the world with the given ID.
	Get(id int64) (*World, error)
	// Add adds a new world and returns the ID
	// of the world. The ID field provided world is also
	// updated.
	Add(world *World) (int64, error)
	// Delete deletes the world with the given ID.
	Delete(worldid int64) error
}

Worlds is an interface for retrieving worlds which contains 'layers' which in turn contains 'scenes' of geometric objects.

func NewWorldsDB

func NewWorldsDB(tx *sqlx.Tx) Worlds

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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