operation

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotApplicableDataType occurs when attempting to execute an operation
	// on a data type that cannot be executed.
	ErrNotApplicableDataType = errors.New("not applicable datatype")
)

Functions

This section is empty.

Types

type Add

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

Add is an operation representing adding an element to an Array.

func NewAdd

func NewAdd(
	parentCreatedAt *time.Ticket,
	prevCreatedAt *time.Ticket,
	value json.Element,
	executedAt *time.Ticket,
) *Add

NewAdd creates a new instance of Add.

func (*Add) Execute

func (o *Add) Execute(root *json.Root) error

Execute executes this operation on the given document(`root`).

func (*Add) ExecutedAt

func (o *Add) ExecutedAt() *time.Ticket

ExecutedAt returns execution time of this operation.

func (*Add) ParentCreatedAt

func (o *Add) ParentCreatedAt() *time.Ticket

ParentCreatedAt returns the creation time of the Array.

func (*Add) PrevCreatedAt

func (o *Add) PrevCreatedAt() *time.Ticket

PrevCreatedAt returns the creation time of previous element.

func (*Add) SetActor

func (o *Add) SetActor(actorID *time.ActorID)

SetActor sets the given actor to this operation.

func (*Add) Value

func (o *Add) Value() json.Element

Value returns the value of this operation.

type Edit

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

Edit is an operation representing editing Text.

func NewEdit

func NewEdit(
	parentCreatedAt *time.Ticket,
	from *json.RGATreeSplitNodePos,
	to *json.RGATreeSplitNodePos,
	latestCreatedAtMapByActor map[string]*time.Ticket,
	content string,
	executedAt *time.Ticket,
) *Edit

NewEdit creates a new instance of Edit.

func (*Edit) Content

func (e *Edit) Content() string

Content returns the content of Edit.

func (*Edit) CreatedAtMapByActor

func (e *Edit) CreatedAtMapByActor() map[string]*time.Ticket

CreatedAtMapByActor returns the map that stores the latest creation time by actor for the nodes included in the editing range.

func (*Edit) Execute

func (e *Edit) Execute(root *json.Root) error

Execute executes this operation on the given document(`root`).

func (*Edit) ExecutedAt

func (e *Edit) ExecutedAt() *time.Ticket

ExecutedAt returns execution time of this operation.

func (*Edit) From

func (e *Edit) From() *json.RGATreeSplitNodePos

From returns the start point of the editing range.

func (*Edit) ParentCreatedAt

func (e *Edit) ParentCreatedAt() *time.Ticket

ParentCreatedAt returns the creation time of the Text.

func (*Edit) SetActor

func (e *Edit) SetActor(actorID *time.ActorID)

SetActor sets the given actor to this operation.

func (*Edit) To

func (e *Edit) To() *json.RGATreeSplitNodePos

To returns the end point of the editing range.

type Increase

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

Increase represents an operation that increments a numeric value to Counter. Among Primitives, numeric types Integer, Long, and Double are used as values.

func NewIncrease

func NewIncrease(
	parentCreatedAt *time.Ticket,
	value json.Element,
	executedAt *time.Ticket,
) *Increase

NewIncrease creates the increase instance.

func (*Increase) Execute

func (o *Increase) Execute(root *json.Root) error

Execute executes this operation on the given document(`root`).

func (*Increase) ExecutedAt

func (o *Increase) ExecutedAt() *time.Ticket

ExecutedAt returns execution time of this operation.

func (*Increase) ParentCreatedAt

func (o *Increase) ParentCreatedAt() *time.Ticket

ParentCreatedAt returns the creation time of Counter.

func (*Increase) SetActor

func (o *Increase) SetActor(actorID *time.ActorID)

SetActor sets the given actor to this operation.

func (*Increase) Value

func (o *Increase) Value() json.Element

Value return the value of this operation.

type Move

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

Move is an operation representing moving an element to an Array.

func NewMove

func NewMove(
	parentCreatedAt *time.Ticket,
	prevCreatedAt *time.Ticket,
	createdAt *time.Ticket,
	executedAt *time.Ticket,
) *Move

NewMove creates a new instance of Move.

func (*Move) CreatedAt

func (o *Move) CreatedAt() *time.Ticket

CreatedAt returns the creation time of the target element.

func (*Move) Execute

func (o *Move) Execute(root *json.Root) error

Execute executes this operation on the given document(`root`).

func (*Move) ExecutedAt

func (o *Move) ExecutedAt() *time.Ticket

ExecutedAt returns execution time of this operation.

func (*Move) ParentCreatedAt

func (o *Move) ParentCreatedAt() *time.Ticket

ParentCreatedAt returns the creation time of the Array.

func (*Move) PrevCreatedAt

func (o *Move) PrevCreatedAt() *time.Ticket

PrevCreatedAt returns the creation time of previous element.

func (*Move) SetActor

func (o *Move) SetActor(actorID *time.ActorID)

SetActor sets the given actor to this operation.

type Operation

type Operation interface {

	// Execute executes this operation on the given document(`root`).
	Execute(root *json.Root) error

	// ExecutedAt returns execution time of this operation.
	ExecutedAt() *time.Ticket

	// SetActor sets the given actor to this operation.
	SetActor(id *time.ActorID)

	// ParentCreatedAt returns the creation time of the target element to
	// execute the operation.
	ParentCreatedAt() *time.Ticket
}

Operation represents an operation to be executed on a document.

type Remove

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

Remove is an operation representing removes an element from Container.

func NewRemove

func NewRemove(
	parentCreatedAt *time.Ticket,
	createdAt *time.Ticket,
	executedAt *time.Ticket,
) *Remove

NewRemove creates a new instance of Remove.

func (*Remove) CreatedAt

func (o *Remove) CreatedAt() *time.Ticket

CreatedAt returns the creation time of the target element.

func (*Remove) Execute

func (o *Remove) Execute(root *json.Root) error

Execute executes this operation on the given document(`root`).

func (*Remove) ExecutedAt

func (o *Remove) ExecutedAt() *time.Ticket

ExecutedAt returns execution time of this operation.

func (*Remove) ParentCreatedAt

func (o *Remove) ParentCreatedAt() *time.Ticket

ParentCreatedAt returns the creation time of the Container.

func (*Remove) SetActor

func (o *Remove) SetActor(actorID *time.ActorID)

SetActor sets the given actor to this operation.

type RichEdit

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

RichEdit is an operation representing editing RichText. Most of the same as Edit, but with additional style properties, attributes.

func NewRichEdit

func NewRichEdit(
	parentCreatedAt *time.Ticket,
	from *json.RGATreeSplitNodePos,
	to *json.RGATreeSplitNodePos,
	latestCreatedAtMapByActor map[string]*time.Ticket,
	content string,
	attributes map[string]string,
	executedAt *time.Ticket,
) *RichEdit

NewRichEdit creates a new instance of RichEdit.

func (*RichEdit) Attributes

func (e *RichEdit) Attributes() map[string]string

Attributes returns the attributes of this Edit.

func (*RichEdit) Content

func (e *RichEdit) Content() string

Content returns the content of RichEdit.

func (*RichEdit) CreatedAtMapByActor

func (e *RichEdit) CreatedAtMapByActor() map[string]*time.Ticket

CreatedAtMapByActor returns the map that stores the latest creation time by actor for the nodes included in the editing range.

func (*RichEdit) Execute

func (e *RichEdit) Execute(root *json.Root) error

Execute executes this operation on the given document(`root`).

func (*RichEdit) ExecutedAt

func (e *RichEdit) ExecutedAt() *time.Ticket

ExecutedAt returns execution time of this operation.

func (*RichEdit) From

func (e *RichEdit) From() *json.RGATreeSplitNodePos

From returns the start point of the editing range.

func (*RichEdit) ParentCreatedAt

func (e *RichEdit) ParentCreatedAt() *time.Ticket

ParentCreatedAt returns the creation time of the RichText.

func (*RichEdit) SetActor

func (e *RichEdit) SetActor(actorID *time.ActorID)

SetActor sets the given actor to this operation.

func (*RichEdit) To

To returns the end point of the editing range.

type Select

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

Select represents an operation that selects an area in the text.

func NewSelect

func NewSelect(
	parentCreatedAt *time.Ticket,
	from *json.RGATreeSplitNodePos,
	to *json.RGATreeSplitNodePos,
	executedAt *time.Ticket,
) *Select

NewSelect creates a new instance of Select.

func (*Select) Execute

func (s *Select) Execute(root *json.Root) error

Execute executes this operation on the given document(`root`).

func (*Select) ExecutedAt

func (s *Select) ExecutedAt() *time.Ticket

ExecutedAt returns execution time of this operation.

func (*Select) From

func (s *Select) From() *json.RGATreeSplitNodePos

From returns the start point of the selection.

func (*Select) ParentCreatedAt

func (s *Select) ParentCreatedAt() *time.Ticket

ParentCreatedAt returns the creation time of the Text.

func (*Select) SetActor

func (s *Select) SetActor(actorID *time.ActorID)

SetActor sets the given actor to this operation.

func (*Select) To

func (s *Select) To() *json.RGATreeSplitNodePos

To returns the end point of the selection.

type Set

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

Set represents an operation that stores the value corresponding to the given key in the Object.

func NewSet

func NewSet(
	parentCreatedAt *time.Ticket,
	key string,
	value json.Element,
	executedAt *time.Ticket,
) *Set

NewSet creates a new instance of Set.

func (*Set) Execute

func (o *Set) Execute(root *json.Root) error

Execute executes this operation on the given document(`root`).

func (*Set) ExecutedAt

func (o *Set) ExecutedAt() *time.Ticket

ExecutedAt returns execution time of this operation.

func (*Set) Key

func (o *Set) Key() string

Key returns the key of this operation.

func (*Set) ParentCreatedAt

func (o *Set) ParentCreatedAt() *time.Ticket

ParentCreatedAt returns the creation time of the Object.

func (*Set) SetActor

func (o *Set) SetActor(actorID *time.ActorID)

SetActor sets the given actor to this operation.

func (*Set) Value

func (o *Set) Value() json.Element

Value returns the value of this operation.

type Style

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

Style is an operation applies the style of the given range to RichText.

func NewStyle

func NewStyle(
	parentCreatedAt *time.Ticket,
	from *json.RGATreeSplitNodePos,
	to *json.RGATreeSplitNodePos,
	attributes map[string]string,
	executedAt *time.Ticket,
) *Style

NewStyle creates a new instance of Style.

func (*Style) Attributes

func (e *Style) Attributes() map[string]string

Attributes returns the attributes of this operation.

func (*Style) Execute

func (e *Style) Execute(root *json.Root) error

Execute executes this operation on the given document(`root`).

func (*Style) ExecutedAt

func (e *Style) ExecutedAt() *time.Ticket

ExecutedAt returns execution time of this operation.

func (*Style) From

func (e *Style) From() *json.RGATreeSplitNodePos

From returns the start point of the editing range.

func (*Style) ParentCreatedAt

func (e *Style) ParentCreatedAt() *time.Ticket

ParentCreatedAt returns the creation time of the RichText.

func (*Style) SetActor

func (e *Style) SetActor(actorID *time.ActorID)

SetActor sets the given actor to this operation.

func (*Style) To

func (e *Style) To() *json.RGATreeSplitNodePos

To returns the end point of the editing range.

Jump to

Keyboard shortcuts

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