dml

package
v0.0.0-...-b1bb88e Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2021 License: LGPL-2.1 Imports: 30 Imported by: 0

Documentation

Overview

Transaction.go

Data descibes a Data object with its respective properties to store things in a database

Vector

Map

parser for the datastructure markup language

Vector

Vector

Index

Constants

View Source
const Error_Arguments_Wrong = "arguments_wrong"
View Source
const Error_Compiler = "compilation_failed"
View Source
const Error_Fatal = "fatal_problem"
View Source
const Error_Filesystem = "filesystem_not_accessible"
View Source
const Error_Key_Not_Available = "key_not_available"
View Source
const Error_Operation_Invalid = "operation_invalid"
View Source
const Error_Setup_Invalid = "setup_invalid"
View Source
const Error_Syntax = "syntax_error"
View Source
const Error_Type = "type"

Variables

This section is empty.

Functions

func DataTypeDecode

func DataTypeDecode(code string) (interface{}, error)

func NewBaseBehaviour

func NewBaseBehaviour(runtime *Runtime) (*behaviour, error)

func NewBehaviourHandler

func NewBehaviourHandler(runtime *Runtime) behaviourHandler

func NewEventHandler

func NewEventHandler() eventHandler

func NewMethodHandler

func NewMethodHandler() methodHandler

func NewObject

func NewObject(rntm *Runtime) (*object, error)

func NewPrintManager

func NewPrintManager() *printManager

func NewPropertyHandler

func NewPropertyHandler() propertyHandler

func SetupGlobals

func SetupGlobals(rntm *Runtime)

func UnifyDataType

func UnifyDataType(val interface{}) interface{}

changes Value to its main type from multiple subtypes, e.g. int64 from int and int16 Note: No type checking is done!

Types

type Behaviour

type Behaviour interface {
	Object

	GetBehaviourType() string                                        //returns the type of behaviour, e.g. "Transaction". Needed to allow multiple different structs implement single behaviour
	HandleEvent(Identifier, Identifier, string, []interface{}) error //Entry for any kind of behhaviour handling. Here the event that can be handled according to the relevant Manager are provided
	HandleKeyword(Identifier, string, interface{}) error             //Handle Keywords on WAMP Api call to the object
}
+extract prio:3

.. dml:behaviour:: Behaviour

:abstract:

Base class for all behaviours, adding common properties and events. It cannot be
used directly, only behaviours derived from it. It does add the possibility to add
custom properties,  events and functions. Children are not allowed.

.. dml:property:: name
	:const:
	:type: string

	A property defining the name of the behaviour. The name can be used to access ut in
	the hirarchy, either in JavaScript code or as WAMP uri. It is mandatory to set the name
	of each behaviour.

.. dml:property:: parent
	:const:
	:type: Data

	The parent object of the behaviour, the one which it extends.

.. dml:property:: recursive
	:const:
	:type: bool

	Defines if the behaviour is applied recursively for all children and subobjects
	of the behaviours parent. For example, if a behaviour is added to a Map Object,
	it may watch for changes in that object. If recursive is true, it will also look
	for all changes in any children or value objects of that Map.

	:default: false

.. dml:event:: onBeforePropertyChange

	Emitted bevore a property of the object changes. At time of emit the
	property still has its old value.

	:argument string Property: Name of the property thats about to be changed

.. dml:event:: onPropertyChanged

	Emitted when a property was changed. The value of the property is already the
	new one when emitted.

	:argument string Property: Name of the property thats was changed

type BehaviourHandler

type BehaviourHandler interface {

	//management functions for behaviours:
	//here general behaviour objects are handled, as a object has a defined set of behaviours.
	//This does not provide any database access, only logic
	HasBehaviour(string) bool
	GetBehaviourObject(string) Behaviour
	AddBehaviourObject(Behaviour) error
	Behaviours() []string

	//This function is used to retrieve a behaviour database access Identifier
	GetBehaviourIdentifier(Identifier, string) (Identifier, error)
	SetBehaviourIdentifier(Identifier, string, Identifier) error
	HasBehaviourIdentifier(Identifier, string) (bool, error)

	//convinience function for combined logic and db access
	GetBehaviour(Identifier, string) (dmlSet, error)

	//Forwards event to all behaviours given in list, and returns the ones not available
	//Identifier, source object, eventname, arguments, behaviours to forward, recursive (true) or original object(false).
	HandleBehaviourEvent(Identifier, Identifier, string, []interface{}, []string, bool) ([]string, error)

	//Forwards WAMP keywords to all behaviours given in list, and returns the ones not available
	//Identifier, keyword arguments, behaviours to forward, recursive (true) or original object(false).
	HandleBehaviourKeywords(Identifier, map[string]interface{}, []string, bool) ([]string, error)
	// contains filtered or unexported methods
}

* Handler for different behaviours within an object

type Boolean

type Boolean bool

special type to make bool handling easier

func (*Boolean) Capture

func (b *Boolean) Capture(v []string) error

type CreatorFunc

type CreatorFunc func(rntm *Runtime) (Object, error)

Function prototype that can create new object types in DML

type DML

type DML struct {

	//next to imports only a single object is allowed: root must be unambigious
	Imports []*astImport `{ @@ }`
	Object  *astObject   `{ @@ }`
}

the file format

type Data

type Data interface {
	Object
	BehaviourHandler

	//Data hirarchy allows childs. Here we add the structure and logic by
	//adding static objects. Database access by identifiers is handled seperatly
	AddChildObject(Data)
	GetChildObjects() []Data

	//Data hirarchy allows childs
	AddChildIdentifier(Identifier, Identifier) error
	GetChildIdentifiers(Identifier) ([]Identifier, error)
	GetChildIdentifierByName(Identifier, string) (Identifier, error)

	//little convinience function for children hirarchy combining objects and IDs
	GetChildren(Identifier) ([]dmlSet, error)
	GetChildByName(Identifier, string) (dmlSet, error)

	GetSubobjects(id Identifier) ([]dmlSet, error) //Convinience function to get all subobjects, including childs, behaviours any any created ones
	Created(id Identifier) error
	ProcessBehaviourKeywords(id Identifier, kwargs map[string]interface{}) error //handles the keyword arguments in the behaviours of this object                                                          //emits onCreated event for this and all subobjects (not behaviours)
	// contains filtered or unexported methods
}
+extract prio:1

.. dml:object:: Data

The most basic implementation of a DML Object. It allows to add properties, events
and functions and can hold other Objects and Behaviours as children. It has no other
special functionality. It is intended as dml grouping 	object as well as base object
for all other data types
Data does allow for children. Note that children are static values, they cannot change at
runtime. Hence they are different to dynamic objects as are possible with Maps etc. Children are
used purely for the static DML hirarchy.

.. dml:property:: name
	:const:
	:type: string

	A property defining the name of the object. The name can than be used to access in
	the hirarchy, either in JavaScript code or as WAMP uri. It is mandatory to set the name
	of each object.

.. dml:property:: parent
	:const:
	:type: Data

	The parent object of the object. The value is null for the toplevel object.

.. dml:property:: children
	:const:
	:type: [Data]

	A list of all children the Data object has. Note that this are only the children defined
	in the DML file itself, not the dynamic subobjects some types can add, like maps entries.

.. dml:property behaviours
	:const:
	:type: [Behaviour]

	A list of all behaviours the Data object has attched to it.

.. dml:event:: onBeforePropertyChange

	Emitted bevore a property of the object changes. At time of emit the
	property still has its old value.

	:argument string Property: Name of the property thats about to be changed

.. dml:event:: onPropertyChanged

	Emitted when a property was changed. The value of the property is already the
	new one when emitted.

	:argument string Property: Name of the property thats was changed

.. dml:event:: onCreated

	Emitted after the object was created and fully setup. It will be emitted
	only dynamically created objects, for example when used as value in Maps,
	and not the ones in the static DML hirarchy.

.. dml:event:: onRemove

	Emitted after the object is about to be removed. At the time of emitting
	the object is still fully setup and accessible, the removing will happen after
	all handlers have been executed.
	As static hirarchy objects cannot be removed this event will be emitted only
	for dynamically created objects, for example when used as value in Maps etc.

.. dml:event:: onBeforeChange

	This is a general event, emitted bevore the object itself changes, no matter
	what the changes are. This is not emitted for changed properties, there is a
	custom event for that, but if the objects content is manipulated. This means that
	for a Data object it will never be emitted, as it does not have any object
	content, but it may be emitted for derived object types like maps.

	.. note:: Most derived classes that emit this event will also have custom
			  events that are more specialized for the eexact changes that happend.

.. dml:event:: onChanged

	This is a general event, emitted after the object has changed, no matter
	what the changes are. This is not emitted for changed properties, there is a
	custom event for that, but if the objects content was manipulated. This means that
	for a Data object it will never be emitted, as it does not have any object
	content, but it may be emitted for derived object types like maps.

	.. note:: Most derived classes that emit this event will also have custom
			  events that are more specialized for the eexact changes that happend.

type DataImpl

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

func NewDataBaseClass

func NewDataBaseClass(rntm *Runtime) (*DataImpl, error)

func (*DataImpl) AddBehaviourObject

func (self *DataImpl) AddBehaviourObject(behaviour Behaviour) error

func (*DataImpl) AddChildIdentifier

func (self *DataImpl) AddChildIdentifier(id Identifier, child Identifier) error

func (*DataImpl) AddChildObject

func (self *DataImpl) AddChildObject(child Data)

func (DataImpl) BeforePropertyChange

func (self DataImpl) BeforePropertyChange(id Identifier, name string) error

func (*DataImpl) Behaviours

func (self *DataImpl) Behaviours() []string

func (DataImpl) BuildVersionedKey

func (self DataImpl) BuildVersionedKey(id Identifier, storage datastore.StorageType, entries ...interface{}) datastore.Key

func (*DataImpl) Created

func (self *DataImpl) Created(id Identifier) error

func (DataImpl) EraseFromDB

func (self DataImpl) EraseFromDB(id Identifier) error

func (*DataImpl) EventEmitted

func (self *DataImpl) EventEmitted(id Identifier, event string, args ...interface{}) error

Override event emitted, to forward them to the behaviour handler

func (DataImpl) FixStateAsVersion

func (self DataImpl) FixStateAsVersion(id Identifier) (datastore.VersionID, error)

func (*DataImpl) GetBehaviour

func (self *DataImpl) GetBehaviour(id Identifier, name string) (dmlSet, error)

func (*DataImpl) GetBehaviourIdentifier

func (self *DataImpl) GetBehaviourIdentifier(id Identifier, name string) (Identifier, error)

func (*DataImpl) GetBehaviourObject

func (self *DataImpl) GetBehaviourObject(name string) Behaviour

func (*DataImpl) GetByKey

func (self *DataImpl) GetByKey(id Identifier, key Key) (interface{}, error)

func (*DataImpl) GetChildByName

func (self *DataImpl) GetChildByName(id Identifier, name string) (dmlSet, error)

func (*DataImpl) GetChildIdentifierByName

func (self *DataImpl) GetChildIdentifierByName(id Identifier, name string) (Identifier, error)

func (*DataImpl) GetChildIdentifiers

func (self *DataImpl) GetChildIdentifiers(id Identifier) ([]Identifier, error)

func (*DataImpl) GetChildObjects

func (self *DataImpl) GetChildObjects() []Data

func (*DataImpl) GetChildren

func (self *DataImpl) GetChildren(id Identifier) ([]dmlSet, error)

func (DataImpl) GetCurrentVersion

func (self DataImpl) GetCurrentVersion(id Identifier) (datastore.VersionID, error)

func (DataImpl) GetDBList

func (self DataImpl) GetDBList(id Identifier, key []byte) (datastore.List, error)

func (DataImpl) GetDBListVersioned

func (self DataImpl) GetDBListVersioned(id Identifier, key []byte) (datastore.ListVersioned, error)

func (DataImpl) GetDBMap

func (self DataImpl) GetDBMap(id Identifier, key []byte) (datastore.Map, error)

func (DataImpl) GetDBMapVersioned

func (self DataImpl) GetDBMapVersioned(id Identifier, key []byte) (datastore.MapVersioned, error)

func (DataImpl) GetDBValue

func (self DataImpl) GetDBValue(id Identifier, key []byte) (datastore.Value, error)

func (DataImpl) GetDBValueVersioned

func (self DataImpl) GetDBValueVersioned(id Identifier, key []byte) (datastore.ValueVersioned, error)

func (DataImpl) GetDataType

func (self DataImpl) GetDataType(id Identifier) (DataType, error)

func (DataImpl) GetJSObject

func (self DataImpl) GetJSObject(id Identifier) *goja.Object

func (DataImpl) GetJSPrototype

func (self DataImpl) GetJSPrototype() *goja.Object

func (DataImpl) GetJSRuntime

func (self DataImpl) GetJSRuntime() *goja.Runtime

func (*DataImpl) GetKeys

func (self *DataImpl) GetKeys(id Identifier) ([]Key, error)

func (DataImpl) GetLatestVersion

func (self DataImpl) GetLatestVersion(id Identifier) (datastore.VersionID, error)

func (DataImpl) GetObjectDataType

func (self DataImpl) GetObjectDataType() DataType

func (DataImpl) GetObjectPath

func (self DataImpl) GetObjectPath(id Identifier) (string, error)

func (DataImpl) GetParent

func (self DataImpl) GetParent(id Identifier) (dmlSet, error)

func (DataImpl) GetParentIdentifier

func (self DataImpl) GetParentIdentifier(id Identifier) (Identifier, error)

func (DataImpl) GetRuntime

func (self DataImpl) GetRuntime() *Runtime

func (*DataImpl) GetSubobjects

func (self *DataImpl) GetSubobjects(id Identifier) ([]dmlSet, error)

func (*DataImpl) HandleBehaviourEvent

func (self *DataImpl) HandleBehaviourEvent(id Identifier, source Identifier, event string, args []interface{}, behaviours []string, isrecursive bool) ([]string, error)

func (*DataImpl) HandleBehaviourKeywords

func (self *DataImpl) HandleBehaviourKeywords(id Identifier, kwargs map[string]interface{}, behaviours []string, isrecursive bool) ([]string, error)

func (*DataImpl) HasBehaviour

func (self *DataImpl) HasBehaviour(name string) bool

func (*DataImpl) HasBehaviourIdentifier

func (self *DataImpl) HasBehaviourIdentifier(id Identifier, name string) (bool, error)

func (*DataImpl) HasKey

func (self *DataImpl) HasKey(id Identifier, key Key) (bool, error)

func (DataImpl) HasUpdates

func (self DataImpl) HasUpdates(id Identifier) (bool, error)

Versioned Data Interface with identifiers for whole object

func (DataImpl) HasVersions

func (self DataImpl) HasVersions(id Identifier) (bool, error)

func (DataImpl) InitializeDB

func (self DataImpl) InitializeDB(id Identifier) error

func (DataImpl) KeysAllHaveVersions

func (self DataImpl) KeysAllHaveVersions(keys []datastore.Key) (bool, error)

func (DataImpl) KeysAnyHasUpdates

func (self DataImpl) KeysAnyHasUpdates(keys []datastore.Key) (bool, error)

func (DataImpl) KeysFixStateAsVersion

func (self DataImpl) KeysFixStateAsVersion(keys []datastore.Key) ([]datastore.VersionID, error)

func (DataImpl) KeysGetCurrentVersion

func (self DataImpl) KeysGetCurrentVersion(keys []datastore.Key) ([]datastore.VersionID, error)

func (DataImpl) KeysGetLatestVersion

func (self DataImpl) KeysGetLatestVersion(keys []datastore.Key) ([]datastore.VersionID, error)

func (DataImpl) KeysLoadVersion

func (self DataImpl) KeysLoadVersion(keys []datastore.Key, versions []datastore.VersionID) error

func (DataImpl) KeysRemoveVersionsUpFrom

func (self DataImpl) KeysRemoveVersionsUpFrom(keys []datastore.Key, versions []datastore.VersionID) error

func (DataImpl) KeysRemoveVersionsUpTo

func (self DataImpl) KeysRemoveVersionsUpTo(keys []datastore.Key, versions []datastore.VersionID) error

func (DataImpl) KeysResetHead

func (self DataImpl) KeysResetHead(keys []datastore.Key) error

func (DataImpl) LoadVersion

func (self DataImpl) LoadVersion(id Identifier, vId datastore.VersionID) error

func (*DataImpl) ProcessBehaviourKeywords

func (self *DataImpl) ProcessBehaviourKeywords(id Identifier, kwargs map[string]interface{}) error

func (DataImpl) PropertyChanged

func (self DataImpl) PropertyChanged(id Identifier, name string) error

func (DataImpl) RemoveVersionsUpFrom

func (self DataImpl) RemoveVersionsUpFrom(id Identifier, vId datastore.VersionID) error

func (DataImpl) RemoveVersionsUpTo

func (self DataImpl) RemoveVersionsUpTo(id Identifier, vId datastore.VersionID) error

func (DataImpl) ResetHead

func (self DataImpl) ResetHead(id Identifier) error

func (*DataImpl) SetBehaviourIdentifier

func (self *DataImpl) SetBehaviourIdentifier(id Identifier, name string, behaviour Identifier) error

func (DataImpl) SetDataType

func (self DataImpl) SetDataType(id Identifier, dt DataType) error

func (DataImpl) SetObjectDataType

func (self DataImpl) SetObjectDataType(dt DataType)

func (*DataImpl) SetObjectPath

func (self *DataImpl) SetObjectPath(id Identifier, path