/*======================================================================== Copyright (C) 2006 by Geir-Tore Lindsve, Torbjørn Meistad and Yngve Raudberget, hereby refered to as "the authors". All rights reserved Permission is hereby granted, without written agreement and without license or royalty fees, to use, reproduce, prepare derivative works, distribute, and display this software and its documentation for NONCOMMERCIAL RESEARCH AND EDUCATIONAL PURPOSES, provided that (1) the above copyright notice and the following two paragraphs appear in all copies of the source code and (2) redistributions, including without limitation binaries, reproduce these notices in the supporting documentation. IN NO EVENT SHALL THE AUTHORS, OR DISTRIBUTORS OF THIS SOFTWARE BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE AUTHORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. ========================================================================*/ using System; using System.Collections.Generic; using System.Text; using System.Collections; namespace CLab.Data { /// /// The Type class represents a CLab type /// CSPTypeEnum represents an enumeration type with a list of valid states (domain) /// Implements the abstract Type class. /// public class TypeEnum : Type { private List enumeratorList; /// /// Initializes a new instance of the class. /// /// Name of the type. /// List of valid states for the type. public TypeEnum(String typeName, List enumeratorsList) : base(typeName) { this.enumeratorList = enumeratorsList; } /// /// Gets the list of valid states for the type. /// public List EnumeratorsList { get { return enumeratorList; } } /// /// Gets a string representation of the valid states for the type in the form {value1, value2, value3, ... , valueN} /// public String GetDomain { get { String domain = "{"; for (int i = 0; i < this.enumeratorList.Count; i++) { domain += this.enumeratorList[i]; if (i < this.enumeratorList.Count - 1) domain += ", "; } domain += "}"; return domain; } } /// /// Returns the names of the type and its valid states. /// /// public override String ToString() { String list = "{"; for (int i = 0; i < this.enumeratorList.Count; i++) { list += this.enumeratorList[i]; if (i < this.enumeratorList.Count - 1) list += ","; } list += "}"; return (String.Format("{0} {1};", TypeName, list)); } } }