[2] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
| 3 | * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
| 4 | *
|
---|
| 5 | * This file is part of HeuristicLab.
|
---|
| 6 | *
|
---|
| 7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
| 8 | * it under the terms of the GNU General Public License as published by
|
---|
| 9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 10 | * (at your option) any later version.
|
---|
| 11 | *
|
---|
| 12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 15 | * GNU General Public License for more details.
|
---|
| 16 | *
|
---|
| 17 | * You should have received a copy of the GNU General Public License
|
---|
| 18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 19 | */
|
---|
| 20 | #endregion
|
---|
| 21 |
|
---|
| 22 | using System;
|
---|
| 23 | using System.Collections.Generic;
|
---|
| 24 | using System.Text;
|
---|
| 25 | using System.Xml;
|
---|
[2474] | 26 | using HeuristicLab.Common;
|
---|
[2] | 27 |
|
---|
| 28 | namespace HeuristicLab.Core {
|
---|
[776] | 29 | /// <summary>
|
---|
| 30 | /// Interface for a hierarchical container of variables (containing variables and subscopes).
|
---|
| 31 | /// </summary>
|
---|
[2] | 32 | public interface IScope : IItem {
|
---|
[776] | 33 | /// <summary>
|
---|
| 34 | /// Gets the name of the current instance.
|
---|
| 35 | /// </summary>
|
---|
[2] | 36 | string Name { get; }
|
---|
| 37 |
|
---|
[776] | 38 | /// <summary>
|
---|
| 39 | /// Gets the varibles of the current scope.
|
---|
| 40 | /// </summary>
|
---|
[2] | 41 | ICollection<IVariable> Variables { get; }
|
---|
[776] | 42 | /// <summary>
|
---|
| 43 | /// Gets all aliases of the current scope.
|
---|
| 44 | /// </summary>
|
---|
[63] | 45 | IEnumerable<KeyValuePair<string, string>> Aliases { get; }
|
---|
[776] | 46 | /// <summary>
|
---|
| 47 | /// Gets all subscopes in the current scope.
|
---|
| 48 | /// </summary>
|
---|
[2] | 49 | IList<IScope> SubScopes { get; }
|
---|
| 50 |
|
---|
[776] | 51 | /// <summary>
|
---|
| 52 | /// Sets the parent scope for the current instance.
|
---|
| 53 | /// </summary>
|
---|
| 54 | /// <param name="scope">The parent scope of the current instance.</param>
|
---|
[2] | 55 | void SetParent(IScope scope);
|
---|
| 56 |
|
---|
[776] | 57 | /// <summary>
|
---|
| 58 | /// Gets a variable with the given <paramref name="name"/>.
|
---|
| 59 | /// </summary>
|
---|
| 60 | /// <param name="name">The name of the variable.</param>
|
---|
| 61 | /// <returns>The variable with the specified name.</returns>
|
---|
[2] | 62 | IVariable GetVariable(string name);
|
---|
[776] | 63 | /// <summary>
|
---|
| 64 | /// Adds the specified variable to the curent instance.
|
---|
| 65 | /// </summary>
|
---|
| 66 | /// <param name="variable">The variable to add.</param>
|
---|
[2] | 67 | void AddVariable(IVariable variable);
|
---|
[776] | 68 | /// <summary>
|
---|
| 69 | /// Deletes a variable with the specified <paramref name="name"/> from the current instance.
|
---|
| 70 | /// </summary>
|
---|
| 71 | /// <param name="name">The name of the variable to delete.</param>
|
---|
[2] | 72 | void RemoveVariable(string name);
|
---|
[776] | 73 |
|
---|
| 74 | /// <inheritdoc cref="GetVariableValue(string, bool)"/>
|
---|
| 75 | /// <typeparam name="T">The type of the value that is searched.</typeparam>
|
---|
[2] | 76 | T GetVariableValue<T>(string name, bool recursiveLookup) where T : class, IItem;
|
---|
[776] | 77 | /// <inheritdoc cref="GetVariableValue(string, bool, bool)"/>
|
---|
| 78 | /// <typeparam name="T">The type of the value that is searched.</typeparam>
|
---|
[2] | 79 | T GetVariableValue<T>(string name, bool recursiveLookup, bool throwOnError) where T : class, IItem;
|
---|
[776] | 80 | /// <inheritdoc cref="GetVariableValue(string, bool, bool)" select="summary"/>
|
---|
| 81 | /// <param name="name">The name of the variable.</param>
|
---|
| 82 | /// <param name="recursiveLookup">Boolean value, whether the parent scopes shall be searched
|
---|
| 83 | /// when the variable is not found in the current instance.</param>
|
---|
| 84 | /// <returns>The value of the variable or <c>null</c> if it was not found.</returns>
|
---|
[2] | 85 | IItem GetVariableValue(string name, bool recursiveLookup);
|
---|
[776] | 86 | /// <summary>
|
---|
| 87 | /// Gets the value of the variable with the given <paramref name="name"/>.
|
---|
| 88 | /// </summary>
|
---|
| 89 | /// <param name="name">The name of the variable.</param>
|
---|
| 90 | /// <param name="recursiveLookup">Boolean value, whether the parent scopes shall be searched
|
---|
| 91 | /// when the variable is not found in the current instance.</param>
|
---|
| 92 | /// <param name="throwOnError">Boolean value, whether an exception shall be thrown when the searched
|
---|
| 93 | /// variable cannot be found, or only <c>null</c> shall be returned.</param>
|
---|
| 94 | /// <returns>The value of the searched variable or <c>null</c> if <paramref name="throwOnError"/>
|
---|
| 95 | /// is set to <c>false</c>.</returns>
|
---|
[2] | 96 | IItem GetVariableValue(string name, bool recursiveLookup, bool throwOnError);
|
---|
| 97 |
|
---|
[776] | 98 | /// <summary>
|
---|
[801] | 99 | /// Gets the actual name of the given alias.
|
---|
[776] | 100 | /// </summary>
|
---|
| 101 | /// <param name="name">The alias whose actual name is searched.</param>
|
---|
| 102 | /// <returns>The actual name.</returns>
|
---|
[61] | 103 | string TranslateName(string name);
|
---|
[776] | 104 | /// <summary>
|
---|
| 105 | /// Adds an alias to the current instance.
|
---|
| 106 | /// </summary>
|
---|
| 107 | /// <param name="alias">The alias to add.</param>
|
---|
| 108 | /// <param name="name">The actual name of the alias.</param>
|
---|
[61] | 109 | void AddAlias(string alias, string name);
|
---|
[776] | 110 | /// <summary>
|
---|
| 111 | /// Deletes the specified <paramref name="alias"/> from the current instance.
|
---|
| 112 | /// </summary>
|
---|
| 113 | /// <param name="alias">The alias to delete.</param>
|
---|
[61] | 114 | void RemoveAlias(string alias);
|
---|
| 115 |
|
---|
[776] | 116 | /// <summary>
|
---|
| 117 | /// Adds the specified sub scope to the current instance.
|
---|
| 118 | /// </summary>
|
---|
| 119 | /// <param name="scope">The sub scope to add.</param>
|
---|
[2] | 120 | void AddSubScope(IScope scope);
|
---|
[776] | 121 | /// <summary>
|
---|
| 122 | /// Deletes the specified sub scope from the current instance.
|
---|
| 123 | /// </summary>
|
---|
| 124 | /// <param name="scope">The sub scope to delete.</param>
|
---|
[2] | 125 | void RemoveSubScope(IScope scope);
|
---|
[776] | 126 | /// <summary>
|
---|
| 127 | /// Reorders all sub scopes according to the specified chronology.
|
---|
| 128 | /// </summary>
|
---|
| 129 | /// <param name="sequence">The chronology how to order the sub scopes.</param>
|
---|
[2] | 130 | void ReorderSubScopes(int[] sequence);
|
---|
[776] | 131 | /// <summary>
|
---|
| 132 | /// Gets the sub scope with the given <paramref name="guid"/>.
|
---|
| 133 | /// </summary>
|
---|
| 134 | /// <param name="guid">The unique identifier of the sub scope.</param>
|
---|
| 135 | /// <returns>The sub scope with the given <paramref name="guid"/>.</returns>
|
---|
[2] | 136 | IScope GetScope(Guid guid);
|
---|
[776] | 137 | /// <summary>
|
---|
| 138 | /// Gets the sub scope with the given <paramref name="name"/>.
|
---|
| 139 | /// </summary>
|
---|
| 140 | /// <param name="name">The name of the sub scope.</param>
|
---|
| 141 | /// <returns>The sub scope with the given <paramref name="name"/>.</returns>
|
---|
[2] | 142 | IScope GetScope(string name);
|
---|
| 143 |
|
---|
[776] | 144 | /// <summary>
|
---|
| 145 | /// Clears the current instance.
|
---|
| 146 | /// </summary>
|
---|
[2] | 147 | void Clear();
|
---|
| 148 |
|
---|
[776] | 149 | /// <summary>
|
---|
| 150 | /// Occurs when a variable has been added to the current instance.
|
---|
| 151 | /// </summary>
|
---|
[2474] | 152 | event EventHandler<EventArgs<IVariable>> VariableAdded;
|
---|
[776] | 153 | /// <summary>
|
---|
| 154 | /// Occurs when a variable has been deleted from the current instance.
|
---|
| 155 | /// </summary>
|
---|
[2474] | 156 | event EventHandler<EventArgs<IVariable>> VariableRemoved;
|
---|
[776] | 157 | /// <summary>
|
---|
| 158 | /// Occurs when an alias has been added to the current instance.
|
---|
| 159 | /// </summary>
|
---|
[2474] | 160 | event EventHandler<EventArgs<string>> AliasAdded;
|
---|
[776] | 161 | /// <summary>
|
---|
| 162 | /// Occurs when an alias has been removed from the current instance.
|
---|
| 163 | /// </summary>
|
---|
[2474] | 164 | event EventHandler<EventArgs<string>> AliasRemoved;
|
---|
[776] | 165 | /// <summary>
|
---|
| 166 | /// Occurs when a sub scope has been added to the current instance.
|
---|
| 167 | /// </summary>
|
---|
[2474] | 168 | event EventHandler<EventArgs<IScope, int>> SubScopeAdded;
|
---|
[776] | 169 | /// <summary>
|
---|
| 170 | /// Occurs when a sub scope has been deleted from the current instance.
|
---|
| 171 | /// </summary>
|
---|
[2474] | 172 | event EventHandler<EventArgs<IScope, int>> SubScopeRemoved;
|
---|
[776] | 173 | /// <summary>
|
---|
| 174 | /// Occurs when the sub scopes have been reordered.
|
---|
| 175 | /// </summary>
|
---|
[2] | 176 | event EventHandler SubScopesReordered;
|
---|
| 177 | }
|
---|
| 178 | }
|
---|