Class: Operation
Defined in: | lib/Types/BasicTypes.coffee |
Overview
A generic interface to operations.
An operation has the following methods: _encode: encodes an operation (needed only if instance of this operation is sent). execute: execute the effects of this operations. Good examples are Insert-type and AddName-type val: in the case that the operation holds a value
Furthermore an encodable operation has a parser.
Direct Known Subclasses
Instance Method Summary
- # (void) on(event, f) Add an event listener.
- # (void) callEvent(event, args) Fire an event.
- # (void) setParent(o) Set the parent of this operation.
- # (void) getUid() Computes a unique identifier (uid) that identifies this operation.
- # (void) execute() Private Notify the all the listeners.
- ~ (void) saveOperation(name, op_uid) Private Operations may depend on other operations (linked lists, etc.).
- # (Boolean) validateSavedOperations() Private After calling this function all not instantiated operations will be accessible.
Constructor Details
#
(void)
constructor(uid)
Instance Method Details
#
(void)
on(event, f)
Add an event listener. It depends on the operation which events are supported.
#
(void)
callEvent(event, args)
Fire an event. TODO: Do something with timeouts. You don't want this to fire for every operation (e.g. insert).
#
(void)
setParent(o)
Set the parent of this operation.
#
(void)
getUid()
Computes a unique identifier (uid) that identifies this operation.
#
(void)
execute()
Private
Notify the all the listeners.
~
(void)
saveOperation(name, op_uid)
~
(void)
saveOperation(name, op)
Operations may depend on other operations (linked lists, etc.). The saveOperation and validateSavedOperations methods provide an easy way to refer to these operations via an uid or object reference.
For example: We can create a new Delete operation that deletes the operation $o like this
- var d = new Delete(uid, $o); or
- var d = new Delete(uid, $o.getUid());
Either way we want to access $o via d.deletes. In the second case validateSavedOperations must be called first.
#
(Boolean)
validateSavedOperations()
Private
After calling this function all not instantiated operations will be accessible.