Free cookie consent management tool by TermsFeed Policy Generator

source: stable/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Grammars/EmptySymbolicExpressionTreeGrammar.cs @ 11874

Last change on this file since 11874 was 11874, checked in by mkommend, 8 years ago

#2268: Merged r11494, r11495, r11496, r11497, r11498, r11504, r11532, r11536 into stable.

File size: 5.1 KB
Line 
1#region License Information
2
3/* HeuristicLab
4 * Copyright (C) 2002-2014 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    IEnumerable<ISymbol> ISymbolicExpressionGrammarBase.GetAllowedChildSymbols(ISymbol parent) {
73      return grammar.GetAllowedChildSymbols(parent);
74    }
75
76    IEnumerable<ISymbol> ISymbolicExpressionGrammarBase.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    int ISymbolicExpressionGrammarBase.GetMinimumExpressionDepth(ISymbol symbol) {
88      return grammar.GetMinimumExpressionDepth(symbol);
89    }
90    int ISymbolicExpressionGrammarBase.GetMaximumExpressionDepth(ISymbol symbol) {
91      return grammar.GetMaximumExpressionDepth(symbol);
92    }
93    int ISymbolicExpressionGrammarBase.GetMinimumExpressionLength(ISymbol symbol) {
94      return grammar.GetMinimumExpressionLength(symbol);
95    }
96    int ISymbolicExpressionGrammarBase.GetMaximumExpressionLength(ISymbol symbol, int maxDepth) {
97      return grammar.GetMaximumExpressionLength(symbol, maxDepth);
98    }
99
100
101    #region ISymbolicExpressionTreeGrammar Members
102    IEnumerable<ISymbol> ISymbolicExpressionTreeGrammar.ModifyableSymbols {
103      get { return Enumerable.Empty<ISymbol>(); }
104    }
105
106    bool ISymbolicExpressionTreeGrammar.IsModifyableSymbol(ISymbol symbol) {
107      return false;
108    }
109
110    void ISymbolicExpressionTreeGrammar.AddSymbol(ISymbol symbol) {
111      throw new NotSupportedException();
112    }
113
114    void ISymbolicExpressionTreeGrammar.RemoveSymbol(ISymbol symbol) {
115      throw new NotSupportedException();
116    }
117
118    void ISymbolicExpressionTreeGrammar.AddAllowedChildSymbol(ISymbol parent, ISymbol child) {
119      throw new NotSupportedException();
120    }
121
122    void ISymbolicExpressionTreeGrammar.AddAllowedChildSymbol(ISymbol parent, ISymbol child, int argumentIndex) {
123      throw new NotSupportedException();
124    }
125
126    void ISymbolicExpressionTreeGrammar.RemoveAllowedChildSymbol(ISymbol parent, ISymbol child) {
127      throw new NotSupportedException();
128    }
129
130    void ISymbolicExpressionTreeGrammar.RemoveAllowedChildSymbol(ISymbol parent, ISymbol child, int argumentIndex) {
131      throw new NotSupportedException();
132    }
133
134    void ISymbolicExpressionTreeGrammar.SetSubtreeCount(ISymbol symbol, int minimumSubtreeCount, int maximumSubtreeCount) {
135      throw new NotSupportedException();
136    }
137   
138    #pragma warning disable 0169 //disable usage warning
139    public event EventHandler Changed;
140    #pragma warning restore 0169
141    #endregion
142  }
143}
Note: See TracBrowser for help on using the repository browser.