From fe8c2be3f0d21c75981f16c76003148300a917ec Mon Sep 17 00:00:00 2001 From: MichalMoskal Date: Thu, 14 Oct 2010 21:45:03 +0000 Subject: Add DisplayNode class with default IDisplayNode implementation. Add IDisplayNode.State. --- Source/ModelViewer/DataModel.cs | 56 ++++++++++++++++++++++++++++++++--------- 1 file changed, 44 insertions(+), 12 deletions(-) (limited to 'Source/ModelViewer/DataModel.cs') diff --git a/Source/ModelViewer/DataModel.cs b/Source/ModelViewer/DataModel.cs index 6f8811e9..bda154ca 100644 --- a/Source/ModelViewer/DataModel.cs +++ b/Source/ModelViewer/DataModel.cs @@ -5,6 +5,13 @@ using System.Text; namespace Microsoft.Boogie.ModelViewer { + [Flags] + public enum NodeState + { + Normal = 0, + Changed = 1 + } + public interface IDisplayNode { string Name { get; } @@ -12,6 +19,7 @@ namespace Microsoft.Boogie.ModelViewer bool Expandable { get; } IEnumerable Expand(); object ViewSync { get; set; } + NodeState State { get; } } public interface ILanguageProvider @@ -20,18 +28,11 @@ namespace Microsoft.Boogie.ModelViewer IEnumerable GetStates(Model m); } - public class ContainerNode : IDisplayNode + public abstract class DisplayNode : IDisplayNode { protected string name; - protected Func convert; - protected IEnumerable data; - public ContainerNode(string name, Func convert, IEnumerable data) - { - this.name = name; - this.convert = convert; - this.data = data; - } + public DisplayNode(string n) { name = n; } public virtual string Name { @@ -43,9 +44,42 @@ namespace Microsoft.Boogie.ModelViewer get { yield break; } } - public virtual bool Expandable { get { return true; } } + public virtual bool Expandable + { + get { return false; } + } public virtual IEnumerable Expand() + { + yield break; + } + + public virtual NodeState State { get { return NodeState.Normal; } } + + public object ViewSync { get; set; } + } + + public static class SeqExtensions + { + public static IEnumerable Map(this IEnumerable inp, Func conv) + { + foreach (var s in inp) yield return conv(s); + } + } + + public class ContainerNode : DisplayNode + { + protected Func convert; + protected IEnumerable data; + + public ContainerNode(string name, Func convert, IEnumerable data) : base(name) + { + this.convert = convert; + this.data = data; + } + + public override bool Expandable { get { return true; } } + public override IEnumerable Expand() { foreach (var f in data) { var res = convert(f); @@ -53,8 +87,6 @@ namespace Microsoft.Boogie.ModelViewer yield return res; } } - - public object ViewSync { get; set; } } -- cgit v1.2.3