[2] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[11171] | 3 | * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[2] | 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 |
|
---|
| 23 | namespace HeuristicLab.PluginInfrastructure {
|
---|
[1189] | 24 | /// <summary>
|
---|
[2504] | 25 | /// Abstract base implementation for the IApplication interface.
|
---|
[1189] | 26 | /// </summary>
|
---|
[2488] | 27 | public abstract class ApplicationBase : IApplication {
|
---|
[1189] | 28 | /// <summary>
|
---|
| 29 | /// Initializes a new instance of <see cref="ApplicationBase"/>.
|
---|
| 30 | /// </summary>
|
---|
[2504] | 31 | protected ApplicationBase() { }
|
---|
[2] | 32 |
|
---|
[2488] | 33 | private ApplicationAttribute ApplicationAttribute {
|
---|
[2475] | 34 | get {
|
---|
[2488] | 35 | object[] appAttributes = this.GetType().GetCustomAttributes(typeof(ApplicationAttribute), false);
|
---|
[2] | 36 |
|
---|
[2475] | 37 | // exactly one attribute of the type ClassInfoAttribute must be given
|
---|
[2504] | 38 | if (appAttributes.Length == 0) {
|
---|
| 39 | throw new InvalidPluginException("ApplicationAttribute on type " + this.GetType() + " is missing.");
|
---|
| 40 | } else if (appAttributes.Length > 1) {
|
---|
[2488] | 41 | throw new InvalidPluginException("Found multiple ApplicationAttributes on type " + this.GetType());
|
---|
[242] | 42 | }
|
---|
[2] | 43 |
|
---|
[2488] | 44 | return (ApplicationAttribute)appAttributes[0];
|
---|
[2] | 45 | }
|
---|
| 46 | }
|
---|
| 47 |
|
---|
| 48 | #region IApplication Members
|
---|
| 49 |
|
---|
[1189] | 50 | /// <summary>
|
---|
| 51 | /// Gets the name of the application.
|
---|
| 52 | /// </summary>
|
---|
[2] | 53 | public string Name {
|
---|
[2488] | 54 | get { return ApplicationAttribute.Name; }
|
---|
[2] | 55 | }
|
---|
| 56 |
|
---|
[1189] | 57 | /// <summary>
|
---|
| 58 | /// Gets the description of the application.
|
---|
| 59 | /// </summary>
|
---|
[2] | 60 | public string Description {
|
---|
[2475] | 61 | get {
|
---|
[2504] | 62 | return ApplicationAttribute.Description;
|
---|
[2475] | 63 | }
|
---|
[2] | 64 | }
|
---|
| 65 |
|
---|
[1189] | 66 | /// <summary>
|
---|
| 67 | /// Runs the application.
|
---|
| 68 | /// </summary>
|
---|
[8818] | 69 | public abstract void Run(ICommandLineArgument[] args);
|
---|
[242] | 70 |
|
---|
[2] | 71 | #endregion
|
---|
| 72 | }
|
---|
| 73 | }
|
---|