/* Uiml.Net: a .Net UIML renderer (http://lumumba.uhasselt.be/kris/research/uiml.net) Copyright (C) 2003 Kris Luyten (kris.luyten@uhasselt.be) Expertise Centre for Digital Media (http://edm.uhasselt.be) Hasselt University This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ namespace Uiml { using Uiml.Peers; using System; using System.Xml; using System.Collections; public class Peer : UimlAttributes, IUimlElement { private ArrayList m_presentations; private ArrayList m_logic; private Presentation m_selected; public Peer(XmlNode nTopPeer) { m_presentations = new ArrayList(); m_logic = new ArrayList(); Process(nTopPeer); } public void AddPeer(Presentation presvoc) { m_presentations.Add(presvoc); } public void AddLogic(Logic l) { m_logic.Add(l); } public void Process(XmlNode n) { if(n.HasChildNodes){ XmlNodeList xnl = n.ChildNodes; for(int i=0; i /// Checks whether this peer has a presentation vocabulary for pattern /// public bool Provides(string pattern) { IEnumerator enumPres = m_presentations.GetEnumerator(); while(enumPres.MoveNext()) { if(((Presentation)enumPres.Current).Provides(pattern)) return true; } return false; } /// ///Returns the Vocabulary that matches pattern /// public Vocabulary GetVocabulary(string pattern) { IEnumerator enumPres = m_presentations.GetEnumerator(); while(enumPres.MoveNext()) if(((Presentation)enumPres.Current).Provides(pattern)) return ((Presentation)enumPres.Current).UimlVocabulary; throw new VocabularyUnavailableException(pattern); } /// ///Returns the first Vocabulary that fits this Peer /// public Vocabulary GetVocabulary() { IEnumerator enumPres = m_presentations.GetEnumerator(); if(enumPres.MoveNext()) return ((Presentation)enumPres.Current).UimlVocabulary; else throw new VocabularyUnavailableException("There is no vocabulary loaded"); } /// ///If there are multiple presentations, one vocabulary must be selected as the ``current'' one. /// /// ///Precondition: Presentation p must be a member of this peer /// public void Select(Presentation p) { //TODO } /// ///If there are multiple presentations, one vocabulary must be selected as the ``current'' one. /// /// ///Precondition: the member must match with a presentation member of this peer /// public void Select(string pattern) { //TODO } public ArrayList Children { get { ArrayList al = new ArrayList(); al.AddRange(m_presentations); al.AddRange(m_logic); return al; } } public ArrayList Logic { get { return m_logic; } } public const string PRESENTATION = "presentation"; public const string LOGIC = "logic"; public const string IAM = "peers"; } }