Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GPDL/HeuristicLab.Grammars/3.3/Attribute.cs @ 15287

Last change on this file since 15287 was 10067, checked in by gkronber, 11 years ago

#2026 worked on brute force solver for GPDL problems.

File size: 2.2 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2013 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;
23
24namespace HeuristicLab.Grammars {
25  public sealed class AttributeType {
26    public static readonly AttributeType In = new AttributeType("");
27    public static readonly AttributeType Out = new AttributeType("out");
28    public static readonly AttributeType Ref = new AttributeType("ref");
29    private string attributeType;
30    private AttributeType(string attributeType) {
31      this.attributeType = attributeType;
32    }
33
34    public static AttributeType Parse(string attributeType) {
35      if (string.IsNullOrEmpty(attributeType)) return In;
36      else if (attributeType == "ref") return Ref;
37      else if (attributeType == "out") return Out;
38      else throw new ArgumentException("Unknown attribute type string.", attributeType);
39    }
40
41    public override string ToString() {
42      return attributeType;
43    }
44  };
45
46  public class Attribute : IAttribute {
47    public AttributeType AttributeType { get; private set; }
48    public string Type { get; private set; }
49    public string Name { get; private set; }
50
51    public Attribute(string name, string type)
52      : this(name, type, AttributeType.In) {
53    }
54
55    public Attribute(string name, string type, AttributeType attributeType) {
56      this.Name = name;
57      this.Type = type;
58      this.AttributeType = attributeType;
59    }
60
61    public override string ToString() {
62      return AttributeType + " " + Type + " " + Name;
63    }
64  }
65}
Note: See TracBrowser for help on using the repository browser.