Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Core/3.3/Interfaces/IScope.cs @ 2546

Last change on this file since 2546 was 2526, checked in by swagner, 15 years ago

Refactored cloning (#806)

File size: 7.1 KB
Line 
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
22using System;
23using System.Collections.Generic;
24using System.Text;
25using System.Xml;
26using HeuristicLab.Common;
27
28namespace HeuristicLab.Core {
29  /// <summary>
30  /// Interface for a hierarchical container of variables (containing variables and subscopes).
31  /// </summary>
32  public interface IScope : IItem {
33    /// <summary>
34    /// Gets the name of the current instance.
35    /// </summary>
36    string Name { get; }
37
38    /// <summary>
39    /// Gets the varibles of the current scope.
40    /// </summary>
41    ICollection<IVariable> Variables { get; }
42    /// <summary>
43    /// Gets all aliases of the current scope.
44    /// </summary>
45    IEnumerable<KeyValuePair<string, string>> Aliases { get; }
46    /// <summary>
47    /// Gets all subscopes in the current scope.
48    /// </summary>
49    IList<IScope> SubScopes { get; }
50
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>
55    void SetParent(IScope scope);
56
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>
62    IVariable GetVariable(string name);
63    /// <summary>
64    /// Adds the specified variable to the curent instance.
65    /// </summary>
66    /// <param name="variable">The variable to add.</param>
67    void AddVariable(IVariable variable);
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>
72    void RemoveVariable(string name);
73   
74    /// <inheritdoc cref="GetVariableValue(string, bool)"/>
75    /// <typeparam name="T">The type of the value that is searched.</typeparam>
76    T GetVariableValue<T>(string name, bool recursiveLookup) where T : class, IItem;
77    /// <inheritdoc cref="GetVariableValue(string, bool, bool)"/>
78    /// <typeparam name="T">The type of the value that is searched.</typeparam>
79    T GetVariableValue<T>(string name, bool recursiveLookup, bool throwOnError) where T : class, IItem;
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>
85    IItem GetVariableValue(string name, bool recursiveLookup);
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>
96    IItem GetVariableValue(string name, bool recursiveLookup, bool throwOnError);
97
98    /// <summary>
99    /// Gets the actual name of the given alias.
100    /// </summary>
101    /// <param name="name">The alias whose actual name is searched.</param>
102    /// <returns>The actual name.</returns>
103    string TranslateName(string name);
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>
109    void AddAlias(string alias, string name);
110    /// <summary>
111    /// Deletes the specified <paramref name="alias"/> from the current instance.
112    /// </summary>
113    /// <param name="alias">The alias to delete.</param>
114    void RemoveAlias(string alias);
115
116    /// <summary>
117    /// Adds the specified sub scope to the current instance.
118    /// </summary>
119    /// <param name="scope">The sub scope to add.</param>
120    void AddSubScope(IScope scope);
121    /// <summary>
122    /// Deletes the specified sub scope from the current instance.
123    /// </summary>
124    /// <param name="scope">The sub scope to delete.</param>
125    void RemoveSubScope(IScope scope);
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>
130    void ReorderSubScopes(int[] sequence);
131    /// <summary>
132    /// Gets the sub scope with the given <paramref name="name"/>.
133    /// </summary>
134    /// <param name="name">The name of the sub scope.</param>
135    /// <returns>The sub scope with the given <paramref name="name"/>.</returns>
136    IScope GetScope(string name);
137
138    /// <summary>
139    /// Clears the current instance.
140    /// </summary>
141    void Clear();
142
143    /// <summary>
144    /// Occurs when a variable has been added to the current instance.
145    /// </summary>
146    event EventHandler<EventArgs<IVariable>> VariableAdded;
147    /// <summary>
148    /// Occurs when a variable has been deleted from the current instance.
149    /// </summary>
150    event EventHandler<EventArgs<IVariable>> VariableRemoved;
151    /// <summary>
152    /// Occurs when an alias has been added to the current instance.
153    /// </summary>
154    event EventHandler<EventArgs<string>> AliasAdded;
155    /// <summary>
156    /// Occurs when an alias has been removed from the current instance.
157    /// </summary>
158    event EventHandler<EventArgs<string>> AliasRemoved;
159    /// <summary>
160    /// Occurs when a sub scope has been added to the current instance.
161    /// </summary>
162    event EventHandler<EventArgs<IScope, int>> SubScopeAdded;
163    /// <summary>
164    /// Occurs when a sub scope has been deleted from the current instance.
165    /// </summary>
166    event EventHandler<EventArgs<IScope, int>> SubScopeRemoved;
167    /// <summary>
168    /// Occurs when the sub scopes have been reordered.
169    /// </summary>
170    event EventHandler SubScopesReordered;
171  }
172}
Note: See TracBrowser for help on using the repository browser.