Operations and variables
This document is meant to articulate the internal logic used for operations and variable annotations.
First note that variableAnnotationNameMap
contains all variables, even those which are properties on the class. The operationVariableNameMap
contains the subset of those that needs to be computed with an operation.
Second note that `operationVariableNameMap
There are a couple of important points,
- One operation can produce many variables.
- Variables may be cached to prevent re-computation.
When the user adds an operation, the following takes place
- The operation is associated with its name in the
operationNameMap
. - Each variable is added to the
variableAnnotationNameMap
and possibly thetimeDependentVariablesNameMap
. - Each variable is associated with this operation using the
operationVariableNameMap
.
When the user requests a variable, the following takes place
- Check the variable cache to see if its already been computed (if so, return).
- Use the
variableAnnotationNameMap
, to find the variable annotation, and then retrieve the operation name - Use
operationNameMap
to retrieve the operation. - Run the operation, cache and return the results.
This seems convoluted. Why can we not just use operationVariableNameMap
?
So now the user adds an operation which produces a variable that is already being used. We certainly could come up with a way to pick and choose which variables get computed. But in the short-term we need to just discard the other operation that produced the variables.