Acoustic Research Tool (ART) v0.10
The function objects (functionoids or functors) derived from this base class are the same as formulas in ARTdataContainers: instructions for calculation.
They provide functions for calculation to ARTdataContainers. When creating an ARTdataContainer, the constructor gets a pointer to one of these functionoids. The dataContainer writes its address to the functionoid's field out_.
Pointers to dataContainers needed for calculation are passed to the constructor of the functionoid. This can be regarded as a deep-frozen function call, because only when the data container to which the functionoid belongs is evaluated, the core function of the functionoid (ApplyFunction) is called. This function uses the dataContainers passed as arguments in the constructor to calculate the value of the output (ie. the data- Container specified by out_)
To calculate a value represented by a dataContainer, only the dataContainer's GetValue function (or similar functions) have to be called. First all dependencies are calcualted by calls to functionoids' ApplyFunction or by evaluation of parser strings. Then the queried value itself is calculated.
The dataContainers are a network of dependencies. If one dataContainer is invalidated, all dataContainers depending on it are invalidated as well. A dataContainer stores its value until it has to be recalculated.
|virtual void||ApplyFunction ()=0|
|Every functionoid must provide a function to calculate the value of its output data container. |
|virtual void||SetDependencies ()|
|Every functionoid must register with data containers, on which its output value depends. override only if special dependencies have to be established. |
|virtual bool||IsSameFunctionoid (ARTfunctionoid *f)=0|
|Given a pointer of type ARTfunctionoid (or subtypes), the functionoid needs to decide if the pointer represents the same function. |
|virtual int||GetIterationNumber ()=0|
|This function should determine the number of iterations as exactly as possible according to the current state of all dependencies so that the evaluation cost of this data container can be estimated. (The user should take care to keep data containers like frequency grids or other determining the number of iterations valid before estimating the evaluation cost!) This number should be exactly the same as the number of times the function ARTdataContainer::progressIndicator.Continue is called in the functionoid's applyFunction. |
|void||SetOutput (ARTdataContainer *out)|
|The dataContainer, to which this functionoid is passed as an argument in the constructor, automatically sets the pointer out_ on itself. |
|vector< ARTdataContainer * >||in_|
|set by SetOutput() in constructor of data container |
Every functionoid must provide a function to calculate the value of its output data container.
The calculation takes place in this very function. Note that you have to call ARTdataContainer::progressIndicator.Continue() frequently to communicate the status of calculation to the user and to check if the user wishes to abort. If you are using a loop in your function, call the function in every iteration. Note that the number of times this function is called here must be exactly the same number returned by GetIterationNumber for evaluation cost estimation to work correctly. Your loop could look somewhat like this: