// // JobDescription.cs // // Author: // Carsten Sonne Larsen // // Copyright (c) 2013 Carsten Sonne Larsen // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. using System; using Ntp.Analyzer.Log; namespace Ntp.Process { /// /// Base class for jobs following the GoF Command Pattern. /// public abstract class JobDescription { /// /// Initializes a new instance of the class. /// /// Configuration for the job. /// Log to use when registrering events. protected JobDescription (JobConfiguration config, LogBase log) { this.config = config; this.log = log; } private readonly JobConfiguration config; private readonly LogBase log; /// /// Gets the name. /// /// The name. public string Name { get { return config.ConfigName; } } /// /// Gets a value indicating whether this should run as a single thread. /// /// true if single thread; otherwise, false. public abstract bool SingleThread { get; } /// /// Gets the type of the job as text. /// /// The type of the job. public abstract string JobType { get; } /// /// Gets the priority to use when scheduling jobs. /// /// The priority. public abstract int Priority { get; } /// /// Gets the configuration for the job. /// /// The configuration. public JobConfiguration Configuration { get { return config; } } /// /// Gets the log to use when registrering events. /// /// The log. protected LogBase Log { get { return log; } } /// /// Perform execution of this instance. /// internal void Execute () { InternalExecute (); } /// /// Implementing method for descendents. /// protected abstract void InternalExecute (); /// /// Returns a that represents the current . /// /// A that represents the current . public override string ToString () { return Name; } } }