Example #1
0
 /// <summary>
 /// Copy constructor.
 /// </summary>
 /// <param name="dataSource">The LGSPNamedGraph object to get the data from</param>
 /// <param name="newName">Name of the copied graph.</param>
 /// <param name="oldToNewMap">A map of the old elements to the new elements after cloning.</param>
 public LGSPNamedGraph(LGSPNamedGraph dataSource, String newName, out IDictionary <IGraphElement, IGraphElement> oldToNewMap)
     : base(dataSource, newName, out oldToNewMap)
 {
     NameToElem = new Dictionary <String, IGraphElement>(dataSource.NumNodes + dataSource.NumEdges);
     ElemToName = new Dictionary <IGraphElement, String>(dataSource.NumNodes + dataSource.NumEdges);
     CopyNames(dataSource, oldToNewMap);
 }
        public void AddEdge(IEdge edge, String varName, String elemName)
        {
            LGSPNamedGraph namedGraph = (LGSPNamedGraph)graph;

            namedGraph.AddEdge(edge, elemName);
            SetVariableValue(varName, edge);
        }
        public void AddNode(INode node, String varName, String elemName)
        {
            LGSPNamedGraph namedGraph = (LGSPNamedGraph)graph;

            namedGraph.AddNode(node, elemName);
            SetVariableValue(varName, node);
        }
        public IEdge AddEdge(EdgeType edgeType, INode source, INode target, String varName, String elemName)
        {
            LGSPNamedGraph namedGraph = (LGSPNamedGraph)graph;
            IEdge          edge       = namedGraph.AddEdge(edgeType, source, target, elemName);

            SetVariableValue(varName, edge);
            return(edge);
        }
        public INode AddNode(NodeType nodeType, String varName, String elemName)
        {
            LGSPNamedGraph namedGraph = (LGSPNamedGraph)graph;
            INode          node       = namedGraph.AddNode(nodeType, elemName);

            SetVariableValue(varName, node);
            return(node);
        }
 public LGSPActionExecutionEnvironment(LGSPGraph graph, LGSPActions actions)
 {
     // TODO: evt. IGraph + BaseActions und dann hier cast auf LGSP, mal gucken was an Schnittstelle besser paßt
     this.usedGraphs = new Stack <LGSPGraph>();
     this.usedGraphs.Push(graph);
     this.namedGraphOnTop = graph as LGSPNamedGraph;
     this.curActions      = actions;
     InitActionsProfile(actions);
 }
 public LGSPActionExecutionEnvironment(LGSPGraph graph, LGSPActions actions)
 {
     usedGraphs = new Stack <LGSPGraph>();
     usedGraphs.Push(graph);
     namedGraphOnTop = graph as LGSPNamedGraph;
     curActions      = actions;
     InitActionsProfile(actions);
     customCommandsToDescriptions = new Dictionary <string, string>();
     FillCustomCommandDescriptions();
 }
Example #8
0
        /// <summary>
        /// Creates a new LGSPNamedGraph and LGSPActions instance from the specified specification file.
        /// If the according dlls do not exist or are out of date, the needed processing steps are performed automatically.
        /// A name for the graph is automatically generated.
        /// </summary>
        /// <param name="grgFilename">Filename of the rule specification file (.grg).</param>
        /// <param name="statisticsPath">Optional path to a file containing the graph statistics to be used for building the matchers.</param>
        /// <param name="capacity">The initial capacity for the name maps (performance optimization, use 0 if unsure).</param>
        /// <param name="newGraph">Returns the new named graph.</param>
        /// <param name="newActions">Returns the new BaseActions object.</param>
        /// <exception cref="System.IO.FileNotFoundException">Thrown, when a needed specification file does not exist.</exception>
        /// <exception cref="System.Exception">Thrown, when something goes wrong.</exception>
        public void CreateNamedFromSpec(String grgFilename, String statisticsPath, int capacity,
                                        out LGSPNamedGraph newGraph, out LGSPActions newActions)
        {
            LGSPGraph   graph;
            LGSPActions actions;

            CreateFromSpec(grgFilename, GetNextGraphName(), statisticsPath, ProcessSpecFlags.UseNoExistingFiles, new List <String>(), true, capacity,
                           out graph, out actions);
            newGraph   = (LGSPNamedGraph)graph;
            newActions = actions;
        }
        public void DoUndo(IGraphProcessingEnvironment procEnv)
        {
            String name;

            if (procEnv.Graph is LGSPNamedGraph && ((LGSPNamedGraph)procEnv.Graph).ElemToName.TryGetValue(_newElem, out name))
            {
                LGSPNamedGraph lgspGraph = (LGSPNamedGraph)procEnv.Graph;
                if (_newElem is INode)
                {
                    LGSPNode newNode = (LGSPNode)_newElem;
                    LGSPNode oldNode = (LGSPNode)_oldElem;
                    lgspGraph.ElemToName[oldNode] = name;
                    lgspGraph.RetypingNode(newNode, oldNode); // this will switch the variables
                    lgspGraph.ReplaceNode(newNode, oldNode);
                    lgspGraph.ElemToName.Remove(newNode);
                    lgspGraph.NameToElem[name] = oldNode;
                }
                else
                {
                    LGSPEdge newEdge = (LGSPEdge)_newElem;
                    LGSPEdge oldEdge = (LGSPEdge)_oldElem;
                    lgspGraph.ElemToName[oldEdge] = name;
                    lgspGraph.RetypingEdge(newEdge, oldEdge); // this will switch the variables
                    lgspGraph.ReplaceEdge(newEdge, oldEdge);
                    lgspGraph.ElemToName.Remove(newEdge);
                    lgspGraph.NameToElem[name] = oldEdge;
                }
            }
            else
            {
                LGSPGraph lgspGraph = (LGSPGraph)procEnv.Graph;
                if (_newElem is INode)
                {
                    LGSPNode newNode = (LGSPNode)_newElem;
                    LGSPNode oldNode = (LGSPNode)_oldElem;
                    lgspGraph.RetypingNode(newNode, oldNode); // this will switch the variables
                    lgspGraph.ReplaceNode(newNode, oldNode);
                }
                else
                {
                    LGSPEdge newEdge = (LGSPEdge)_newElem;
                    LGSPEdge oldEdge = (LGSPEdge)_oldElem;
                    lgspGraph.RetypingEdge(newEdge, oldEdge); // this will switch the variables
                    lgspGraph.ReplaceEdge(newEdge, oldEdge);
                }
            }
        }
Example #10
0
 public static GRGEN_MODEL.@Node CreateNode(GRGEN_LGSP.LGSPNamedGraph graph, string nodeName)
 {
     GRGEN_MODEL.@Node node;
     if (poolLevel == 0)
     {
         node = new GRGEN_MODEL.@Node();
     }
     else
     {
         node             = pool[--poolLevel];
         node.lgspInhead  = null;
         node.lgspOuthead = null;
         node.lgspFlags  &= ~(uint)GRGEN_LGSP.LGSPElemFlags.HAS_VARIABLES;
         // implicit initialization, container creation of Node
     }
     graph.AddNode(node, nodeName);
     return(node);
 }
Example #11
0
 public static GRGEN_MODEL.@UEdge CreateEdge(GRGEN_LGSP.LGSPNamedGraph graph, GRGEN_LGSP.LGSPNode source, GRGEN_LGSP.LGSPNode target, string edgeName)
 {
     GRGEN_MODEL.@UEdge edge;
     if (poolLevel == 0)
     {
         edge = new GRGEN_MODEL.@UEdge(source, target);
     }
     else
     {
         edge            = pool[--poolLevel];
         edge.lgspFlags &= ~(uint)GRGEN_LGSP.LGSPElemFlags.HAS_VARIABLES;
         edge.lgspSource = source;
         edge.lgspTarget = target;
         // implicit initialization, container creation of UEdge
     }
     graph.AddEdge(edge, edgeName);
     return(edge);
 }
Example #12
0
        /// <summary>
        /// Copy constructor helper.
        /// </summary>
        /// <param name="dataSource">The LGSPNamedGraph object to get the data from</param>
        /// <param name="oldToNewMap">A map of the old elements to the new elements after cloning.</param>
        private void CopyNames(LGSPNamedGraph dataSource, IDictionary <IGraphElement, IGraphElement> oldToNewMap)
        {
            foreach (INode node in dataSource.Nodes)
            {
                NameToElem[dataSource.GetElementName(node)] = oldToNewMap[node];
                ElemToName[oldToNewMap[node]] = dataSource.GetElementName(node);
            }

            foreach (IEdge edge in dataSource.Edges)
            {
                NameToElem[dataSource.GetElementName(edge)] = oldToNewMap[edge];
                ElemToName[oldToNewMap[edge]] = dataSource.GetElementName(edge);
            }

            /* TODO: remove when cloning of graph variables was implemented
             * foreach(KeyValuePair<IGraphElement, LinkedList<Variable>> kvp in dataSource.ElementMap)
             * {
             *  IGraphElement newElem = oldToNewMap[kvp.Key];
             *  foreach(Variable var in kvp.Value)
             *      SetVariableValue(var.Name, newElem);
             * }*/
        }
Example #13
0
        /// <summary>
        /// Copy constructor helper.
        /// </summary>
        /// <param name="dataSource">The LGSPNamedGraph object to get the data from</param>
        /// <param name="oldToNewMap">A map of the old elements to the new elements after cloning.</param>
        private void CopyNames(LGSPNamedGraph dataSource, IDictionary<IGraphElement, IGraphElement> oldToNewMap)
        {
            foreach(INode node in dataSource.Nodes)
            {
                NameToElem[dataSource.GetElementName(node)] = oldToNewMap[node];
                ElemToName[oldToNewMap[node]] = dataSource.GetElementName(node);
            }

            foreach(IEdge edge in dataSource.Edges)
            {
                NameToElem[dataSource.GetElementName(edge)] = oldToNewMap[edge];
                ElemToName[oldToNewMap[edge]] = dataSource.GetElementName(edge);
            }

            /* TODO: remove when cloning of graph variables was implemented
             * foreach(KeyValuePair<IGraphElement, LinkedList<Variable>> kvp in dataSource.ElementMap)
            {
                IGraphElement newElem = oldToNewMap[kvp.Key];
                foreach(Variable var in kvp.Value)
                    SetVariableValue(var.Name, newElem);
            }*/
        }
Example #14
0
 /// <summary>
 /// Copy constructor.
 /// </summary>
 /// <param name="dataSource">The LGSPNamedGraph object to get the data from</param>
 /// <param name="newName">Name of the copied graph.</param>
 public LGSPNamedGraph(LGSPNamedGraph dataSource, String newName)
     : base(dataSource, newName, out tmpOldToNewMap)
 {
     NameToElem = new Dictionary<String, IGraphElement>(dataSource.NumNodes + dataSource.NumEdges);
     ElemToName = new Dictionary<IGraphElement, String>(dataSource.NumNodes + dataSource.NumEdges);
     CopyNames(dataSource, tmpOldToNewMap);
     tmpOldToNewMap = null;
 }
Example #15
0
 /// <summary>
 /// Creates a new LGSPNamedGraph and LGSPActions instance from the specified specification file.
 /// If the according dlls do not exist or are out of date, the needed processing steps are performed automatically.
 /// A name for the graph is automatically generated.
 /// </summary>
 /// <param name="grgFilename">Filename of the rule specification file (.grg).</param>
 /// <param name="statisticsPath">Optional path to a file containing the graph statistics to be used for building the matchers.</param>
 /// <param name="capacity">The initial capacity for the name maps (performance optimization, use 0 if unsure).</param>
 /// <param name="newGraph">Returns the new named graph.</param>
 /// <param name="newActions">Returns the new BaseActions object.</param>
 /// <exception cref="System.IO.FileNotFoundException">Thrown, when a needed specification file does not exist.</exception>
 /// <exception cref="System.Exception">Thrown, when something goes wrong.</exception>
 public void CreateNamedFromSpec(String grgFilename, String statisticsPath, int capacity,
     out LGSPNamedGraph newGraph, out LGSPActions newActions)
 {
     LGSPGraph graph;
     LGSPActions actions;
     CreateFromSpec(grgFilename, GetNextGraphName(), statisticsPath, ProcessSpecFlags.UseNoExistingFiles, new List<String>(), true, capacity,
         out graph, out actions);
     newGraph = (LGSPNamedGraph)graph;
     newActions = actions;
 }