There are 2 main methods used for the evaluation:
These functions are mutually exclusive. That means that
evalChildren does not eval the current Node,
but only children of the current Node.
By default the implementation of
eval() is “empty” and return 0. However, if successful, eval resets the Node not to be Dirty nor Invalid.
This method is supposed to be overridden by your own implementation. If you look for examples, please check
examples/example_calculator to get inspiration on how to setup your own
The evaluation takes advantage of the Node flags described below.
Node has 2 flags:
The Invalid flag has always higher priority over Dirty. This means that if the Node is Invalid it does not matter whether it is Dirty or not.
To mark a node as Dirty or Invalid there are respective methods
markInvalid(). Both methods take bool parameter for the new state.
You can mark Node dirty by setting the parameter to
True. Also you can un-mark the state by passing
For both flags there are 3 methods available:
markInvalid()- to mark only the Node
markChildrenInvalid()- to mark only the direct (first level) children of the Node
markDescendantsInvalid()- to mark it self and all descendant children of the Node
The same applies to the Dirty flag:
markDirty()- to mark only the Node
markChildrenDirty()- to mark only the direct (first level) children of the Node
markDescendantsDirty()- to mark it self and all descendant children of the Node
Descendants or Children are always connected to the Output(s) of the current Node.
When a node is marked as Dirty or Invalid one of the two event methods,
onMarkedDirty(), is called. By default, these methods do nothing.
However, they are implemented for you to override and use them in your own evaluation system.