The evaluation system uses eval() and evalChildren(). eval is supposed to be overridden by your own implementation. The evaluation logic uses Flags for marking the Nodes as Dirty and/or Invalid.

Evaluation Functions

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 out examples/example_calculator to get inspiration on how to setup your own Node evaluation.

The evaluation takes advantage of the Node flags described below.

Node Flags

Each Node has 2 flags:

  • Dirty

  • Invalid

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 markDirty() and 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 False value.

For both flags there are 3 methods available:

The same applies to the Dirty flag:

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, onMarkedInvalid() or 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.