コード例 #1
0
ファイル: DataDto.cs プロジェクト: inthefabric/Fabric
        /*--------------------------------------------------------------------------------------------*/
        public DataDto(IGraphElement pGraphElement)
        {
            Id         = pGraphElement.Id;
            Properties = pGraphElement.Properties;

            EdgeLabel       = pGraphElement.Label;
            EdgeOutVertexId = pGraphElement.OutVertexId;
            EdgeInVertexId  = pGraphElement.InVertexId;

            Type = ElementType.Vertex;

            if (pGraphElement.Type != RexConn.GraphElementType.Vertex)
            {
                Type = ElementType.Edge;
                return;
            }

            if (Properties != null && Properties.ContainsKey(DbName.Vert.Vertex.VertexType))
            {
                byte ft = byte.Parse(Properties[DbName.Vert.Vertex.VertexType]);
                VertexType = (VertexType.Id)Enum.ToObject(typeof(VertexType.Id), ft);
                return;
            }

            throw new Exception("Unspecified DataTto type: Id=" + pGraphElement.Id +
                                ", Props=" + JsonSerializer.SerializeToString(pGraphElement.Properties));
        }
コード例 #2
0
        public override void Assign(object value, IGraphProcessingEnvironment procEnv)
        {
            IGraphElement elem = (IGraphElement)DestVar.GetVariableValue(procEnv);
            object container = elem.GetAttribute(AttributeName);
            object key = KeyExpression.Evaluate(procEnv);
            AttributeType attrType = elem.Type.GetAttributeType(AttributeName);

            BaseGraph.ChangingAttributeAssignElement(procEnv.Graph, elem, attrType, value, key);

            if(container is IList)
            {
                IList array = (IList)container;
                array[(int)key] = value;
            }
            else if(container is IDeque)
            {
                IDeque deque = (IDeque)container;
                deque[(int)key] = value;
            }
            else
            {
                IDictionary map = (IDictionary)container;
                map[key] = value;
            }

            BaseGraph.ChangedAttribute(procEnv.Graph, elem, attrType);
        }
コード例 #3
0
ファイル: GraphEditor.cs プロジェクト: you8/vvvv-sdk
 public void RemoveGraphElement(IGraphElement element)
 {
     if (element.IsConnectable)
     {
         FConnectables.Remove(element);
     }
 }
コード例 #4
0
        public override void Assign(object value, IGraphProcessingEnvironment procEnv)
        {
            IGraphElement elem        = (IGraphElement)GraphElementVar.GetVariableValue(procEnv);
            int           visitedFlag = VisitedFlagExpression != null ? (int)VisitedFlagExpression.Evaluate(procEnv) : 0;

            procEnv.Graph.SetVisited(elem, visitedFlag, (bool)value);
        }
コード例 #5
0
        public static void CopyElement(IGraphElement element)
        {
            Ensure.That(nameof(element)).IsNotNull(element);

            singleClipboard.Copy(element);
            groupClipboard.Copy(GetCopyGroup(element.Yield()));
        }
コード例 #6
0
ファイル: YCompClient.cs プロジェクト: tmaierhofer/grgen
        private String GetElemLabelWithChangedAttr(IGraphElement elem, AttributeType changedAttrType, object newValue)
        {
            List <InfoTag> infoTagTypes = dumpInfo.GetTypeInfoTags(elem.Type);
            String         infoTagStr   = "";

            if (infoTagTypes != null)
            {
                foreach (InfoTag infoTag in infoTagTypes)
                {
                    object attr;
                    if (infoTag.AttributeType == changedAttrType)
                    {
                        attr = newValue;
                    }
                    else
                    {
                        attr = elem.GetAttribute(infoTag.AttributeType.Name);
                    }
                    if (attr == null)
                    {
                        continue;
                    }
                    infoTagStr += "\\n" + infoTag.AttributeType.Name + " = " + attr.ToString();
                }
            }

            return(dumpInfo.GetElementName(elem) + ":" + elem.Type.Name + infoTagStr);
        }
コード例 #7
0
 public void SettingVisited(IGraphElement elem, int visitorID, bool newValue)
 {
     foreach (RecordingState recordingState in recordings.Values)
     {
         recordingState.writer.WriteLine("# visited[" + visitorID + "] = " + newValue);
     }
 }
コード例 #8
0
ファイル: ContainerHelper.cs プロジェクト: tmaierhofer/grgen
 public static object GetGraphElementAttributeOrElementOfMatch(object source, string attributeOrElementName)
 {
     if (source is IMatch)
     {
         IMatch match = (IMatch)source;
         object value = match.getNode(attributeOrElementName);
         if (value != null)
         {
             return(value);
         }
         value = match.getEdge(attributeOrElementName);
         if (value != null)
         {
             return(value);
         }
         value = match.getVariable(attributeOrElementName);
         return(value);
     }
     else
     {
         IGraphElement elem  = (IGraphElement)source;
         object        value = elem.GetAttribute(attributeOrElementName);
         value = ContainerHelper.IfAttributeOfElementIsContainerThenCloneContainer(
             elem, attributeOrElementName, value);
         return(value);
     }
 }
コード例 #9
0
        public void RemovingElement(IGraphElement elem)
        {
#if LOG_TRANSACTION_HANDLING
            if (elem is INode)
            {
                INode node = (INode)elem;
                writer.WriteLine((paused ? "" : new String(' ', transactionLevel)) + "RemovingElement: " + ((LGSPNamedGraph)procEnv.graph).GetElementName(node) + ":" + node.Type.Name);
            }
            else
            {
                IEdge edge = (IEdge)elem;
                writer.WriteLine((paused ? "" : new String(' ', transactionLevel)) + "RemovingElement: " + ((LGSPNamedGraph)procEnv.graph).GetElementName(edge.Source) + " -" + ((LGSPNamedGraph)procEnv.graph).GetElementName(edge) + ":" + edge.Type.Name + "-> " + ((LGSPNamedGraph)procEnv.graph).GetElementName(edge.Target));
            }
#endif
            if (recording && !paused && !undoing)
            {
                undoItems.Add(new LGSPUndoElemRemoved(elem, procEnv));
                if (object.ReferenceEquals(elem, currentlyRedirectedEdge))
                {
                    LGSPEdge edge = (LGSPEdge)elem;
                    undoItems.Add(new LGSPUndoElemRedirecting(edge, edge.lgspSource, edge.lgspTarget, procEnv));
                    currentlyRedirectedEdge = null;
                }
            }
        }
コード例 #10
0
 /// <summary>
 /// Initializes a ConnectionAssertionError instance.
 /// </summary>
 /// <param name="caeType">The type of error.</param>
 /// <param name="elem">The graph element, where the error was found.</param>
 /// <param name="found">The number of edges found in the graph, if CAEType != CAEType.EdgeNotSpecified.</param>
 /// <param name="valInfo">The corresponding ValidatedInfo object, if CAEType != CAEType.EdgeNotSpecified, otherwise null.</param>
 public ConnectionAssertionError(CAEType caeType, IGraphElement elem, long found, ValidateInfo valInfo)
 {
     CAEType      = caeType;
     Elem         = elem;
     FoundEdges   = found;
     ValidateInfo = valInfo;
 }
コード例 #11
0
        public LinkedList <Variable> GetElementVariables(IGraphElement elem)
        {
            LinkedList <Variable> variableList;

            ElementMap.TryGetValue(elem, out variableList);
            return(variableList);
        }
コード例 #12
0
 public void LoadXmlCollection(IGraphElement parent, XmlElement element, IList list)
 {
     foreach (var xe in element.ChildNodes.OfType <XmlElement>())
     {
         var id = xe.GetAttribute("Id");
         var ge = list.OfType <IGraphElement>().FirstOrDefault(b => b.Id == id);
         if (ge == null)
         {
             if (Types.TryGetValue(xe.Name, out var type))
             {
                 ge        = (IGraphElement)Activator.CreateInstance(type);
                 ge.Parent = parent;
                 ge.Id     = id;
                 LoadXmlAttributes(ge, xe);
                 list.Add(ge);
             }
             else
             {
                 throw new ArgumentException(xe.Name + " type not found");
             }
         }
         else
         {
             LoadXmlAttributes(ge, xe);
         }
     }
 }
コード例 #13
0
        public override void Assign(object value, IGraphProcessingEnvironment procEnv)
        {
            IGraphElement elem = (IGraphElement)DestVar.GetVariableValue(procEnv);
            AttributeType attrType;

            value = ContainerHelper.IfAttributeOfElementIsContainerThenCloneContainer(
                elem, AttributeName, value, out attrType);
            AttributeChangeType changeType = AttributeChangeType.Assign;

            if (elem is INode)
            {
                procEnv.Graph.ChangingNodeAttribute((INode)elem, attrType, changeType, value, null);
            }
            else
            {
                procEnv.Graph.ChangingEdgeAttribute((IEdge)elem, attrType, changeType, value, null);
            }
            elem.SetAttribute(AttributeName, value);
            if (elem is INode)
            {
                procEnv.Graph.ChangedNodeAttribute((INode)elem, attrType);
            }
            else
            {
                procEnv.Graph.ChangedEdgeAttribute((IEdge)elem, attrType);
            }
        }
コード例 #14
0
ファイル: XMIExport.cs プロジェクト: tmaierhofer/grgen
 protected void WriteAttributes(IGraphElement elem)
 {
     foreach(AttributeType attrType in elem.Type.AttributeTypes)
     {
         object value = elem.GetAttribute(attrType.Name);
         String valuestr = (value == null) ? "" : value.ToString();
         switch(attrType.Kind)
         {
         case AttributeKind.BooleanAttr:
         case AttributeKind.DoubleAttr:
         case AttributeKind.FloatAttr:
         case AttributeKind.ByteAttr:
         case AttributeKind.ShortAttr:
         case AttributeKind.IntegerAttr:
         case AttributeKind.LongAttr:
         case AttributeKind.StringAttr:
             xmlwriter.WriteAttributeString(RemoveGrGenPrefix(attrType.Name), valuestr);
             break;
         case AttributeKind.EnumAttr:
             xmlwriter.WriteAttributeString(RemoveGrGenPrefix(attrType.Name), RemoveGrGenPrefix(valuestr));
             break;
         default:
             throw new Exception("Unsupported attribute value type: \"" + attrType.Kind + "\"");
         }
     }
 }
コード例 #15
0
ファイル: YCompClient.cs プロジェクト: tmaierhofer/grgen
        /// <summary>
        /// Dumps all attributes in the form "kind owner::name = value" into a String List
        /// </summary>
        /// <param name="elem">IGraphElement which attributes are to be dumped</param>
        /// <returns>A String List containing the dumped attributes </returns>
        private List <String> DumpAttributes(IGraphElement elem)
        {
            List <String> attribs = new List <String>();

            foreach (AttributeType attrType in elem.Type.AttributeTypes)
            {
                object attr = elem.GetAttribute(attrType.Name);
                String attrString;
                if (attr != null)
                {
                    if (attr is double)
                    {
                        attrString = ((double)attr).ToString(System.Globalization.CultureInfo.InvariantCulture);
                    }
                    else if (attr is float)
                    {
                        attrString = ((float)attr).ToString(System.Globalization.CultureInfo.InvariantCulture) + "f";
                    }
                    else
                    {
                        attrString = attr.ToString();
                    }
                }
                else
                {
                    attrString = "<Not initialized>";
                }
                attribs.Add(String.Format("{0} {1}::{2} = {3}", GetKindName(attrType),
                                          attrType.OwnerType.Name, attrType.Name, attrString));
            }
            return(attribs);
        }
コード例 #16
0
        /////////////////////////////////////////////////////////////////////////////////

        public static void AssignAttribute(object target, object value, string attributeName, IGraph graph)
        {
            if (target is IGraphElement)
            {
                IGraphElement elem = (IGraphElement)target;

                AttributeType attrType;
                value = ContainerHelper.IfAttributeOfElementIsContainerThenCloneContainer(
                    elem, attributeName, value, out attrType);

                BaseGraph.ChangingAttributeAssign(graph, elem, attrType, value);

                elem.SetAttribute(attributeName, value);

                BaseGraph.ChangedAttribute(graph, elem, attrType);
            }
            else if (target is IObject)
            {
                IObject elem = (IObject)target;

                AttributeType attrType = elem.Type.GetAttributeType(attributeName);

                BaseGraph.ChangingAttributeAssign(graph, elem, attrType, value);

                elem.SetAttribute(attributeName, value);
            }
            else //if(target is ITransientObject)
            {
                ITransientObject elem = (ITransientObject)target;

                elem.SetAttribute(attributeName, value);
            }
        }
コード例 #17
0
ファイル: YCompClient.cs プロジェクト: tmaierhofer/grgen
        /// <summary>
        /// Annotates the given element with the given string in double angle brackets
        /// </summary>
        /// <param name="elem">The element to be annotated</param>
        /// <param name="annotation">The annotation string or null, if the annotation is to be removed</param>
        public void AnnotateElement(IGraphElement elem, String annotation)
        {
            bool isNode = elem is INode;

            if (isNode)
            {
                if (dumpInfo.IsExcludedNodeType((NodeType)elem.Type))
                {
                    return;
                }
            }
            else
            {
                if (dumpInfo.IsExcludedEdgeType((EdgeType)elem.Type))
                {
                    return;
                }
            }


            String name           = graph.GetElementName(elem);
            String elemKind       = isNode ? "Node" : "Edge";
            String elemNamePrefix = isNode ? "n" : "e";

            ycompStream.Write("set" + elemKind + "Label \"" + elemNamePrefix + name + "\" \""
                              + (annotation == null ? "" : "<<" + annotation + ">>\\n") + GetElemLabel(elem) + "\"\n");
            isDirty = true;
        }
コード例 #18
0
        public string ToString(object data, INamedGraph graph, params object[] additionalData)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(ToString(debuggingEvent));
            sb.Append(" ");

            switch (debuggingEvent)
            {
            case SubruleDebuggingEvent.Add:
            case SubruleDebuggingEvent.Rem:
            case SubruleDebuggingEvent.Emit:
            case SubruleDebuggingEvent.Halt:
            case SubruleDebuggingEvent.Highlight:
            {
                string message = (string)data;
                sb.Append("\"");
                sb.Append(message);
                sb.Append("\"");
                for (int i = 0; i < additionalData.Length; ++i)
                {
                    sb.Append(" ");
                    sb.Append(EmitHelper.Clip(EmitHelper.ToStringAutomatic(additionalData[i], graph, false, null, null), 120));
                }
                break;
            }

            case SubruleDebuggingEvent.Match:
            {
                IMatches matches = (IMatches)data;
                sb.Append(matches.Producer.PackagePrefixedName);
                break;
            }

            case SubruleDebuggingEvent.New:
            case SubruleDebuggingEvent.Delete:
            case SubruleDebuggingEvent.Retype:
            case SubruleDebuggingEvent.SetAttributes:
            {
                IGraphElement elem = (IGraphElement)data;
                sb.Append(graph.GetElementName(elem));
                sb.Append(":");
                sb.Append(elem.Type.Name);
                if (additionalData.Length > 0)
                {
                    sb.Append(".");     // the attribute name
                    sb.Append((string)additionalData[0]);
                }
                break;
            }

            default:
                return("INTERNAL FAILURE, unknown SubruleDebuggingConfigurationRule");
            }

            sb.Append(" triggers ");
            sb.Append(ToString());

            return(sb.ToString());
        }
コード例 #19
0
        public static bool HasValue(this IAttributeDefinition myAttribute, IGraphElement myElement)
        {
            if (myAttribute == null)
            {
                throw new NullReferenceException();
            }

            if (myElement == null)
            {
                throw new ArgumentNullException("myElement");
            }

            switch (myAttribute.Kind)
            {
            case AttributeType.Property:
                return(IPropertyDefintionExtension.HasValue(myAttribute as IPropertyDefinition, myElement));

            case AttributeType.OutgoingEdge:
                return(IOutgoingEdgeDefinitionExtension.HasValue(myAttribute as IOutgoingEdgeDefinition, myElement as IVertex));

            case AttributeType.IncomingEdge:
                return(IIncomingEdgeDefinitionExtension.HasValue(myAttribute as IIncomingEdgeDefinition, myElement as IVertex));

            case AttributeType.BinaryProperty:
                return(IBinaryPropertyDefintionExtension.HasValue(myAttribute as IBinaryPropertyDefinition, myElement as IVertex));

            default:
                throw new Exception("AttributeType enumeration was changed, but not this switch statement.");
            }
        }
コード例 #20
0
 /// <summary>
 /// Fires an OnSettingVisited event.
 /// </summary>
 /// <param name="elem">The graph element of which the specified flag is to be set.</param>
 /// <param name="visitorID">The id of the visited flag to be set.</param>
 /// <param name="newValue">The new value.</param>
 public void SettingVisited(IGraphElement elem, int visitorID, bool newValue)
 {
     if (OnSettingVisited != null)
     {
         OnSettingVisited(elem, visitorID, newValue);
     }
 }
コード例 #21
0
        /// <summary>
        /// If the attribute of the given name of the given element is a conatiner attribute
        /// then return a clone of the given container value, otherwise just return the original value
        /// </summary>
        public static object IfAttributeOfElementIsContainerThenCloneContainer(
            IGraphElement element, String AttributeName, object value)
        {
            AttributeType attrType;

            return(IfAttributeOfElementIsContainerThenCloneContainer(
                       element, AttributeName, value, out attrType));
        }
コード例 #22
0
ファイル: ArrayHelper.cs プロジェクト: tmaierhofer/grgen
 private static void ExtractAttribute(IList array, string attribute, IList extractedArray)
 {
     foreach (object element in array)
     {
         IGraphElement graphElement = (IGraphElement)element;
         extractedArray.Add(graphElement.GetAttribute(attribute));
     }
 }
コード例 #23
0
        public static Boolean HasLabel(this IGraphElement myIGraphElement)
        {
            if (myIGraphElement == null)
            {
                throw new ArgumentNullException("myIGraphElement must not be null!");
            }

            return(myIGraphElement.Label.IsNotNullOrEmpty());
        }
コード例 #24
0
ファイル: BaseGraph.cs プロジェクト: jblomer/GrGen.NET
        /// <summary>
        /// Fires an OnSettingVisited event.
        /// </summary>
        /// <param name="elem">The graph element of which the specified flag is to be set.</param>
        /// <param name="visitorID">The id of the visited flag to be set.</param>
        /// <param name="newValue">The new value.</param>
        public void SettingVisited(IGraphElement elem, int visitorID, bool newValue)
        {
            SettingVisitedHandler setVisited = OnSettingVisited;

            if (setVisited != null)
            {
                setVisited(elem, visitorID, newValue);
            }
        }
コード例 #25
0
        public static IColor GetColor(this IGraphElement myIGraphElement)
        {
            if (myIGraphElement == null)
            {
                throw new ArgumentNullException("myIGraphElement must not be null!");
            }

            return(myIGraphElement.Color);
        }
コード例 #26
0
        public static String GetLabel(this IGraphElement myIGraphElement)
        {
            if (myIGraphElement == null)
            {
                throw new ArgumentNullException("myIGraphElement must not be null!");
            }

            return(myIGraphElement.Label);
        }
コード例 #27
0
        public void RetypingElement(IGraphElement oldElem, IGraphElement newElem)
        {
#if LOG_TRANSACTION_HANDLING
            writer.WriteLine((paused ? "" : new String(' ', transactionLevel)) + "RetypingElement: " + ((LGSPNamedGraph)procEnv.graph).GetElementName(newElem) + ":" + newElem.Type.Name + "<" + ((LGSPNamedGraph)procEnv.graph).GetElementName(oldElem) + ":" + oldElem.Type.Name + ">");
#endif
            if (recording && !paused && !undoing)
            {
                undoItems.Add(new LGSPUndoElemRetyped(oldElem, newElem, procEnv));
            }
        }
コード例 #28
0
        private void RemoveName(IGraphElement elem)
        {
            String name;

            if (ElemToName.TryGetValue(elem, out name))  // has a name been assigned to the element?
            {
                ElemToName.Remove(elem);
                NameToElem.Remove(name);
            }
        }
コード例 #29
0
        public object Askfor(String typeName)
        {
            if (typeName == null)
            {
                UserInterface.ShowMsgAskForEnter("Pause..");
                return(null);
            }

            if (TypesHelper.GetNodeOrEdgeType(typeName, impl.curShellProcEnv.ProcEnv.NamedGraph.Model) != null) // if type is node/edge type let the user select the element in yComp
            {
                if (!CheckDebuggerAlive())
                {
                    impl.errOut.WriteLine("debug mode must be enabled (yComp available) for asking for a node/edge type");
                    return(null);
                }

                impl.debugOut.WriteLine("Select an element of type " + typeName + " by double clicking in yComp (ESC for abort)...");

                String id = debugger.ChooseGraphElement();
                if (id == null)
                {
                    return(null);
                }

                impl.debugOut.WriteLine("Received @(\"" + id + "\")");

                IGraphElement elem = impl.curShellProcEnv.ProcEnv.NamedGraph.GetGraphElement(id);
                if (elem == null)
                {
                    impl.errOut.WriteLine("Graph element does not exist (anymore?).");
                    return(null);
                }
                if (!TypesHelper.IsSameOrSubtype(elem.Type.PackagePrefixedName, typeName, impl.curShellProcEnv.ProcEnv.NamedGraph.Model))
                {
                    impl.errOut.WriteLine(elem.Type.PackagePrefixedName + " is not the same type as/a subtype of " + typeName + ".");
                    return(null);
                }
                return(elem);
            }
            else // else let the user type in the value
            {
                String       inputValue      = UserInterface.ShowMsgAskForString("Enter a value of type " + typeName + ": ");
                StringReader reader          = new StringReader(inputValue);
                GrShell      shellForParsing = new GrShell(reader);
                shellForParsing.SetImpl(impl.GetGrShellImpl());
                object val         = shellForParsing.Constant();
                String valTypeName = TypesHelper.XgrsTypeOfConstant(val, impl.curShellProcEnv.ProcEnv.NamedGraph.Model);
                if (!TypesHelper.IsSameOrSubtype(valTypeName, typeName, impl.curShellProcEnv.ProcEnv.NamedGraph.Model))
                {
                    impl.errOut.WriteLine(valTypeName + " is not the same type as/a subtype of " + typeName + ".");
                    return(null);
                }
                return(val);
            }
        }
コード例 #30
0
ファイル: GraphEditor.cs プロジェクト: orjanbp/Frienguins
 ///Translate the graph to the center of target element (node, connection)
 public static void FocusElement(IGraphElement element, bool alsoSelect = false)
 {
     if (element is Node)
     {
         FocusNode((Node)element, alsoSelect);
     }
     if (element is Connection)
     {
         FocusConnection((Connection)element, alsoSelect);
     }
 }
コード例 #31
0
ファイル: JSGraphElement.cs プロジェクト: Vanaheimr/Balder
        /// <summary>
        /// Create a new graph element wrapper for JavaScript.
        /// </summary>
        /// <param name="GraphElement">A graph element.</param>
        /// <param name="JavaScriptEngine">An instance of a JavaScript engine.</param>
        public JSGraphElement(IGraphElement<String, Int64, String, String, Object> GraphElement,
                              ScriptEngine JavaScriptEngine)
            : base(JavaScriptEngine)
        {
            this.GraphElement     = GraphElement;
            this.JavaScriptEngine = JavaScriptEngine;

            // Int32 is a Jurassic limitation as JavaScript only supports "number"
            // http://jurassic.codeplex.com/wikipage?title=Supported%20types&referringTitle=Exposing%20a%20.NET%20class%20to%20JavaScript
            this.DefineProperty("Id",      new PropertyDescriptor(GraphElement.Id,    PropertyAttributes.Sealed), true);
            this.DefineProperty("RevId",   new PropertyDescriptor(GraphElement.RevId, PropertyAttributes.Sealed), true);
        }
コード例 #32
0
        public static IComparable GetValue(this IPropertyDefinition myProperty, IGraphElement myElement)
        {
            if (!HasValue(myProperty, myElement))
                return null;

            if (myElement is IVertex)
                return GetValue(myProperty, myElement as IVertex);

            if (myElement is IEdge)
                return GetValue(myProperty, myElement as IEdge);

            throw new Exception("Unknown IGraphElement.");
        }
コード例 #33
0
        public static bool HasValue(this IPropertyDefinition myProperty, IGraphElement myElement)
        {
            if (myProperty == null)
                throw new NullReferenceException();

            if (myElement == null)
                throw new ArgumentNullException("myElement");

            if (myElement is IVertex)
                return HasValue(myProperty, myElement as IVertex);

            if (myElement is IEdge)
                return HasValue(myProperty, myElement as IEdge);

            throw new Exception("Unknown IGraphElement.");
        }
コード例 #34
0
        public static bool HasValue(this IAttributeDefinition myAttribute, IGraphElement myElement)
        {
            if (myAttribute == null)
                throw new NullReferenceException();

            if (myElement == null)
                throw new ArgumentNullException("myElement");

            switch (myAttribute.Kind)
            {
                case AttributeType.Property:
                    return IPropertyDefintionExtension.HasValue(myAttribute as IPropertyDefinition, myElement);
                case AttributeType.OutgoingEdge:
                    return IOutgoingEdgeDefinitionExtension.HasValue(myAttribute as IOutgoingEdgeDefinition, myElement as IVertex);
                case AttributeType.IncomingEdge:
                    return IIncomingEdgeDefinitionExtension.HasValue(myAttribute as IIncomingEdgeDefinition, myElement as IVertex);
                case AttributeType.BinaryProperty:
                    return IBinaryPropertyDefintionExtension.HasValue(myAttribute as IBinaryPropertyDefinition, myElement as IVertex);
                default:
                    throw new Exception("AttributeType enumeration was changed, but not this switch statement.");
            }
        }
コード例 #35
0
        public String _targetName; // for ToString only

        public LGSPUndoElemAdded(IGraphElement elem, LGSPGraphProcessingEnvironment procEnv)
        {
            _elem = elem;
            if(procEnv.graph is LGSPNamedGraph)
            {
                _name = ((LGSPNamedGraph)procEnv.graph).GetElementName(_elem);
                if(_elem is IEdge)
                {
                    _sourceName = ((LGSPNamedGraph)procEnv.graph).GetElementName(((IEdge)_elem).Source);
                    _targetName = ((LGSPNamedGraph)procEnv.graph).GetElementName(((IEdge)_elem).Target);
                }
            }
            else
            {
                _name = "?";
                if(_elem is IEdge)
                {
                    _sourceName = "?";
                    _targetName = "?";
                }
            }
        }
コード例 #36
0
ファイル: YCompClient.cs プロジェクト: jblomer/GrGen.NET
 private void EncodeAttr(AttributeType attrType, IGraphElement elem, out String attrTypeString, out String attrValueString)
 {
     if (attrType.Kind == AttributeKind.SetAttr || attrType.Kind == AttributeKind.MapAttr)
     {
         EmitHelper.ToString((IDictionary)elem.GetAttribute(attrType.Name), out attrTypeString, out attrValueString, attrType, graph);
         attrValueString = Encode(attrValueString);
     }
     else if(attrType.Kind == AttributeKind.ArrayAttr)
     {
         EmitHelper.ToString((IList)elem.GetAttribute(attrType.Name), out attrTypeString, out attrValueString, attrType, graph);
         attrValueString = Encode(attrValueString);
     }
     else if(attrType.Kind == AttributeKind.DequeAttr)
     {
         EmitHelper.ToString((IDeque)elem.GetAttribute(attrType.Name), out attrTypeString, out attrValueString, attrType, graph);
         attrValueString = Encode(attrValueString);
     }
     else
     {
         EmitHelper.ToString(elem.GetAttribute(attrType.Name), out attrTypeString, out attrValueString, attrType, graph);
         attrValueString = Encode(attrValueString);
     }
 }
コード例 #37
0
ファイル: YCompClient.cs プロジェクト: jblomer/GrGen.NET
        private String GetElemLabelWithChangedAttr(IGraphElement elem, AttributeType changedAttrType, String newValue)
        {
            List<InfoTag> infoTagTypes = dumpInfo.GetTypeInfoTags(elem.Type);
            String label = dumpInfo.GetElemTypeLabel(elem.Type);
            bool first = true;

            if(label == null)
            {
                label = dumpInfo.GetElementName(elem) + ":" + elem.Type.Name;
                first = false;
            }

            if(infoTagTypes != null)
            {
                foreach(InfoTag infoTag in infoTagTypes)
                {
                    string attrValueString;

                    if (infoTag.AttributeType == changedAttrType) {
                        attrValueString = newValue;
                    } else {
                        string attrTypeString;
                        EncodeAttr(infoTag.AttributeType, elem, out attrTypeString, out attrValueString);
                    }

                    if(!first) label += "\\n";
                    else first = false;

                    if(!infoTag.ShortInfoTag)
                        label += infoTag.AttributeType.Name + " = ";
                    label += attrValueString;
                }
            }

            return label;
        }
コード例 #38
0
        public String _name; // for ToString only

        public LGSPUndoElemRetyped(IGraphElement oldElem, IGraphElement newElem, LGSPGraphProcessingEnvironment procEnv)
        {
            _oldElem = oldElem;
            _newElem = newElem;
            if(procEnv.graph is LGSPNamedGraph) _name = ((LGSPNamedGraph)procEnv.graph).GetElementName(newElem);
            else _name = "?";
        }
コード例 #39
0
ファイル: lgspGraph.cs プロジェクト: jblomer/GrGen.NET
 /// <summary>
 /// Sets the internal-use visited flag of the given graph element.
 /// (Used for computing reachability when employed from a parallelized matcher executed by the thread pool.)
 /// </summary>
 /// <param name="elem">The graph element whose flag is to be set.</param>
 /// <param name="visited">True for visited, false for not visited.</param>
 /// <param name="threadId">The id of the thread which marks the graph element.</param>
 public override void SetInternallyVisited(IGraphElement elem, bool visited, int threadId)
 {
     List<ushort> flagsPerElement = flagsPerThreadPerElement[threadId];
     LGSPNode node = elem as LGSPNode;
     if(visited)
     {
         if(node != null)
             flagsPerElement[node.uniqueId] |= (ushort)LGSPElemFlagsParallel.IS_VISITED_INTERNALLY;
         else
             flagsPerElement[(elem as LGSPEdge).uniqueId] |= (ushort)LGSPElemFlagsParallel.IS_VISITED_INTERNALLY;
     }
     else
     {
         if(node != null)
             flagsPerElement[node.uniqueId] &= (ushort)~LGSPElemFlagsParallel.IS_VISITED_INTERNALLY;
         else
         {
             flagsPerElement[(elem as LGSPEdge).uniqueId] &= (ushort)~LGSPElemFlagsParallel.IS_VISITED_INTERNALLY;
         }
     }
 }
コード例 #40
0
ファイル: lgspGraph.cs プロジェクト: jblomer/GrGen.NET
 /// <summary>
 /// Sets the internal-use visited flag of the given graph element.
 /// (Used for computing reachability.)
 /// </summary>
 /// <param name="elem">The graph element whose flag is to be set.</param>
 /// <param name="visited">True for visited, false for not visited.</param>
 public override void SetInternallyVisited(IGraphElement elem, bool visited)
 {
     LGSPNode node = elem as LGSPNode;
     if(visited)
     {
         if(node != null)
             node.lgspFlags |= (uint)LGSPElemFlags.IS_VISITED_INTERNALLY;
         else
             (elem as LGSPEdge).lgspFlags |= (uint)LGSPElemFlags.IS_VISITED_INTERNALLY;
     }
     else
     {
         if(node != null)
             node.lgspFlags &= ~(uint)LGSPElemFlags.IS_VISITED_INTERNALLY;
         else
             (elem as LGSPEdge).lgspFlags &= ~(uint)LGSPElemFlags.IS_VISITED_INTERNALLY;
     }
 }
コード例 #41
0
ファイル: lgspGraph.cs プロジェクト: jblomer/GrGen.NET
 /// <summary>
 /// Sets the visited flag of the given graph element.
 /// </summary>
 /// <param name="elem">The graph element whose flag is to be set.</param>
 /// <param name="visitorID">The ID of the visited flag.</param>
 /// <param name="visited">True for visited, false for not visited.</param>
 public override void SetVisited(IGraphElement elem, int visitorID, bool visited)
 {
     SettingVisited(elem, visitorID, visited);
     
     VisitorData visitor = availableVisitors[visitorID];
     if(visitorID < (int) LGSPElemFlags.NUM_SUPPORTED_VISITOR_IDS)     // id supported by flags?
     {
         uint mask = (uint)LGSPElemFlags.IS_VISITED << visitorID;
         LGSPNode node = elem as LGSPNode;
         if(node != null)
         {
             if(visited)
             {
                 node.lgspFlags |= mask;
                 visitor.NodesMarked = true;
             }
             else
                 node.lgspFlags &= ~mask;
         }
         else
         {
             LGSPEdge edge = (LGSPEdge) elem;
             if(visited)
             {
                 edge.lgspFlags |= mask;
                 visitor.EdgesMarked = true;
             }
             else
                 edge.lgspFlags &= ~mask;
         }
     }
     else                                                        // no, use hash map
     {
         if(visited)
             visitor.VisitedElements[elem] = true;
         else
             visitor.VisitedElements.Remove(elem);
     }
 }
コード例 #42
0
ファイル: BaseGraph.cs プロジェクト: jblomer/GrGen.NET
 public abstract bool IsVisited(IGraphElement elem, int visitorID);
コード例 #43
0
ファイル: BaseGraph.cs プロジェクト: jblomer/GrGen.NET
 public abstract void SetInternallyVisited(IGraphElement elem, bool visited, int threadId);
コード例 #44
0
 public LinkedList<Variable> GetElementVariables(IGraphElement elem)
 {
     LinkedList<Variable> variableList;
     ElementMap.TryGetValue(elem, out variableList);
     return variableList;
 }
コード例 #45
0
 public object ExecuteNoImplicitContainerCopy(IGraphProcessingEnvironment procEnv, out IGraphElement elem, out AttributeType attrType)
 {
     elem = SourceValue(procEnv);
     object value = elem.GetAttribute(AttributeName);
     attrType = elem.Type.GetAttributeType(AttributeName);
     return value;
 }
コード例 #46
0
        public IGraph _graph; // for ToString only

        public LGSPUndoElemRemoved(IGraphElement elem, LGSPGraphProcessingEnvironment procEnv)
        {
            _elem = elem;
            _vars = procEnv.GetElementVariables(_elem);
            if(procEnv.graph is LGSPNamedGraph) _name = ((LGSPNamedGraph)procEnv.graph).GetElementName(_elem);
            else _name = null;
            _graph = procEnv.graph;
        }
コード例 #47
0
 private LGSPUndoElemRemoved(IGraphElement elem, String name, LinkedList<Variable> vars)
 {
     _elem = elem;
     _name = name;
     _vars = vars;
 }
コード例 #48
0
        public IGraph _graph; // for ToString only

        public LGSPUndoAttributeChanged(IGraphElement elem, AttributeType attrType,
                AttributeChangeType changeType, Object newValue, Object keyValue, 
                LGSPGraphProcessingEnvironment procEnv)
        {
            _elem = elem;
            _attrType = attrType;
            if(procEnv.graph is LGSPNamedGraph) _name = ((LGSPNamedGraph)procEnv.graph).GetElementName(_elem);
            else _name = "?";
            _graph = procEnv.graph;

            if (_attrType.Kind == AttributeKind.SetAttr)
            {
                if (changeType == AttributeChangeType.PutElement)
                {
                    IDictionary dict = (IDictionary)_elem.GetAttribute(_attrType.Name);
                    if (dict.Contains(newValue))
                    {
                        _undoOperation = UndoOperation.None;
                    }
                    else
                    {
                        _undoOperation = UndoOperation.RemoveElement;
                        _value = newValue;
                    }
                }
                else if (changeType == AttributeChangeType.RemoveElement)
                {
                    IDictionary dict = (IDictionary)_elem.GetAttribute(_attrType.Name);
                    if (dict.Contains(newValue))
                    {
                        _undoOperation = UndoOperation.PutElement;
                        _value = newValue;
                    }
                    else
                    {
                        _undoOperation = UndoOperation.None;
                    }
                }
                else // Assign
                {
                    Type keyType, valueType;
                    IDictionary dict = ContainerHelper.GetDictionaryTypes(
                        _elem.GetAttribute(_attrType.Name), out keyType, out valueType);
                    IDictionary clonedDict = ContainerHelper.NewDictionary(keyType, valueType, dict);
                    _undoOperation = UndoOperation.Assign;
                    _value = clonedDict;
                }
            }
            else if (_attrType.Kind == AttributeKind.ArrayAttr)
            {
                if (changeType == AttributeChangeType.PutElement)
                {
                    IList array = (IList)_elem.GetAttribute(_attrType.Name);
                    _undoOperation = UndoOperation.RemoveElement;
                    _keyOfValue = keyValue;
                }
                else if (changeType == AttributeChangeType.RemoveElement)
                {
                    IList array = (IList)_elem.GetAttribute(_attrType.Name);
                    _undoOperation = UndoOperation.PutElement;
                    if(keyValue == null)
                    {
                        _value = array[array.Count-1];
                    }
                    else
                    {
                        _value = array[(int)keyValue];
                        _keyOfValue = keyValue;
                    }
                }
                else if(changeType == AttributeChangeType.AssignElement)
                {
                    IList array = (IList)_elem.GetAttribute(_attrType.Name);
                    _undoOperation = UndoOperation.AssignElement;
                    _value = array[(int)keyValue];
                    _keyOfValue = keyValue;
                }
                else // Assign
                {
                    Type valueType;
                    IList array = ContainerHelper.GetListType(
                        _elem.GetAttribute(_attrType.Name), out valueType);
                    IList clonedArray = ContainerHelper.NewList(valueType, array);
                    _undoOperation = UndoOperation.Assign;
                    _value = clonedArray;
                }
            }
            else if(_attrType.Kind == AttributeKind.DequeAttr)
            {
                if(changeType == AttributeChangeType.PutElement)
                {
                    IDeque deque = (IDeque)_elem.GetAttribute(_attrType.Name);
                    _undoOperation = UndoOperation.RemoveElement;
                    _keyOfValue = keyValue;
                }
                else if(changeType == AttributeChangeType.RemoveElement)
                {
                    IDeque deque = (IDeque)_elem.GetAttribute(_attrType.Name);
                    _undoOperation = UndoOperation.PutElement;
                    if(keyValue == null)
                    {
                        _value = deque.Front;
                    }
                    else
                    {
                        _value = deque[(int)keyValue];
                        _keyOfValue = keyValue;
                    }
                }
                else if(changeType == AttributeChangeType.AssignElement)
                {
                    IDeque deque = (IDeque)_elem.GetAttribute(_attrType.Name);
                    _undoOperation = UndoOperation.AssignElement;
                    _value = deque[(int)keyValue];
                    _keyOfValue = keyValue;
                }
                else // Assign
                {
                    Type valueType;
                    IDeque deque = ContainerHelper.GetDequeType(
                        _elem.GetAttribute(_attrType.Name), out valueType);
                    IDeque clonedDeque = ContainerHelper.NewDeque(valueType, deque);
                    _undoOperation = UndoOperation.Assign;
                    _value = clonedDeque;
                }
            }
            else if(_attrType.Kind == AttributeKind.MapAttr)
            {
                if (changeType == AttributeChangeType.PutElement)
                {
                    IDictionary dict = (IDictionary)_elem.GetAttribute(_attrType.Name);
                    if (dict.Contains(keyValue))
                    {
                        if (dict[keyValue] == newValue)
                        {
                            _undoOperation = UndoOperation.None;
                        }
                        else
                        {
                            _undoOperation = UndoOperation.PutElement;
                            _value = dict[keyValue];
                            _keyOfValue = keyValue;
                        }
                    }
                    else
                    {
                        _undoOperation = UndoOperation.RemoveElement;
                        _value = newValue;
                        _keyOfValue = keyValue;
                    }
                }
                else if (changeType == AttributeChangeType.RemoveElement)
                {
                    IDictionary dict = (IDictionary)_elem.GetAttribute(_attrType.Name);
                    if (dict.Contains(keyValue))
                    {
                        _undoOperation = UndoOperation.PutElement;
                        _value = dict[keyValue];
                        _keyOfValue = keyValue;
                    }
                    else
                    {
                        _undoOperation = UndoOperation.None;
                    }
                }
                else if(changeType == AttributeChangeType.AssignElement)
                {
                    IDictionary dict = (IDictionary)_elem.GetAttribute(_attrType.Name);
                    if(dict[keyValue] == newValue)
                    {
                        _undoOperation = UndoOperation.None;
                    }
                    else
                    {
                        _undoOperation = UndoOperation.AssignElement;
                        _value = dict[keyValue];
                        _keyOfValue = keyValue;
                    }
                }
                else // Assign
                {
                    Type keyType, valueType;
                    IDictionary dict = ContainerHelper.GetDictionaryTypes(
                        _elem.GetAttribute(_attrType.Name), out keyType, out valueType);
                    IDictionary clonedDict = ContainerHelper.NewDictionary(keyType, valueType, dict);
                    _undoOperation = UndoOperation.Assign;
                    _value = clonedDict;
                }
            }
            else // Primitve Type Assign
            {
                _undoOperation = UndoOperation.Assign;
                _value = _elem.GetAttribute(_attrType.Name);
            }
        }
コード例 #49
0
ファイル: BaseGraph.cs プロジェクト: jblomer/GrGen.NET
 public abstract bool IsInternallyVisited(IGraphElement elem);
コード例 #50
0
ファイル: BaseGraph.cs プロジェクト: jblomer/GrGen.NET
 /// <summary>
 /// Fires an OnSettingVisited event.
 /// </summary>
 /// <param name="elem">The graph element of which the specified flag is to be set.</param>
 /// <param name="visitorID">The id of the visited flag to be set.</param>
 /// <param name="newValue">The new value.</param>
 public void SettingVisited(IGraphElement elem, int visitorID, bool newValue)
 {
     SettingVisitedHandler setVisited = OnSettingVisited;
     if(setVisited != null) setVisited(elem, visitorID, newValue);
 }
コード例 #51
0
ファイル: BaseGraph.cs プロジェクト: jblomer/GrGen.NET
 public abstract void SetVisited(IGraphElement elem, int visitorID, bool visited);
コード例 #52
0
ファイル: BaseGraph.cs プロジェクト: jblomer/GrGen.NET
 public abstract bool IsInternallyVisited(IGraphElement elem, int threadId);
コード例 #53
0
ファイル: lgspGraph.cs プロジェクト: jblomer/GrGen.NET
 /// <summary>
 /// Returns whether the given graph element has been visited.
 /// </summary>
 /// <param name="elem">The graph element to be examined.</param>
 /// <param name="visitorID">The ID of the visited flag.</param>
 /// <returns>True for visited, false for not visited.</returns>
 public override bool IsVisited(IGraphElement elem, int visitorID)
 {
     if(visitorID < (int) LGSPElemFlags.NUM_SUPPORTED_VISITOR_IDS)        // id supported by flags?
     {
         uint mask = (uint) LGSPElemFlags.IS_VISITED << visitorID;
         LGSPNode node = elem as LGSPNode;
         if(node != null)
             return (node.lgspFlags & mask) != 0;
         else
         {
             LGSPEdge edge = (LGSPEdge) elem;
             return (edge.lgspFlags & mask) != 0;
         }
     }
     else                                                        // no, use hash map
     {
         return availableVisitors[visitorID].VisitedElements.ContainsKey(elem);
     }
 }
コード例 #54
0
		//Stolen from GXLExport.cs
		private string CanonizeElement (IGraphElement elem)
		{
				List<String> attributes = new List<String> ();
			foreach (AttributeType attrType in elem.Type.AttributeTypes) {
				object value = elem.GetAttribute (attrType.Name);
				
				String valType;
				String valuestr = (value == null) ? "" : value.ToString ();
				switch (attrType.Kind) {
				case AttributeKind.BooleanAttr:
					valType = "bool";
					valuestr = ((bool)value) ? "true" : "false";
					break;
					
				case AttributeKind.DoubleAttr:
				case AttributeKind.FloatAttr:
					valType = "double";
                    valuestr = ((double)value).ToString(System.Globalization.CultureInfo.InvariantCulture);
                    break;
					
				case AttributeKind.ByteAttr:
				case AttributeKind.ShortAttr:
				case AttributeKind.IntegerAttr:
				case AttributeKind.LongAttr:
					valType = "int";
					break;
					
				// TODO: This does not allow differentiating between empty and null strings
				case AttributeKind.StringAttr:
					valType = "string";
					valuestr= "\"" + valuestr + "\"";
					break;
					
				case AttributeKind.EnumAttr:
					valType = "enum";
					break;
					
				default:
					throw new Exception ("Unsupported attribute value type: \"" + attrType.Kind + "\"");
				}

				attributes.Add (attrType.Name + ":" + valType + ":" + valuestr);
			}

			attributes.Sort ((x,y) => x.CompareTo (y));
	
			string elemTypeName = null;
			string elemClassName = elem.GetType ().Name;

			if (elem is INode) {
				elemTypeName = "Node";
			} else if (elem is IEdge) {
				elemTypeName = "Edge";
			} else {
				elemTypeName = "Unsupported Graph Element Type";
			}

			StringBuilder sb = new StringBuilder (elemClassName + ":" + elemTypeName);

			if (attributes.Count > 0) {
				sb.Append (",");
				for (int i=0; i< (attributes.Count-1); i++) {
					sb.Append (attributes [i] + ",");
				}
			}

			if(attributes.Count > 0)
				sb.Append(attributes[attributes.Count-1]);

			return sb.ToString();
		}
コード例 #55
0
ファイル: lgspGraph.cs プロジェクト: jblomer/GrGen.NET
 /// <summary>
 /// Returns whether the given graph element has been internally visited.
 /// (Used for computing reachability.)
 /// </summary>
 /// <param name="elem">The graph element whose flag is to be retrieved.</param>
 /// <returns>True for visited, false for not visited.</returns>
 public override bool IsInternallyVisited(IGraphElement elem)
 {
     LGSPNode node = elem as LGSPNode;
     if(node != null)
         return (node.lgspFlags & (uint)LGSPElemFlags.IS_VISITED_INTERNALLY) == (uint)LGSPElemFlags.IS_VISITED_INTERNALLY;
     else
         return ((elem as LGSPEdge).lgspFlags & (uint)LGSPElemFlags.IS_VISITED_INTERNALLY) == (uint)LGSPElemFlags.IS_VISITED_INTERNALLY;
 }
コード例 #56
0
ファイル: YCompClient.cs プロジェクト: jblomer/GrGen.NET
 /// <summary>
 /// Annotates the given element with the given string in double angle brackets
 /// </summary>
 /// <param name="elem">The element to be annotated</param>
 /// <param name="annotation">The annotation string or null, if the annotation is to be removed</param>
 public void AnnotateElement(IGraphElement elem, String annotation)
 {
     if (elem is INode)
     {
         INode node = (INode)elem;
         if (IsNodeExcluded(node)) return;
         ycompStream.Write("setNodeLabel \"n" + graph.GetElementName(elem) + "\" \""
             + (annotation == null ? "" : "<<" + annotation + ">>\\n") + GetElemLabel(elem) + "\"\n");
     }
     else
     {
         IEdge edge = (IEdge)elem;
         if (IsEdgeExcluded(edge)) return;
         ycompStream.Write("setEdgeLabel \"e" + graph.GetElementName(elem) + "\" \""
             + (annotation == null ? "" : "<<" + annotation + ">>\\n") + GetElemLabel(elem) + "\"\n");
     }
     isDirty = true;
 }
コード例 #57
0
ファイル: lgspGraph.cs プロジェクト: jblomer/GrGen.NET
 /// <summary>
 /// Returns whether the given graph element has been internally visited.
 /// (Used for computing reachability when employed from a parallelized matcher executed by the thread pool.)
 /// </summary>
 /// <param name="elem">The graph element whose flag is to be retrieved.</param>
 /// <param name="threadId">The id of the thread which queries the marking of the graph element.</param>
 /// <returns>True for visited, false for not visited.</returns>
 public override bool IsInternallyVisited(IGraphElement elem, int threadId)
 {
     List<ushort> flagsPerElement = flagsPerThreadPerElement[threadId];
     LGSPNode node = elem as LGSPNode;
     if(node != null)
         return (flagsPerElement[node.uniqueId] & (ushort)LGSPElemFlagsParallel.IS_VISITED_INTERNALLY) == (ushort)LGSPElemFlagsParallel.IS_VISITED_INTERNALLY;
     else
         return (flagsPerElement[(elem as LGSPEdge).uniqueId] & (ushort)LGSPElemFlagsParallel.IS_VISITED_INTERNALLY) == (ushort)LGSPElemFlagsParallel.IS_VISITED_INTERNALLY;
 }
コード例 #58
0
ファイル: YCompClient.cs プロジェクト: jblomer/GrGen.NET
        public void RetypingElement(IGraphElement oldElem, IGraphElement newElem)
        {
            bool isNode = oldElem is INode;
            GrGenType oldType = oldElem.Type;
            GrGenType newType = newElem.Type;

            // TODO: Add element, if old element was excluded, but new element is not
            if(isNode)
            {
                INode oldNode = (INode) oldElem;
                if(IsNodeExcluded(oldNode)) return;
            }
            else
            {
                IEdge oldEdge = (IEdge) oldElem;
                if(IsEdgeExcluded(oldEdge)) return;
                if(hiddenEdges.ContainsKey(oldEdge)) return;       // TODO: Update group relation
            }

            String elemKind = isNode ? "Node" : "Edge";
            String elemNamePrefix = isNode ? "n" : "e";
            String oldName = elemNamePrefix + graph.GetElementName(oldElem);

            ycompStream.Write("set" + elemKind + "Label \"" + oldName + "\" \"" + GetElemLabel(newElem) + "\"\n");

            // remove the old attributes
            foreach(AttributeType attrType in oldType.AttributeTypes)
            {
                String attrTypeString;
                String attrValueString;
                EncodeAttr(attrType, oldElem, out attrTypeString, out attrValueString);
                ycompStream.Write("clear" + elemKind + "Attr \"" + oldName + "\" \"" + attrType.OwnerType.Name + "::" + attrType.Name + " : "
                    + attrTypeString + "\"\n");
            }
            // set the new attributes
            foreach(AttributeType attrType in newType.AttributeTypes)
            {
                String attrTypeString;
                String attrValueString;
                EncodeAttr(attrType, newElem, out attrTypeString, out attrValueString);
                ycompStream.Write("change" + elemKind + "Attr \"" + oldName + "\" \"" + attrType.OwnerType.Name + "::" + attrType.Name + " : "
                    + attrTypeString + "\" \"" + attrValueString + "\"\n");
            }

            if(isNode)
            {
                String oldNr = realizers.GetNodeRealizer((NodeType)oldType, dumpInfo);
                String newNr = realizers.GetNodeRealizer((NodeType)newType, dumpInfo);
                if(oldNr != newNr)
                    ChangeNode((INode) oldElem, newNr);
            }
            else
            {
                String oldEr = realizers.GetEdgeRealizer((EdgeType)oldType, dumpInfo);
                String newEr = realizers.GetEdgeRealizer((EdgeType)newType, dumpInfo);
                if(oldEr != newEr)
                    ChangeEdge((IEdge) oldElem, newEr);
            }

            String newName = elemNamePrefix + graph.GetElementName(newElem);
            ycompStream.Write("rename" + elemKind + " \"" + oldName + "\" \"" + newName + "\"\n");

            isDirty = true;
        }
コード例 #59
0
        public LGSPMatches myMatch(LGSPGraph graph, int maxMatches, IGraphElement[] parameters)
        {
            matches.matches.Clear();
            // Lookup(edge__edge0:connection)
            foreach(EdgeType edge_type_edge__edge0 in EdgeType_connection.typeVar.SubOrSameTypes)
            {
                for(LGSPEdge edge_head_edge__edge0 = graph.edgesByTypeHeads[edge_type_edge__edge0.TypeID], edge_cur_edge__edge0 = edge_head_edge__edge0.typeNext; edge_cur_edge__edge0 != edge_head_edge__edge0; edge_cur_edge__edge0 = edge_cur_edge__edge0.typeNext)
                {
                    // ImplicitTarget(edge__edge0 -> node_p2:Process)
                    LGSPNode node_cur_node_p2 = edge_cur_edge__edge0.target;
                    if(!NodeType_Process.isMyType[node_cur_node_p2.type.TypeID]) goto contunmap_edge_cur_edge__edge0_2;
                    node_cur_node_p2.mappedTo = 1;
                    // ImplicitSource(edge__edge0 -> node_p1:Process)
                    LGSPNode node_cur_node_p1 = edge_cur_edge__edge0.source;
                    if(!NodeType_Process.isMyType[node_cur_node_p1.type.TypeID]) goto contunmap_node_cur_node_p2_4;
                    if(node_cur_node_p1.mappedTo != 0) goto cont_node_cur_node_p1_7;
                    LGSPMatch match = matchesList.GetNewMatch();
                    match.nodes[0] = node_cur_node_p2;
                    match.nodes[1] = node_cur_node_p1;
                    match.edges[0] = edge_cur_edge__edge0;
                    matchesList.CommitMatch();
                    if(maxMatches > 0 && matchesList.Count >= maxMatches)
                    {
                        node_cur_node_p2.mappedTo = 0;
                        graph.MoveHeadAfter(edge_cur_edge__edge0);
                        return matches;
                    }
cont_node_cur_node_p1_7:;
contunmap_node_cur_node_p2_4:;
                    node_cur_node_p2.mappedTo = 0;
contunmap_edge_cur_edge__edge0_2:;
                    // Tail of Lookup(edge_cur_edge__edge0)
                }
            }
            return matches;
        }
コード例 #60
0
        public String _name; // for ToString only

        public LGSPUndoSettingVisited(IGraphElement elem, int visitorID, bool oldValue, LGSPGraphProcessingEnvironment procEnv)
        {
            _elem = elem;
            _visitorID = visitorID;
            _oldValue = oldValue;
            if(procEnv.graph is LGSPNamedGraph) _name = ((LGSPNamedGraph)procEnv.graph).GetElementName(_elem);
            else _name = "?";
        }