Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/19/08 12:12:39 (15 years ago)
Author:
vdorfer
Message:

Created API documentation for HeuristicLab.Core namespace (#331)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Core/EngineBase.cs

    r47 r776  
    2727
    2828namespace HeuristicLab.Core {
     29  /// <summary>
     30  /// Base class to represent an engine, which is an interpreter, holding the code, the data and
     31  /// the actual state, which is the runtime stack and a pointer onto the next operation. It represents
     32  /// one execution and can handle parallel executions.
     33  /// </summary>
    2934  public abstract class EngineBase : ItemBase, IEngine {
     35    /// <summary>
     36    /// Field of the current instance that represent the operator graph.
     37    /// </summary>
    3038    protected IOperatorGraph myOperatorGraph;
     39    /// <summary>
     40    /// Gets the current operator graph.
     41    /// </summary>
    3142    public IOperatorGraph OperatorGraph {
    3243      get { return myOperatorGraph; }
    3344    }
     45    /// <summary>
     46    /// Field of the current instance that represent the global scope.
     47    /// </summary>
    3448    protected IScope myGlobalScope;
     49    /// <summary>
     50    /// Gets the current global scope.
     51    /// </summary>
    3552    public IScope GlobalScope {
    3653      get { return myGlobalScope; }
     
    3855
    3956    private TimeSpan myExecutionTime;
     57    /// <summary>
     58    /// Gets or sets the execution time.
     59    /// </summary>
     60    /// <remarks>Calls <see cref="OnExecutionTimeChanged"/> in the setter.</remarks>
    4061    public TimeSpan ExecutionTime {
    4162      get { return myExecutionTime; }
     
    4667    }
    4768
     69    /// <summary>
     70    /// Field of the current instance that represent the execution stack.
     71    /// </summary>
    4872    protected Stack<IOperation> myExecutionStack;
     73    /// <summary>
     74    /// Gets the current execution stack.
     75    /// </summary>
    4976    public Stack<IOperation> ExecutionStack {
    5077      get { return myExecutionStack; }
    5178    }
     79   
     80    /// <summary>
     81    /// Flag of the current instance whether it is currently running.
     82    /// </summary>
    5283    protected bool myRunning;
     84    /// <summary>
     85    /// Gets information whether the instance is currently running.
     86    /// </summary>
    5387    public bool Running {
    5488      get { return myRunning; }
    5589    }
     90
     91    /// <summary>
     92    /// Flag of the current instance whether it is canceled.
     93    /// </summary>
    5694    protected bool myCanceled;
     95    /// <summary>
     96    /// Gets information whether the instance is currently canceled.
     97    /// </summary>
    5798    public bool Canceled {
    5899      get { return myCanceled; }
    59100    }
     101    /// <summary>
     102    /// Gets information whether the instance has already terminated.
     103    /// </summary>
    60104    public virtual bool Terminated {
    61105      get { return ExecutionStack.Count == 0; }
    62106    }
    63107
     108    /// <summary>
     109    /// Initializes a new instance of <see cref="EngineBase"/> with a new global scope.
     110    /// </summary>
     111    /// <remarks>Calls <see cref="Reset"/>.</remarks>
    64112    protected EngineBase() {
    65113      myOperatorGraph = new OperatorGraph();
     
    69117    }
    70118
     119    /// <summary>
     120    /// Clones the current instance (deep clone).
     121    /// </summary>
     122    /// <remarks>Deep clone through <see cref="Auxiliary.Clone"/> method of helper class
     123    /// <see cref="Auxiliary"/>.</remarks>
     124    /// <param name="clonedObjects">Dictionary of all already clone objects. (Needed to avoid cycles.)</param>
     125    /// <returns>The cloned object as <see cref="EngineBase"/>.</returns>
    71126    public override object Clone(IDictionary<Guid, object> clonedObjects) {
    72127      EngineBase clone = (EngineBase)base.Clone(clonedObjects);
     
    84139    }
    85140
     141    /// <inheritdoc/>
     142    /// <remarks>Calls <see cref="ThreadPool.QueueUserWorkItem(System.Threading.WaitCallback, object)"/>
     143    /// of class <see cref="ThreadPool"/>.</remarks>
    86144    public virtual void Execute() {
    87145      myRunning = true;
     
    89147      ThreadPool.QueueUserWorkItem(new WaitCallback(Run), null);
    90148    }
     149    /// <inheritdoc/>
     150    /// <remarks>Calls <see cref="ThreadPool.QueueUserWorkItem(System.Threading.WaitCallback, object)"/>
     151    /// of class <see cref="ThreadPool"/>.</remarks>
    91152    public virtual void ExecuteSteps(int steps) {
    92153      myRunning = true;
     
    94155      ThreadPool.QueueUserWorkItem(new WaitCallback(Run), steps);
    95156    }
     157    /// <inheritdoc/>
     158    /// <remarks>Calls <see cref="ThreadPool.QueueUserWorkItem(System.Threading.WaitCallback, object)"/>
     159    /// of class <see cref="ThreadPool"/>.</remarks>
    96160    public void ExecuteStep() {
    97161      ExecuteSteps(1);
    98162    }
     163    /// <inheritdoc/>
     164    /// <remarks>Sets the protected flag <c>myCanceled</c> to <c>true</c>.</remarks>
    99165    public virtual void Abort() {
    100166      myCanceled = true;
    101167    }
     168    /// <inheritdoc/>
     169    /// <remarks>Sets <c>myCanceled</c> and <c>myRunning</c> to <c>false</c>. The global scope is cleared,
     170    /// the execution time is reseted, the execution stack is cleared and a new <see cref="AtomicOperation"/>
     171    /// with the initial operator is added. <br/>
     172    /// Calls <see cref="OnInitialized"/>.</remarks>
    102173    public virtual void Reset() {
    103174      myCanceled = false;
     
    142213    }
    143214
     215    /// <summary>
     216    /// Performs the next operation.
     217    /// </summary>
    144218    protected abstract void ProcessNextOperation();
    145219
     220    /// <summary>
     221    /// Occurs when the current instance is initialized.
     222    /// </summary>
    146223    public event EventHandler Initialized;
     224    /// <summary>
     225    /// Fires a new <c>Initialized</c> event.
     226    /// </summary>
    147227    protected virtual void OnInitialized() {
    148228      if (Initialized != null)
    149229        Initialized(this, new EventArgs());
    150230    }
     231    /// <summary>
     232    /// Occurs when an operation is executed.
     233    /// </summary>
    151234    public event EventHandler<OperationEventArgs> OperationExecuted;
     235    /// <summary>
     236    /// Fires a new <c>OperationExecuted</c> event.
     237    /// </summary>
     238    /// <param name="operation">The operation that has been executed.</param>
    152239    protected virtual void OnOperationExecuted(IOperation operation) {
    153240      if (OperationExecuted != null)
    154241        OperationExecuted(this, new OperationEventArgs(operation));
    155242    }
     243    /// <summary>
     244    /// Occurs when an exception occured during the execution.
     245    /// </summary>
    156246    public event EventHandler<ExceptionEventArgs> ExceptionOccurred;
     247    /// <summary>
     248    /// Aborts the execution and fires a new <c>ExceptionOccurred</c> event.
     249    /// </summary>
     250    /// <param name="exception">The exception that was thrown.</param>
    157251    protected virtual void OnExceptionOccurred(Exception exception) {
    158252      Abort();
     
    160254        ExceptionOccurred(this, new ExceptionEventArgs(exception));
    161255    }
     256    /// <summary>
     257    /// Occurs when the execution time changed.
     258    /// </summary>
    162259    public event EventHandler ExecutionTimeChanged;
     260    /// <summary>
     261    /// Fires a new <c>ExecutionTimeChanged</c> event.
     262    /// </summary>
    163263    protected virtual void OnExecutionTimeChanged() {
    164264      if (ExecutionTimeChanged != null)
    165265        ExecutionTimeChanged(this, new EventArgs());
    166266    }
     267    /// <summary>
     268    /// Occurs when the execution is finished.
     269    /// </summary>
    167270    public event EventHandler Finished;
     271    /// <summary>
     272    /// Fires a new <c>Finished</c> event.
     273    /// </summary>
    168274    protected virtual void OnFinished() {
    169275      if (Finished != null)
     
    172278
    173279    #region Persistence Methods
     280    /// <summary>
     281    /// Saves the current instance as <see cref="XmlNode"/> in the specified <paramref name="document"/>.
     282    /// </summary>
     283    /// <remarks>Calls <see cref="StorableBase.GetXmlNode"/> of base class <see cref="ItemBase"/>.<br/>
     284    /// A quick overview how the single elements of the current instance are saved:
     285    /// <list type="bullet">
     286    /// <item>
     287    /// <term>Operator graph: </term>
     288    /// <description>Saved as a child node with the tag name <c>OperatorGraph</c>.</description>
     289    /// </item>
     290    /// <item>
     291    /// <term>Global scope: </term>
     292    /// <description>Saved as a child node with the tag name <c>GlobalScope</c>.</description>
     293    /// </item>
     294    /// <item>
     295    /// <term>Execution stack: </term>
     296    /// <description>A child node is created with the tag name <c>ExecutionStack</c>. Beyond this child node
     297    /// all operations of the execution stack are saved as child nodes.</description>
     298    /// </item>
     299    /// <item>
     300    /// <term>Execution time: </term>
     301    /// <description>Saved as a child node with the tag name <c>ExecutionTime</c>, where the execution
     302    /// time is saved as string in the node's inner text.</description>
     303    /// </item>
     304    /// </list></remarks>
     305    /// <param name="name">The (tag)name of the <see cref="XmlNode"/>.</param>
     306    /// <param name="document">The <see cref="XmlDocument"/> where to save the data.</param>
     307    /// <param name="persistedObjects">The dictionary of all already persisted objects. (Needed to avoid cycles.)</param>
     308    /// <returns>The saved <see cref="XmlNode"/>.</returns>
    174309    public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid,IStorable> persistedObjects) {
    175310      XmlNode node = base.GetXmlNode(name, document, persistedObjects);
     
    190325      return node;
    191326    }
     327    /// <summary>
     328    ///  Loads the persisted instance from the specified <paramref name="node"/>.
     329    /// </summary>
     330    /// <remarks>See <see cref="GetXmlNode"/> to get information on how the instance must be saved. <br/>
     331    /// Calls <see cref="StorableBase.Populate"/> of base class <see cref="ItemBase"/>.</remarks>
     332    /// <param name="node">The <see cref="XmlNode"/> where the engine is saved.</param>
     333    /// <param name="restoredObjects">The dictionary of all already restored objects.
     334    /// (Needed to avoid cycles.)</param>
    192335    public override void Populate(XmlNode node, IDictionary<Guid,IStorable> restoredObjects) {
    193336      base.Populate(node, restoredObjects);
Note: See TracChangeset for help on using the changeset viewer.