/*======================================================================== 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; using System.Collections.Generic; using System.IO; using System.Text; using CLab.Exceptions; using CLab.Parsers; namespace CLab.Data { /// /// The CP object contains the internal data representation, parsed from the input XML file /// public class CP { private List types = new List(); private List variables = new List(); private List rules = new List(); private String description = ""; private String author = ""; private String date = ""; private ClabXmlParser parser; /// /// Initializes a new instance of the class. /// /// The XML filename. /// public CP(String xmlFilename) { parser = new ClabXmlParser(this); try { parser.Parse(xmlFilename); } catch (ClabXMLParserException e) { throw new ClabException(e.Message, e); } } /// /// Initializes a new instance of the class. /// /// The stream. public CP(Stream stream) { parser = new ClabXmlParser(this); try { parser.Parse(stream); } catch (ClabXMLParserException e) { throw new ClabException(e.Message, e); } } /// /// Optional header information in the XML file. /// Description of the XML data (optional metadata) /// public String Description { get { return description; } set { description = value; } } /// /// Optional header information in the XML file. /// Author of the XML data (optional metadata) /// public String Author { get {return author; } set {author = value; } } /// /// Optional header information in the XML file. /// Timestamp of the XML data (optional metadata) /// /// The date. public String Date { get { return date; } set { date = value; } } /// /// Gets the list of type objects in the internal data representation /// /// The types. public List Types { get { return types; } } /// /// Gets the List of variable objects in the internal data representation. /// /// The list of variables. public List Variables { get { return variables; } } /// /// Gets the list of rule (expression) objects in the internal data representation /// /// The rules. public List Rules { get { return rules; } } /// /// Adds a type object to the internal data representation /// /// The type object to add public void AddType(Type newType) { types.Add(newType); } /// /// Adds a variable object to the internal data representation /// /// The variable object to add public void AddVariable(Variable newVariable) { variables.Add(newVariable); } /// /// Adds a rule (expression) object to the internal data representation /// /// The rule to add public void AddRule(Expression newRule) { rules.Add(newRule); } } }