Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2839_HiveProjectManagement/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Grammars/EmptySymbolicExpressionTreeGrammar.cs @ 16057

Last change on this file since 16057 was 16057, checked in by jkarder, 6 years ago

#2839:

File size: 4.6 KB
Line 
1#region License Information
2
3/* HeuristicLab
4 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
5 *
6 * This file is part of HeuristicLab.
7 *
8 * HeuristicLab is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * HeuristicLab is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#endregion
23
24using System;
25using System.Collections.Generic;
26using System.Linq;
27using HeuristicLab.Common;
28using HeuristicLab.Core;
29using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
30
31namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
32
33  [StorableClass]
34  internal sealed class EmptySymbolicExpressionTreeGrammar : NamedItem, ISymbolicExpressionTreeGrammar {
35    [Storable]
36    private ISymbolicExpressionGrammar grammar;
37
38    [StorableConstructor]
39    private EmptySymbolicExpressionTreeGrammar(bool deserializing) : base(deserializing) { }
40    internal EmptySymbolicExpressionTreeGrammar(ISymbolicExpressionGrammar grammar)
41      : base() {
42      if (grammar == null) throw new ArgumentNullException();
43      this.grammar = grammar;
44    }
45
46    public override IDeepCloneable Clone(Cloner cloner) {
47      return this;
48    }
49
50    public IEnumerable<ISymbol> Symbols {
51      get { return grammar.Symbols; }
52    }
53    public IEnumerable<ISymbol> AllowedSymbols {
54      get { return grammar.AllowedSymbols; }
55    }
56
57    public ISymbol GetSymbol(string symbolName) {
58      return grammar.GetSymbol(symbolName);
59    }
60
61    public bool ContainsSymbol(ISymbol symbol) {
62      return grammar.ContainsSymbol(symbol);
63    }
64
65    public bool IsAllowedChildSymbol(ISymbol parent, ISymbol child) {
66      return grammar.IsAllowedChildSymbol(parent, child);
67    }
68    public bool IsAllowedChildSymbol(ISymbol parent, ISymbol child, int argumentIndex) {
69      return grammar.IsAllowedChildSymbol(parent, child, argumentIndex);
70    }
71
72    public IEnumerable<ISymbol> GetAllowedChildSymbols(ISymbol parent) {
73      return grammar.GetAllowedChildSymbols(parent);
74    }
75
76    public IEnumerable<ISymbol> GetAllowedChildSymbols(ISymbol parent, int argumentIndex) {
77      return grammar.GetAllowedChildSymbols(parent, argumentIndex);
78    }
79
80    public int GetMinimumSubtreeCount(ISymbol symbol) {
81      return grammar.GetMinimumSubtreeCount(symbol);
82    }
83    public int GetMaximumSubtreeCount(ISymbol symbol) {
84      return grammar.GetMaximumSubtreeCount(symbol);
85    }
86
87    public int GetMinimumExpressionDepth(ISymbol symbol) {
88      return grammar.GetMinimumExpressionDepth(symbol);
89    }
90    public int GetMaximumExpressionDepth(ISymbol symbol) {
91      return grammar.GetMaximumExpressionDepth(symbol);
92    }
93    public int GetMinimumExpressionLength(ISymbol symbol) {
94      return grammar.GetMinimumExpressionLength(symbol);
95    }
96    public int GetMaximumExpressionLength(ISymbol symbol, int maxDepth) {
97      return grammar.GetMaximumExpressionLength(symbol, maxDepth);
98    }
99
100    public void AddSymbol(ISymbol symbol) { throw new NotSupportedException(); }
101    public void RemoveSymbol(ISymbol symbol) { throw new NotSupportedException(); }
102    public void AddAllowedChildSymbol(ISymbol parent, ISymbol child) { throw new NotSupportedException(); }
103    public void AddAllowedChildSymbol(ISymbol parent, ISymbol child, int argumentIndex) { throw new NotSupportedException(); }
104    public void RemoveAllowedChildSymbol(ISymbol parent, ISymbol child) { throw new NotSupportedException(); }
105    public void RemoveAllowedChildSymbol(ISymbol parent, ISymbol child, int argumentIndex) { throw new NotSupportedException(); }
106    public void SetSubtreeCount(ISymbol symbol, int minimumSubtreeCount, int maximumSubtreeCount) { throw new NotSupportedException(); }
107
108
109    #region ISymbolicExpressionTreeGrammar Members
110    public IEnumerable<ISymbol> ModifyableSymbols {
111      get { return Enumerable.Empty<ISymbol>(); }
112    }
113
114    public bool IsModifyableSymbol(ISymbol symbol) {
115      return false;
116    }
117
118#pragma warning disable 0067 //disable usage warning
119    public event EventHandler Changed;
120#pragma warning restore 0067
121    #endregion
122  }
123}
Note: See TracBrowser for help on using the repository browser.