Example #1
0
        // You must implement this class in the same partial class in ./ExternalAttributeEvaluationModelExternalFunctionsImpl.cs:
        // You must implement the functions called by the following functions inside that class (same name plus suffix Impl):

        // Called during .grs import, at exactly the position in the text reader where the attribute begins.
        // For attribute type object or a user defined type, which is treated as object.
        // The implementation must parse from there on the attribute type requested.
        // It must not parse beyond the serialized representation of the attribute,
        // i.e. Peek() must return the first character not belonging to the attribute type any more.
        // Returns the parsed object.
        public static object Parse(TextReader reader, GRGEN_LIBGR.AttributeType attrType, GRGEN_LIBGR.IGraph graph)
        {
            return(ParseImpl(reader, attrType, graph));
            //reader.Read(); reader.Read(); reader.Read(); reader.Read(); // eat 'n' 'u' 'l' 'l' // default implementation
            //return null; // default implementation
        }
Example #2
0
 public override void FillIndexSetAsClone(GRGEN_LIBGR.IGraph graph, GRGEN_LIBGR.IGraph originalGraph, IDictionary <GRGEN_LIBGR.IGraphElement, GRGEN_LIBGR.IGraphElement> oldToNewMap)
 {
     ((StdIndexSet)graph.Indices).FillAsClone((GRGEN_LGSP.LGSPGraph)originalGraph, oldToNewMap);
 }
Example #3
0
 public override object[] ApplyProcedureMethod(GRGEN_LIBGR.IActionExecutionEnvironment actionEnv, GRGEN_LIBGR.IGraph graph, string name, object[] arguments)
 {
     switch (name)
     {
     default: throw new NullReferenceException("UEdge does not have the procedure method " + name + "!");
     }
 }
 public static GRGEN_LIBGR.INamedGraph AsGraphImpl(object attribute, GRGEN_LIBGR.AttributeType attrType, GRGEN_LIBGR.IGraph graph)
 {
     if (attribute is Own || attribute is OwnPown || attribute is OwnPownHome)
     {
         // here you would inspect the type and build the graph depending on the type, returning null for types not supported
         ExternalAttributeEvaluationNamedGraph ng = new ExternalAttributeEvaluationNamedGraph();
         N foo = ng.CreateNodeN("foo");
         foo.i = 42;
         Node bar = ng.CreateNodeNode("bar");
         E    baz = ng.CreateEdgeE(foo, bar, "baz");
         Edge qux = ng.CreateEdgeEdge(bar, bar, "qux");
         return(ng);
     }
     return(null);
 }
Example #5
0
 public void CreateAndBindIndexSet(GRGEN_LIBGR.IGraph graph)
 {
     ((GRGEN_LGSP.LGSPGraph)graph).indices = new StdIndexSet((GRGEN_LGSP.LGSPGraph)graph);
 }
Example #6
0
 // Called during debugging on user request, the implementation must return a named graph representation for the attribute.
 // For attribute type object or a user defined type, which is treated as object.
 // The attribute type may be null. The return graph must be of the same model as the graph handed in.
 // The named graph is meant for display in the debugger, to visualize the internal structure of some attribute type.
 // This way you can graphically inspect your own data types which are opaque to GrGen with its debugger.
 public static GRGEN_LIBGR.INamedGraph AsGraph(object attribute, GRGEN_LIBGR.AttributeType attrType, GRGEN_LIBGR.IGraph graph)
 {
     return(AsGraphImpl(attribute, attrType, graph));
     //return null; // default implementation
 }
        public static string EmitImpl(object attribute, GRGEN_LIBGR.AttributeType attrType, GRGEN_LIBGR.IGraph graph)
        {
            if (attribute == null)
            {
                return("null");
            }

            // important: if cascade from most specific to least specific, from subtypes to supertypes
            if (attribute.GetType() == typeof(OwnPownHome))
            {
                OwnPownHome   oph = (OwnPownHome)attribute;
                StringBuilder sb  = new StringBuilder();
                sb.Append("OwnPownHome { ehe: ");
                sb.Append(oph.ehe);
                sb.Append(" aha: ");
                sb.Append(oph.aha);
                sb.Append(" }");
                return(sb.ToString());
            }
            else if (attribute.GetType() == typeof(OwnPown))
            {
                OwnPown       op = (OwnPown)attribute;
                StringBuilder sb = new StringBuilder();
                sb.Append("OwnPown { ehe: ");
                sb.Append(op.ehe);
                sb.Append(" }");
                return(sb.ToString());
            }
            else if (attribute.GetType() == typeof(Own))
            {
                return("Own");
            }
            else
            {
                return(attribute.ToString());
            }
        }
Example #8
0
 public static int TestFunction(GRGEN_LIBGR.IActionExecutionEnvironment actionEnv, GRGEN_LIBGR.IGraph graph)
 {
     return(42);
 }
Example #9
0
 public static int TestFunction2(GRGEN_LIBGR.IActionExecutionEnvironment actionEnv, GRGEN_LIBGR.IGraph graph, string in_0)
 {
     return(42 + in_0.Length);
 }
Example #10
0
 public void External(string line, GRGEN_LIBGR.IGraph graph)
 {
     Console.Write("Ignoring: ");
     Console.WriteLine(line);
 }
Example #11
0
 public GRGEN_LIBGR.INamedGraph AsGraph(object attribute, GRGEN_LIBGR.AttributeType attrType, GRGEN_LIBGR.IGraph graph)
 {
     return(null);
 }
Example #12
0
 public string Emit(object attribute, GRGEN_LIBGR.AttributeType attrType, GRGEN_LIBGR.IGraph graph)
 {
     return(attribute != null?attribute.ToString() : "null");
 }
Example #13
0
 public string Serialize(object attribute, GRGEN_LIBGR.AttributeType attrType, GRGEN_LIBGR.IGraph graph)
 {
     Console.WriteLine("Warning: Exporting attribute of object type to null");
     return("null");
 }
Example #14
0
 public object Parse(TextReader reader, GRGEN_LIBGR.AttributeType attrType, GRGEN_LIBGR.IGraph graph)
 {
     reader.Read(); reader.Read(); reader.Read(); reader.Read();             // eat 'n' 'u' 'l' 'l'
     return(null);
 }
Example #15
0
 // Called during .grs export, the implementation must return a string representation for the attribute.
 // For attribute type object or a user defined type, which is treated as object.
 // The serialized string must be parseable by Parse.
 public static string Serialize(object attribute, GRGEN_LIBGR.AttributeType attrType, GRGEN_LIBGR.IGraph graph)
 {
     return(SerializeImpl(attribute, attrType, graph));
     //Console.WriteLine("Warning: Exporting attribute of object type to null"); // default implementation
     //return "null"; // default implementation
 }
Example #16
0
 public static void TestProcedure(GRGEN_LIBGR.IActionExecutionEnvironment actionEnv, GRGEN_LIBGR.IGraph graph)
 {
     graph.AddNode(graph.Model.NodeModel.GetType("Node"));
 }
Example #17
0
 // Called during debugging or emit writing, the implementation must return a string representation for the attribute.
 // For attribute type object or a user defined type, which is treated as object.
 // The attribute type may be null.
 // The string is meant for consumption by humans, it does not need to be parseable.
 public static string Emit(object attribute, GRGEN_LIBGR.AttributeType attrType, GRGEN_LIBGR.IGraph graph)
 {
     return(EmitImpl(attribute, attrType, graph));
     //return "null"; // default implementation
 }
Example #18
0
 public static void TestProcedure2(GRGEN_LIBGR.IActionExecutionEnvironment actionEnv, GRGEN_LIBGR.IGraph graph, string in_0, out int out_0)
 {
     out_0 = in_0.Length;
 }
        public static string SerializeImpl(object attribute, GRGEN_LIBGR.AttributeType attrType, GRGEN_LIBGR.IGraph graph)
        {
            if (attribute == null)
            {
                // attrType.Kind is always ObjectAttr
                if (attrType.Type == typeof(OwnPownHome))
                {
                    return("null");
                }
                else if (attrType.Type == typeof(OwnPown))
                {
                    return("null");
                }
                else if (attrType.Type == typeof(Own))
                {
                    return("null");
                }
                return("null");
            }

            // important: if cascade from most specific to least specific, from subtypes to supertypes
            if (attribute.GetType() == typeof(OwnPownHome))
            {
                OwnPownHome   oph = (OwnPownHome)attribute;
                StringBuilder sb  = new StringBuilder();
                sb.Append("h");
                sb.Append(oph.ehe);
                sb.Append(";");
                sb.Append(oph.aha);
                return(sb.ToString());
            }
            else if (attribute.GetType() == typeof(OwnPown))
            {
                OwnPown       op = (OwnPown)attribute;
                StringBuilder sb = new StringBuilder();
                sb.Append("p");
                sb.Append(op.ehe);
                return(sb.ToString());
            }
            else if (attribute.GetType() == typeof(Own))
            {
                return("o");
            }
            else
            {
                Console.WriteLine("Warning: Exporting attribute of object type to null");
                return("null");
            }
        }
Example #20
0
 public override GRGEN_LIBGR.IUniquenessHandler CreateUniquenessHandler(GRGEN_LIBGR.IGraph graph)
 {
     return(null);
 }
 public static void ExternalImpl(string line, GRGEN_LIBGR.IGraph graph)
 {
     Console.Write("Ignoring: "); // default implementation
     Console.WriteLine(line);     // default implementation
 }
Example #22
0
 public override GRGEN_LIBGR.IIndexSet CreateIndexSet(GRGEN_LIBGR.IGraph graph)
 {
     return(new StdIndexSet((GRGEN_LGSP.LGSPGraph)graph));
 }
 public string fn(GRGEN_LIBGR.IActionExecutionEnvironment actionEnv_, GRGEN_LIBGR.IGraph graph_, string var_ss)
 {
     return(ehe);
 }
Example #24
0
 public static void externalProcedure(GRGEN_LIBGR.IActionExecutionEnvironment actionEnv, GRGEN_LIBGR.IGraph graph)
 {
 }