예제 #1
0
 public static void connectSon(IXmlBBase father, IXmlBBase son)
 {
     if (son != null)
     {
         son.setFather(father);
     }
 }
 public static void connectSons(IXmlBBase father, ICollection l)
 {
     if (l != null)
     {
         foreach (IXmlBBase item in l)
             connectSon(father, item);
     }
 }
        private void performTest(XmlBBaseAcceptor acceptor,
                                 String fname,
                                 int count,
                                 int inMem)
        {
            XmlBStringContext ctxt = new XmlBStringContext();
            String            b;

            long start = 0; //System.currentTimeMillis();

            if (!ctxt.readFile(fname))
            {
                System.Console.WriteLine("Could not open file : " +
                                         fname);
                return;
            }
            IXmlBBase[] el = new IXmlBBase[inMem];
            try
            {
                int ptr = 0;
                for (int i = 0; i < count; i++)
                {
                    if (i % 1000 == 0)
                    {
                        System.Console.WriteLine("" + (i) + "/" + count);
                    }
                    el[ptr] = acceptor.genericAccept(ctxt);
                    ctxt.setPtr(0);
                    ptr++;
                    if (ptr >= el.Length)
                    {
                        ptr = 0;
                    }
                }
                long stop = 0;//System.currentTimeMillis();
                System.Console.WriteLine("Done parsing.    Total time: " +
                                         (stop - start) + " millisecs   Time/instance: " +
                                         (stop - start) / count);
                // System.Console.WriteLine (el[0].toString());
                start = 0;//System.currentTimeMillis();
                for (int i = 0; i < count; i++)
                {
                    if (i % 1000 == 0)
                    {
                        System.Console.WriteLine("" + (i) + "/" + count);
                    }
                    b = el[0].ToString();
                }
                stop = 0;//System.currentTimeMillis();
                System.Console.WriteLine("Done unparsing.  Total time: " +
                                         (stop - start) + " millisecs   Time/instance: " +
                                         (stop - start) / count);
            }
            catch (Exception)
            {
                ctxt.dumpError();
            }
        }
예제 #4
0
 /// <summary>
 /// Sets the default values for the element provided as parameter
 /// </summary>
 /// <param name="model"></param>
 public void SetDefaultValue(IXmlBBase model)
 {
     // We are creating a new element, notification about changes in that element
     // are not necessary.
     Util.DontNotify(() =>
     {
         // ReSharper disable once ConvertToLambdaExpression
         visit(model, true);
     });
 }
예제 #5
0
 public static void connectSons(IXmlBBase father, ICollection l)
 {
     if (l != null)
     {
         foreach (IXmlBBase item in l)
         {
             connectSon(father, item);
         }
     }
 }
예제 #6
0
        public void setSon(IXmlBBase n)
        {
            XmlBBase n1;

            if (n != null)
            {
                n1          = (XmlBBase)n;
                n1.aFather  = this;
                n1.aSibling = aFirstSon;
            }
            aFirstSon = n;
        }
예제 #7
0
        /// <summary>
        ///     Finds the elements requested
        /// </summary>
        /// <param name="root"></param>
        /// <returns></returns>
        public HashSet <T> find(IXmlBBase root)
        {
            if (!TheCache.ContainsKey(root))
            {
                currentSet = new HashSet <T>();
                visit(root, false);
                dispatch(root, true);
                TheCache[root] = currentSet;
            }

            return(TheCache[root]);
        }
        private void performTest(XmlBBaseAcceptor acceptor,
            String fname,
            int count,
            int inMem)
        {
            XmlBStringContext ctxt = new XmlBStringContext();
            String b;

            long start = 0; //System.currentTimeMillis();

            if (!ctxt.readFile(fname))
            {
                System.Console.WriteLine("Could not open file : " +
                           fname);
                return;
            }
            IXmlBBase[] el = new IXmlBBase[inMem];
            try
            {
                int ptr = 0;
                for (int i = 0; i < count; i++)
                {
                    if (i % 1000 == 0)
                        System.Console.WriteLine("" + (i) + "/" + count);
                    el[ptr] = acceptor.genericAccept(ctxt);
                    ctxt.setPtr(0);
                    ptr++;
                    if (ptr >= el.Length)
                        ptr = 0;
                }
                long stop = 0;//System.currentTimeMillis();
                System.Console.WriteLine("Done parsing.    Total time: " +
                           (stop - start) + " millisecs   Time/instance: " +
                           (stop - start) / count);
                // System.Console.WriteLine (el[0].toString());
                start = 0;//System.currentTimeMillis();
                for (int i = 0; i < count; i++)
                {
                    if (i % 1000 == 0)
                        System.Console.WriteLine("" + (i) + "/" + count);
                    b = el[0].ToString();
                }
                stop = 0;//System.currentTimeMillis();
                System.Console.WriteLine("Done unparsing.  Total time: " +
                           (stop - start) + " millisecs   Time/instance: " +
                           (stop - start) / count);
            }
            catch (Exception)
            {
                ctxt.dumpError();
            }
        }
예제 #9
0
        public bool genericSave(IXmlBBase obj,
                                string fName)
        {
            FileStream   fs;
            StreamWriter pw;

            fs = new FileStream(fName, FileMode.Create);
            pw = new StreamWriter(fs);
            genericUnParse(pw, obj);
            pw.Flush();
            fs.Close();
            return(true);
        }
        public bool genericSave(IXmlBBase obj,
            string fName)
        {
            FileStream fs;
            StreamWriter pw;

            fs = new FileStream(fName, FileMode.Create);
            pw = new StreamWriter(fs);
            genericUnParse(pw, obj);
            pw.Flush();
            fs.Close();
            return true;
        }
 public override void visit(IXmlBBase obj, bool visitSubNodes)
 {
     IGraphicalDisplay graphicalDisplay = obj as IGraphicalDisplay;
     if (graphicalDisplay != null)
     {
         graphicalDisplay.X = -1;
         graphicalDisplay.Y = -1;
         graphicalDisplay.Width = 0;
         graphicalDisplay.Height = 0;
         graphicalDisplay.Hidden = false;
         graphicalDisplay.Pinned = false;
     }
     base.visit(obj);
 }
예제 #12
0
        public override void visit(IXmlBBase obj, bool visitSubNodes)
        {
            IGraphicalDisplay graphicalDisplay = obj as IGraphicalDisplay;

            if (graphicalDisplay != null)
            {
                graphicalDisplay.X      = -1;
                graphicalDisplay.Y      = -1;
                graphicalDisplay.Width  = 0;
                graphicalDisplay.Height = 0;
                graphicalDisplay.Hidden = false;
                graphicalDisplay.Pinned = false;
            }
            base.visit(obj);
        }
        /// <summary>
        ///     Cleans up the declared elements dictionaries
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="visitSubNodes"></param>
        public override void visit(IXmlBBase obj, bool visitSubNodes)
        {
            ModelElement modelElement = obj as ModelElement;
            if (modelElement != null && ClearCaches)
            {
                modelElement.ClearCache();
            }

            ISubDeclarator subDeclarator = obj as ISubDeclarator;
            if (subDeclarator != null)
            {
                subDeclarator.InitDeclaredElements();
            }

            base.visit(obj, visitSubNodes);
        }
예제 #14
0
            public override void visit(IXmlBBase obj, bool visitSubNodes)
            {
                ReqRef reqRef = obj as ReqRef;

                if (reqRef != null)
                {
                    if (reqRef.Paragraph != null)
                    {
                        if (!ParagraphsReqRefs.ContainsKey(reqRef.Paragraph))
                        {
                            ParagraphsReqRefs.Add(reqRef.Paragraph, new List <ReqRef>());
                        }
                        _paragraphsReqRefs[reqRef.Paragraph].Add(reqRef);
                    }
                }
            }
예제 #15
0
        public void unParse(TextWriter pw, IXmlBBase el, bool typeId,
                            String headingTag,
                            String endingTag)
        {
            XmlBBase el2;

            if (el == null)
            {
                return;
            }
            el2 = (XmlBBase)el;

            while (el2 != null)
            {
                el2.unParse(pw, typeId, headingTag, endingTag);
                el2 = (XmlBBase)el2.aNext;
            }
        }
예제 #16
0
            /// <summary>
            ///     Cleans up the declared elements dictionaries
            /// </summary>
            /// <param name="obj"></param>
            /// <param name="visitSubNodes"></param>
            public override void visit(IXmlBBase obj, bool visitSubNodes)
            {
                ModelElement modelElement = obj as ModelElement;

                if (modelElement != null && ClearCaches)
                {
                    modelElement.ClearCache();
                }

                ISubDeclarator subDeclarator = obj as ISubDeclarator;

                if (subDeclarator != null)
                {
                    subDeclarator.InitDeclaredElements();
                }

                base.visit(obj, visitSubNodes);
            }
예제 #17
0
        public IXmlBBase[] subElements()
        {
            ArrayList l = new ArrayList();

            subElements(l);
            for (int i = l.Count - 1; i >= 0; i--)
            {
                if (l[i] == null)
                {
                    l.Remove(i);
                }
            }
            if (l.Count == 0)
            {
                return(null);
            }
            IXmlBBase[] res = new IXmlBBase[l.Count];
            l.CopyTo(res, 0);
            return(res);
        }
예제 #18
0
 public abstract bool genericUnParse(TextWriter pw, IXmlBBase obj);
예제 #19
0
 virtual public IXmlBBase[] genericSubElements(IXmlBBase obj)
 {
     return(new IXmlBBase[0]);
 }
 /// <summary>Part of the list interface for PreConditions
 /// This function returns the index of an element in
 /// the collection.</summary>
 /// <param name="el">the object to look for</param>
 /// <returns>the index where it is found, or -1 if it is not.</returns>
 public int indexOfPreConditions(IXmlBBase el)
 {
     return ((System.Collections.IList) allPreConditions()).IndexOf (el);
 }
 /// <remarks>This method is used by XMLBooster-generated code
 /// internally. Please refrain from using it, as it
 /// might produce unexpected results, and might change
 /// or even disappear in the future.</remarks>
 public override IXmlBBase[] genericSubElements(IXmlBBase obj)
 {
     return ((XmlBBase ) obj).subElements();
 }
 /// <summary>Part of the list interface for Translations
 /// This function returns the index of an element in
 /// the collection.</summary>
 /// <param name="el">the object to look for</param>
 /// <returns>the index where it is found, or -1 if it is not.</returns>
 public int indexOfTranslations(IXmlBBase el)
 {
     return ((System.Collections.IList) allTranslations()).IndexOf (el);
 }
 /// <summary>Part of the list interface for Translations
 /// This deletion function removes an element from the
 /// collection in Translations
 /// If the object given in parameter is not found in the
 /// the collection, this function does nothing.</summary>
 /// <param name="obj">the object to remove</param>
 public void removeTranslations(IXmlBBase obj)
 {
     int idx = indexOfTranslations(obj);
       if (idx >= 0) { deleteTranslations(idx);
     NotifyControllers(null);
        }
 }
예제 #24
0
 public virtual void visit(IXmlBBase obj)
 {
 }
예제 #25
0
 public void setFather(IXmlBBase f)
 {
     aFather = f;
 }
예제 #26
0
 public virtual void visit(IXmlBBase obj, bool visitSubNodes)
 {
 }
예제 #27
0
 public void setNext(IXmlBBase n)
 {
     aNext = n;
 }
 /// <summary>Part of the list interface for SubSteps
 /// This deletion function removes an element from the
 /// collection in SubSteps
 /// If the object given in parameter is not found in the
 /// the collection, this function does nothing.</summary>
 /// <param name="obj">the object to remove</param>
 public void removeSubSteps(IXmlBBase obj)
 {
     int idx = indexOfSubSteps(obj);
       if (idx >= 0) { deleteSubSteps(idx);
     NotifyControllers(null);
        }
 }
 public void removeSubVariables(IXmlBBase obj,Lock aLock)
 {
     int idx = indexOfSubVariables(obj);
       if (idx >= 0) { deleteSubVariables(idx);
     NotifyControllers(aLock);
       }
 }
 /// <summary>Part of the list interface for Folders
 /// This function returns the index of an element in
 /// the collection.</summary>
 /// <param name="el">the object to look for</param>
 /// <returns>the index where it is found, or -1 if it is not.</returns>
 public int indexOfFolders(IXmlBBase el)
 {
     return ((System.Collections.IList) allFolders()).IndexOf (el);
 }
 public override void dispatch(IXmlBBase obj, bool visitSubNodes)
 {
     if (obj == null){
     return;
     } // If
     ((XmlBBase)obj).dispatch(this, visitSubNodes);
 }
 public void removeFolders(IXmlBBase obj,Lock aLock)
 {
     int idx = indexOfFolders(obj);
       if (idx >= 0) { deleteFolders(idx);
     NotifyControllers(aLock);
       }
 }
예제 #33
0
 abstract public void dispatch(IXmlBBase obj);
 /// <summary>Part of the list interface for SubVariables
 /// This function returns the index of an element in
 /// the collection.</summary>
 /// <param name="el">the object to look for</param>
 /// <returns>the index where it is found, or -1 if it is not.</returns>
 public int indexOfSubVariables(IXmlBBase el)
 {
     return ((System.Collections.IList) allSubVariables()).IndexOf (el);
 }
 /// <summary>Part of the list interface for Elements
 /// This function returns the index of an element in
 /// the collection.</summary>
 /// <param name="el">the object to look for</param>
 /// <returns>the index where it is found, or -1 if it is not.</returns>
 public int indexOfElements(IXmlBBase el)
 {
     return ((System.Collections.IList) allElements()).IndexOf (el);
 }
 public override void dispatch(IXmlBBase obj)
 {
     dispatch (obj, true);
 }
 public virtual IXmlBBase[] genericSubElements(IXmlBBase obj)
 {
     return new IXmlBBase[0];
 }
 /// <remarks>This method is used by XMLBooster-generated code
 /// internally. Please refrain from using it, as it
 /// might produce unexpected results, and might change
 /// or even disappear in the future.</remarks>
 public static IXmlBBase[] subElements(IXmlBBase obj)
 {
     return ((XmlBBase ) obj).subElements();
 }
 /// <summary>Part of the list interface for Elements
 /// This deletion function removes an element from the
 /// collection in Elements
 /// If the object given in parameter is not found in the
 /// the collection, this function does nothing.</summary>
 /// <param name="obj">the object to remove</param>
 public void removeElements(IXmlBBase obj)
 {
     int idx = indexOfElements(obj);
       if (idx >= 0) { deleteElements(idx);
     NotifyControllers(null);
        }
 }
 /// <remarks>This method is used by XMLBooster-generated code
 /// internally. Please refrain from using it, as it
 /// might produce unexpected results, and might change
 /// or even disappear in the future.</remarks>
 public override bool genericUnParse(TextWriter pw, IXmlBBase obj)
 {
     ((XmlBBase ) obj).unParse(pw, false);
       return true;
 }
 /// <summary>Part of the list interface for Interfaces
 /// This deletion function removes an element from the
 /// collection in Interfaces
 /// If the object given in parameter is not found in the
 /// the collection, this function does nothing.</summary>
 /// <param name="obj">the object to remove</param>
 public void removeInterfaces(IXmlBBase obj)
 {
     int idx = indexOfInterfaces(obj);
       if (idx >= 0) { deleteInterfaces(idx);
     NotifyControllers(null);
        }
 }
 public void removePreConditions(IXmlBBase obj,Lock aLock)
 {
     int idx = indexOfPreConditions(obj);
       if (idx >= 0) { deletePreConditions(idx);
     NotifyControllers(aLock);
       }
 }
 /// <summary>Part of the list interface for Procedures
 /// This deletion function removes an element from the
 /// collection in Procedures
 /// If the object given in parameter is not found in the
 /// the collection, this function does nothing.</summary>
 /// <param name="obj">the object to remove</param>
 public void removeProcedures(IXmlBBase obj)
 {
     int idx = indexOfProcedures(obj);
       if (idx >= 0) { deleteProcedures(idx);
     NotifyControllers(null);
        }
 }
 public static void connectSon(IXmlBBase father, IXmlBBase son)
 {
     if (son != null)
         son.setFather(father);
 }
 /// <summary>Part of the list interface for SourceTexts
 /// This function returns the index of an element in
 /// the collection.</summary>
 /// <param name="el">the object to look for</param>
 /// <returns>the index where it is found, or -1 if it is not.</returns>
 public int indexOfSourceTexts(IXmlBBase el)
 {
     return ((System.Collections.IList) allSourceTexts()).IndexOf (el);
 }
 /// <summary>Part of the list interface for Interfaces
 /// This function returns the index of an element in
 /// the collection.</summary>
 /// <param name="el">the object to look for</param>
 /// <returns>the index where it is found, or -1 if it is not.</returns>
 public int indexOfInterfaces(IXmlBBase el)
 {
     return ((System.Collections.IList) allInterfaces()).IndexOf (el);
 }
예제 #47
0
 abstract public void dispatch(IXmlBBase obj, bool visitSubNodes);
 public abstract bool genericUnParse(TextWriter pw, IXmlBBase obj);
 /// <summary>Part of the list interface for StateMachines
 /// This function returns the index of an element in
 /// the collection.</summary>
 /// <param name="el">the object to look for</param>
 /// <returns>the index where it is found, or -1 if it is not.</returns>
 public int indexOfStateMachines(IXmlBBase el)
 {
     return ((System.Collections.IList) allStateMachines()).IndexOf (el);
 }