Class Computation
- Namespace
- NMF.Transformations.Core
- Assembly
- NMF.Transformations.Core.dll
This class represents a single computation within the transformation engine of NMF.Transformations
public abstract class Computation : IPersistor, ITraceEntry
- Inheritance
-
Computation
- Implements
- Derived
- Inherited Members
- Extension Methods
Remarks
This class is visible to public as it provides reaction to delayness
Constructors
Computation(GeneralTransformationRule, IComputationContext)
Creates a new computation for the given transformation rule with the given input arguments
protected Computation(GeneralTransformationRule transformationRule, IComputationContext context)
Parameters
transformationRule
GeneralTransformationRuleThe transformation rule responsible for the transformation of the input data
context
IComputationContextThe transformation context, in which the computation is done
Properties
Context
Gets the computation context for this computation
public IComputationContext Context { get; }
Property Value
InputArguments
Gets the number of input arguments
public int InputArguments { get; }
Property Value
IsDelayed
Gets a value indicating whether the output creation for this computation is delayed
public bool IsDelayed { get; }
Property Value
Output
Gets the output of this computation
public object Output { get; }
Property Value
Exceptions
- InvalidOperationException
This property may throw a DelayedOutputCreationException in case that the output has been tried to access, although the output creation was delayed
OutputCore
Gets or sets the output in a derived class
protected abstract object OutputCore { get; set; }
Property Value
TransformationContext
Gets the context, in which the computation has been made
public ITransformationContext TransformationContext { get; }
Property Value
TransformationRule
Gets the transformation rule, which has been used to compute this computation
public GeneralTransformationRule TransformationRule { get; }
Property Value
Methods
CreateInputArray()
Copies the input of this computation into an array
public object[] CreateInputArray()
Returns
- object[]
An array with the inputs
CreateOutput(IEnumerable)
Creates the output of this transformation rule
public abstract object CreateOutput(IEnumerable context)
Parameters
context
IEnumerable
Returns
- object
The output for this transformation under this input
Remarks
At this point, not all of the computations have created their output and thus, the trace is not complete. Use the OutputDelayLevel-feature to have the trace contain all elements created in earlier levels
DelayOutputAtLeast(byte)
Configures the computation to create its output at minimum with the given delay level
public void DelayOutputAtLeast(byte delayLevel)
Parameters
delayLevel
byteThe minimum delay level for this computation
DelayTransformationAtLeast(byte)
Configures the computation to be transformed at least with the given delay level
public void DelayTransformationAtLeast(byte delayLevel)
Parameters
delayLevel
byte
GetInput(int)
Gets the input argument for this computation with the given index
public abstract object GetInput(int index)
Parameters
index
intThe index of the input parameter
Returns
- object
The input parameter at the ith position
InitializeOutput(object)
Initializes the output for the actual computation
public void InitializeOutput(object output)
Parameters
output
objectThe intended output
MarkRequire(Computation, bool, ITransformationRuleDependency)
Marks that this computations requires another to be transformed.
public virtual void MarkRequire(Computation other, bool isRequired, ITransformationRuleDependency dependency)
Parameters
other
ComputationThe other computation
isRequired
boolA value indicating whether the other computation must be execute before or after the current computation
dependency
ITransformationRuleDependencyThe dependency that required this
Remarks
The default implementation does nothing, so feel free to override. This method is intended to be called by NMF.Transformations, only.
OnComputed(EventArgs)
Fires the Computed-event
protected virtual void OnComputed(EventArgs e)
Parameters
e
EventArgsThe event arguments
OnOutputInitialized(EventArgs)
Fires the OutputInitialized-event
protected virtual void OnOutputInitialized(EventArgs e)
Parameters
e
EventArgsThe event arguments
SetBaseComputation(Computation)
Sets the provided computation as the base computation
public virtual void SetBaseComputation(Computation baseComputation)
Parameters
baseComputation
ComputationThe base computation
Remarks
By default, this method is blank.
ThrowDelayedException()
Throws an exception that the output has been accessed although the output of teh computation is delayed
protected static void ThrowDelayedException()
Transform()
Initializes the transformation output
public abstract void Transform()
Remarks
At this point, all the transformation outputs are created (also the delayed ones), thus, the trace is fully reliable
Events
Computed
This event is fired as soon as the computation has been computed, i.e., the computation has been processed in the computation list
public event EventHandler Computed
Event Type
OutputInitialized
This event is fired as soon as the output of this computation is initialized
public event EventHandler OutputInitialized