public void ParseComponent(InterfaceObject parentInterface, AtlasFeature feature)
        {
            Component comp = new Component(feature.Name);

            this.bragi.AddComponent(comp);

            if (parentInterface != null)
            {
                Socket so = new Socket(comp, parentInterface, (++counter).ToString());
                bragi.AddSocket(so);
            }

            foreach (AtlasFeature fchild in this.model.GetChildren(feature))
            {
                if (fchild.IsAbstract)
                {
                    this.ParseInterface(comp, fchild);
                }
                else
                {
                    string          iname = (++counter).ToString();
                    InterfaceObject o     = new InterfaceObject(iname, comp);
                    this.bragi.AddInterface(o);

                    SMarty m = new SMarty((++counter).ToString(), SMartyBindingTimeTypes.CompileTime, o);
                    this.bragi.AddAttachment(m);

                    this.ParseComponent(o, fchild);
                }
            }
        }
示例#2
0
 private void ReadElements(ClaferClassNode elements, AtlasFeature feature)
 {
     if (elements.Type == ClaferClasses.Elements && elements.Derivations[0].Type != ClaferClasses.Epsilon)
     {
         entry.Pop();
         ReadListElement(elements.Derivations[1], feature);
         entry.Pop();
     }
 }
示例#3
0
 private void ReadListElement(ClaferClassNode listElement, AtlasFeature feature)
 {
     if (listElement.Type == ClaferClasses.ListElement)
     {
         if (listElement.Derivations[0].Type != ClaferClasses.Epsilon)
         {
             ReadClafer(listElement.Derivations[0].Derivations[0], feature);
             ReadListElement(listElement.Derivations[1], feature);
         }
     }
 }
示例#4
0
        private void ReadClafer(ClaferClassNode clafer)
        {
            bool   isAbstract = ReadAbstract(clafer.Derivations[0]);
            string name       = ReadIdent(clafer.Derivations[2]);

            AtlasFeature feature = new AtlasFeature(name);

            feature.IsAbstract = isAbstract;

            atlas.CreateFeatureModel(feature);

            ReadElements(clafer.Derivations[5], feature);
        }
示例#5
0
        private void ReadClafer(ClaferClassNode clafer, AtlasFeature feature)
        {
            bool isAbstract          = ReadAbstract(clafer.Derivations[0]);
            AtlasConnectionType type = ReadGCard(clafer.Derivations[1]);
            string name = ReadIdent(clafer.Derivations[2]);

            AtlasFeature newFeature = new AtlasFeature(name);

            newFeature.IsAbstract = isAbstract;

            atlas.AddFeature(newFeature, feature, type);

            ReadElements(clafer.Derivations[5], newFeature);
        }
        public void ParseInterface(Component parentComponent, AtlasFeature feature)
        {
            string iname = (++counter).ToString();

            InterfaceObject o = new InterfaceObject(iname, parentComponent);

            this.bragi.AddInterface(o);

            SMarty m = new SMarty((++counter).ToString(), SMartyBindingTimeTypes.CompileTime, o);

            this.bragi.AddAttachment(m);

            foreach (AtlasFeature child in this.model.GetChildren(feature))
            {
                this.ParseComponent(o, child);
            }
        }
        public void SaveTo(AtlasFeatureModel atlas, string filename)
        {
            this.model = atlas;
            this.bragi = new ComponentDiagramBragi();

            AtlasFeature rootFeature = atlas.GetFeature(atlas.RootFeatureName);

            this.ParseComponent(null, rootFeature);


            this.bragi.AddStereotype(new Stereotype("Mutex"));
            this.bragi.AddStereotype(new Stereotype("Requires"));
            XmlSerializer serializer = new XmlSerializer(typeof(ComponentDiagramBragi));

            using (TextWriter writer = new StreamWriter(filename)){
                serializer.Serialize(writer, this.bragi);
            }
        }
示例#8
0
        private AtlasFeature buildFeature(Node node, AtlasFeature parent, ref AtlasFeatureModel atlas)
        {
            AtlasFeature f = new AtlasFeature(node.Name);

            atlas.AddFeature(f);

            //children
            foreach (Node n in node.Children)
            {
                AtlasFeature    ff  = buildFeature(n, f, ref atlas);
                AtlasConnection con = null;

                switch (n.Type)
                {
                case NodeType.Mandatory:
                case NodeType.Root:
                    con = new AtlasConnection(f, ff, AtlasConnectionType.Mandatory);
                    break;

                case NodeType.Optional:
                    con = new AtlasConnection(f, ff, AtlasConnectionType.Optional);
                    break;

                case NodeType.Or:
                    con = new AtlasConnection(f, ff, AtlasConnectionType.OrRelation);
                    break;

                case NodeType.Xor:
                    con = new AtlasConnection(f, ff, AtlasConnectionType.Alternative);
                    break;
                }
                atlas.AddConnection(con);
            }

            return(f);
        }
示例#9
0
        /// <summary>
        /// Parses an Atlas from an existing SPLOT xml format.
        /// </summary>
        /// <returns></returns>
        public AtlasFeatureModel LoadFrom(string filename)
        {
            //loads XML document.
            XmlDocument document = new XmlDocument();

            document.Load(filename);

            //select tree node.
            XmlNodeList foundNodes = document.SelectNodes("//feature_tree");

            if (foundNodes.Count != 1)
            {
                throw new Exception("Unable to parse document.");
            }

            //tree content
            String treeInfo = foundNodes[0].InnerText;

            String[] rawNodes = treeInfo.Split('\n');

            //remove dummy windows line-break characters
            if (rawNodes[0].StartsWith("\r"))
            {
                for (int i = 0; i < rawNodes[i].Count(); i++)
                {
                    rawNodes[i] = rawNodes[i].Replace("\r", "");
                }
            }

            //convert strings to nodes (tree)
            Stack <Node> nodeStack = new Stack <Node>();


            foreach (String stringNode in rawNodes)
            {
                if (stringNode.Trim() == string.Empty)
                {
                    continue;
                }

                Node n = stringNode.ToNode();

                //root node
                if (nodeStack.Count == 0)
                {
                    nodeStack.Push(n);
                    continue;
                }

                if (nodeStack.Peek().Depth < n.Depth) //is subnode
                {
                    nodeStack.Peek().Children.Add(n);
                    nodeStack.Push(n);
                }
                else if (nodeStack.Peek().Depth == n.Depth)  // same-level node
                {
                    nodeStack.Pop();
                    nodeStack.Peek().Children.Add(n);
                    nodeStack.Push(n);
                }
                else   //uncle-node -> pops it
                {
                    while (nodeStack.Peek().Depth > n.Depth)
                    {
                        nodeStack.Pop();
                    }
                    nodeStack.Peek().Children.Add(n);
                    nodeStack.Push(n);
                }
            }


            AtlasFeatureModel atlas = new AtlasFeatureModel();
            AtlasFeature      root  = this.buildFeature(nodeStack.LastOrDefault(), null, ref atlas);

            return(atlas);
        }