inheritance tree
FlagsMixin
|
|
|
MappingMixin
class definition
[abstract class] A mixin class for various traversing and mapping methods on the whole score hierarchy.
class MappingMixin (Inheritance-free)
attr flags
- addFlag(F)
Adds an arbitrary flag F to self. A flag must be a literal.
- collect(?Xs excludeSelf:ExcludeSelf level:Level mode:Mode test:Test)
The collect methods collects (possibly all) score objects in a list to make them accessible for, e.g., various list mapping functions. The method collects objects related to self (an item) by the value of the item attributes containers, parameters and the container attribute items. The methods supports a few features to control the collecting.
If feature mode
is set to tree
(the default), collect recursively collects the score objects and subobjects contained in self (i.e. both the attributes items and parameters are traversed). If mode
is set to graph
, both objects contained in self and containers self is contained in are collected (i.e. all three attributes items, parameters, and containers are traversed).
If feature level
is set to all
(the default), collect collects score objects recursively into arbitrary depth. However, the depth can be controlled by specifying an integer value for level
.
The feature test
expects a unary function returning a boolean or an atom representing a boolean unary method understood by all objects in self. The method collect only collects score objects fulfilling the test function/method.
The feature excludeSelf
expects a Boolean. If true (the default), self is not included in the result.
collect visits containers in depth-first fashion from left to right which affects the order of the objects in the returned list. E.g., collecting all events in a few nested sequentials in tree mode returns a list with all events ordered by start time.
NB: collect blocks if self is not fully initialised (e.g. created by Score.makeScore2) or if Test blocks at some object in self (e.g. because the object is only partially determined).
- count(?N excludeSelf:ExcludeSelf level:Level mode:Mode test:Test)
The method count counts a number of collected score objects. The method supports the features mode
, level
, test
, and excludeSelf
. These features have the same meaning as in the method collect.
- filter(?Xs Fn excludeSelf:ExcludeSelf level:Level mode:Mode)
The method filter collects a number of score objects fulfilling Fn, a the unary function returning a boolean. The method supports the features mode
, test
, and excludeSelf
. These features have the same meaning as in the method collect.
- find(?Xs Fn excludeSelf:ExcludeSelf level:Level mode:Mode)
The method find returns the first score object in self fulfilling Fn, a the unary function returning a boolean. The method supports the features mode
, level
, and excludeSelf
. These features have the same meaning as in the method collect.
NB: this implementation is inefficient (first collects all score objects).
- forAll(Proc excludeSelf:ExcludeSelf level:Level mode:Mode test:Test)
The method forAll maps the procedure Proc to a number of collected score objects. Proc may also be an atom representing a method of no arguments and understood by all objects in self fulfilling Test. The method supports the features mode
, level
, test
, and excludeSelf
. These features have the same meaning as in the method collect.
- forAllThreaded(Proc excludeSelf:ExcludeSelf level:Level mode:Mode test:Test)
The method traverses all score objects in self (i.e. items and parameters) and applies unary procedure (or null-ary method) Proc on every object returning true for the unary function (or unary method) Test. However, the method does not effect the object self itself -- only the parameters and (if self is a container) items of self are effected recursively. Traversing happens concurrently -- the method does not suspend even if the result of getItems or getParameters is not yet fully determined.
- hasFlag(?B F)
Tests whether self has flag F. Method returns a boolean.
- initFlags()
[aux method] Method must not be called by user.
- map(?Xs Fn excludeSelf:ExcludeSelf level:Level mode:Mode test:Test)
The method map maps the function Fn to a number of collected score objects and returns a list with all results. Fn may also be an atom representing a unary method understood by all objects in self fulfilling Test. The method supports the features mode
, level
, test
, and excludeSelf
. These features have the same meaning as in the method collect.
- mappend(?Xs Fn excludeSelf:ExcludeSelf level:Level mode:Mode test:Test)
The method map maps the function Fn (which must return a list) to a number of collected score objects and returns a list with all results appended. Fn may also be an atom representing a unary method understood by all objects in self fulfilling Test. The method supports the features mode
, level
, test
, and excludeSelf
. These features have the same meaning as in the method collect.
- removeAllFlags()
[aux method] Method should not be called by user (method removes all flags from self).
- removeFlag(F)
Removes flag F from self.
end