Made finding the ID of a JsonSerializable less ugly
authorDaniel Kirschten <daniel.kirschten@gmx.de>
Wed, 4 Sep 2019 20:26:09 +0000 (22:26 +0200)
committerDaniel Kirschten <daniel.kirschten@gmx.de>
Wed, 4 Sep 2019 20:26:09 +0000 (22:26 +0200)
49 files changed:
net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/GUIdff12.java
net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/GUIdff4_finewe.java
net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/GUIinc12.java
net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/GUInor12.java
net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/GUIram5_12.java
net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/GUIsel4_12.java
net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/am2904/GUIAm2904RegCTInstrDecode.java
net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/am2904/GUIAm2904ShiftInstrDecode.java
net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/am2910/GUIAm2910InstrPLA.java
net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/am2910/GUIAm2910RegCntr.java
net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/components/am2910/GUIAm2910SP.java
net.mograsim.logic.model.am2900/test/net/mograsim/logic/model/am2900/am2904/Am2904Testbench.java
net.mograsim.logic.model.editor/src/net/mograsim/logic/model/editor/Editor.java
net.mograsim.logic.model.editor/src/net/mograsim/logic/model/editor/handles/ComponentHandle.java
net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/GUIComponent.java
net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/GUIAndGate.java
net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/GUIBitDisplay.java
net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/GUIClock.java
net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/GUIManualSwitch.java
net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/GUIMerger.java
net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/GUINandGate.java
net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/GUINotGate.java
net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/GUIOrGate.java
net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/GUISplitter.java
net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/GUITriStateBuffer.java
net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/SimpleRectangularGUIGate.java
net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/SimpleRectangularHardcodedGUIComponent.java
net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/TextComponent.java
net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/submodels/SubmodelComponent.java
net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/submodels/SubmodelInterface.java
net.mograsim.logic.model/src/net/mograsim/logic/model/model/wires/WireCrossPoint.java
net.mograsim.logic.model/src/net/mograsim/logic/model/serializing/IdentifierGetter.java [deleted file]
net.mograsim.logic.model/src/net/mograsim/logic/model/serializing/IdentifyParams.java [new file with mode: 0644]
net.mograsim.logic.model/src/net/mograsim/logic/model/serializing/JSONSerializable.java
net.mograsim.logic.model/src/net/mograsim/logic/model/serializing/LegacySubmodelComponentSerializer.java
net.mograsim.logic.model/src/net/mograsim/logic/model/serializing/SubmodelComponentSerializer.java
net.mograsim.logic.model/src/net/mograsim/logic/model/serializing/ViewModelSerializer.java
net.mograsim.logic.model/src/net/mograsim/logic/model/snippets/highlevelstatehandlers/DefaultHighLevelStateHandler.java
net.mograsim.logic.model/src/net/mograsim/logic/model/snippets/highlevelstatehandlers/standard/StandardHighLevelStateHandler.java
net.mograsim.logic.model/src/net/mograsim/logic/model/snippets/highlevelstatehandlers/standard/atomic/BitVectorSplittingAtomicHighLevelStateHandler.java
net.mograsim.logic.model/src/net/mograsim/logic/model/snippets/highlevelstatehandlers/standard/atomic/DelegatingAtomicHighLevelStateHandler.java
net.mograsim.logic.model/src/net/mograsim/logic/model/snippets/highlevelstatehandlers/standard/atomic/WireForcingAtomicHighLevelStateHandler.java
net.mograsim.logic.model/src/net/mograsim/logic/model/snippets/highlevelstatehandlers/standard/subcomponent/DelegatingSubcomponentHighLevelStateHandler.java
net.mograsim.logic.model/src/net/mograsim/logic/model/snippets/outlinerenderers/DefaultOutlineRenderer.java
net.mograsim.logic.model/src/net/mograsim/logic/model/snippets/symbolrenderers/CenteredTextSymbolRenderer.java
net.mograsim.logic.model/src/net/mograsim/logic/model/snippets/symbolrenderers/DefaultSymbolRenderer.java
net.mograsim.logic.model/src/net/mograsim/logic/model/snippets/symbolrenderers/PinNamesSymbolRenderer.java
net.mograsim.logic.model/src/net/mograsim/logic/model/snippets/symbolrenderers/SimpleRectangularLikeSymbolRenderer.java
net.mograsim.machine/src/net/mograsim/machine/standard/memory/GUIMemoryWA.java

index 503831d..03e26d4 100644 (file)
@@ -22,7 +22,7 @@ public class GUIdff12 extends SimpleRectangularHardcodedGUIComponent
 {
        public GUIdff12(ViewModelModifiable model, String name)
        {
-               super(model, name, "D flip flop\n12 bits");
+               super(model, "GUIdff12", name, "D flip flop\n12 bits");
                setSize(40, 20);
                addPin(new Pin(this, "D", 12, PinUsage.INPUT, 20, 20), Position.TOP);
                addPin(new Pin(this, "C", 1, PinUsage.INPUT, 0, 10), Position.RIGHT);
index dec8f63..6c857b6 100644 (file)
@@ -24,7 +24,7 @@ public class GUIdff4_finewe extends SimpleRectangularHardcodedGUIComponent
 {
        public GUIdff4_finewe(ViewModelModifiable model, String name)
        {
-               super(model, name, "D flip flop\n4 bits");
+               super(model, "GUIdff4_finewe", name, "D flip flop\n4 bits");
                setSize(35, 90);
                addPin(new Pin(this, "C", 1, PinUsage.INPUT, 0, 5), Position.RIGHT);
                addPin(new Pin(this, "_WE1", 1, PinUsage.INPUT, 0, 15), Position.RIGHT);
index c3848d4..744b326 100644 (file)
@@ -22,7 +22,7 @@ public class GUIinc12 extends SimpleRectangularHardcodedGUIComponent
 {
        public GUIinc12(ViewModelModifiable model, String name)
        {
-               super(model, name, "Incrementer");
+               super(model, "GUIinc12", name, "Incrementer");
                setSize(40, 20);
                addPin(new Pin(this, "A", 12, PinUsage.INPUT, 20, 20), Position.TOP);
                addPin(new Pin(this, "CI", 1, PinUsage.INPUT, 40, 10), Position.LEFT);
index 1948c67..3ceb01c 100644 (file)
@@ -22,7 +22,7 @@ public class GUInor12 extends SimpleRectangularHardcodedGUIComponent
 {
        public GUInor12(ViewModelModifiable model, String name)
        {
-               super(model, name, "=0");
+               super(model, "GUInor12", name, "=0");
                setSize(35, 20);
                addPin(new Pin(this, "D", 12, PinUsage.INPUT, 0, 10), Position.RIGHT);
                addPin(new Pin(this, "Y", 1, PinUsage.OUTPUT, 35, 10), Position.LEFT);
index 7a1409e..f46b68d 100644 (file)
@@ -26,7 +26,7 @@ public class GUIram5_12 extends SimpleRectangularHardcodedGUIComponent
 {
        public GUIram5_12(ViewModelModifiable model, String name)
        {
-               super(model, name, "RAM\n5 x 12 Bit");
+               super(model, "GUIram5_12", name, "RAM\n5 x 12 Bit");
                setSize(40, 40);
                addPin(new Pin(this, "A", 3, PinUsage.INPUT, 10, 0), Position.BOTTOM);
                addPin(new Pin(this, "B", 3, PinUsage.INPUT, 30, 0), Position.BOTTOM);
index ee7bc0e..17b70a5 100644 (file)
@@ -23,7 +23,7 @@ public class GUIsel4_12 extends SimpleRectangularHardcodedGUIComponent
 {
        public GUIsel4_12(ViewModelModifiable model, String name)
        {
-               super(model, name, "4-way SEL\n12 bit");
+               super(model, "GUIsel4_12", name, "4-way SEL\n12 bit");
                setSize(80, 40);
                addPin(new Pin(this, "SA", 1, PinUsage.INPUT, 0, 5), Position.RIGHT);
                addPin(new Pin(this, "SB", 1, PinUsage.INPUT, 0, 15), Position.RIGHT);
index 447fef6..664893b 100644 (file)
@@ -22,7 +22,7 @@ public class GUIAm2904RegCTInstrDecode extends SimpleRectangularHardcodedGUIComp
 {
        public GUIAm2904RegCTInstrDecode(ViewModelModifiable model, String name)
        {
-               super(model, name, "Instruction\ndecode");
+               super(model, "GUIAm2904RegCTInstrDecode", name, "Instruction\ndecode");
                setSize(80, 80);
                addPin(new Pin(this, "I12-11", 2, PinUsage.INPUT, 0, 30), Position.RIGHT);
                addPin(new Pin(this, "I5-0", 6, PinUsage.INPUT, 0, 50), Position.RIGHT);
index dae7ae4..04dc933 100644 (file)
@@ -23,7 +23,7 @@ public class GUIAm2904ShiftInstrDecode extends SimpleRectangularHardcodedGUIComp
 {
        public GUIAm2904ShiftInstrDecode(ViewModelModifiable model, String name)
        {
-               super(model, name, "Shift \ninstruction\ndecode");
+               super(model, "GUIAm2904ShiftInstrDecode", name, "Shift \ninstruction\ndecode");
                setSize(60, 80);
                addPin(new Pin(this, "I", 5, PinUsage.INPUT, 0, 25), Position.RIGHT);
                addPin(new Pin(this, "_SE", 1, PinUsage.INPUT, 0, 55), Position.RIGHT);
index 5ae7240..960cc74 100644 (file)
@@ -21,7 +21,7 @@ public class GUIAm2910InstrPLA extends SimpleRectangularHardcodedGUIComponent
 {
        public GUIAm2910InstrPLA(ViewModelModifiable model, String name)
        {
-               super(model, name, "Instr.\nPLA");
+               super(model, "GUIAm2910InstrPLA", name, "Instr.\nPLA");
                setSize(30, 85);
                addPin(new Pin(this, "PASS", 1, PinUsage.INPUT, 0, 5), Position.RIGHT);
                addPin(new Pin(this, "I", 4, PinUsage.INPUT, 0, 20), Position.RIGHT);
index 00635bf..8451327 100644 (file)
@@ -22,7 +22,7 @@ public class GUIAm2910RegCntr extends SimpleRectangularHardcodedGUIComponent
 {
        public GUIAm2910RegCntr(ViewModelModifiable model, String name)
        {
-               super(model, name, "Register/\nCounter");
+               super(model, "GUIAm2910RegCntr", name, "Register/\nCounter");
                setSize(40, 40);
                addPin(new Pin(this, "D", 12, PinUsage.INPUT, 20, 0), Position.BOTTOM);
                addPin(new Pin(this, "_RLD", 1, PinUsage.INPUT, 0, 5), Position.RIGHT);
index 0e89cca..cbd4251 100644 (file)
@@ -22,7 +22,7 @@ public class GUIAm2910SP extends SimpleRectangularHardcodedGUIComponent
 {
        public GUIAm2910SP(ViewModelModifiable model, String name)
        {
-               super(model, name, "Stack\npointer");
+               super(model, "GUIAm2910SP", name, "Stack\npointer");
                setSize(40, 30);
                addPin(new Pin(this, "STKI0", 1, PinUsage.INPUT, 0, 5), Position.RIGHT);
                addPin(new Pin(this, "STKI1", 1, PinUsage.INPUT, 0, 15), Position.RIGHT);
index 3999966..dcf0569 100644 (file)
@@ -11,7 +11,7 @@ import net.mograsim.logic.model.model.ViewModelModifiable;
 import net.mograsim.logic.model.model.components.atomic.GUIManualSwitch;
 import net.mograsim.logic.model.model.components.submodels.SubmodelComponent;
 import net.mograsim.logic.model.serializing.DeserializedSubmodelComponent;
-import net.mograsim.logic.model.serializing.IdentifierGetter;
+import net.mograsim.logic.model.serializing.IdentifyParams;
 import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator;
 import net.mograsim.logic.model.snippets.Renderer;
 
@@ -32,7 +32,13 @@ public class Am2904Testbench
                testbench.setOutlineRenderer(new Renderer()
                {
                        @Override
-                       public Void getParamsForSerializing(IdentifierGetter idGetter)
+                       public String getIDForSerializing(IdentifyParams idParams)
+                       {
+                               return null;
+                       }
+
+                       @Override
+                       public Void getParamsForSerializing(IdentifyParams idParams)
                        {
                                return null;
                        }
index c0a504a..903f882 100644 (file)
@@ -25,7 +25,7 @@ import net.mograsim.logic.model.model.ViewModelModifiable;
 import net.mograsim.logic.model.model.components.GUIComponent;
 import net.mograsim.logic.model.model.wires.GUIWire;
 import net.mograsim.logic.model.serializing.DeserializedSubmodelComponent;
-import net.mograsim.logic.model.serializing.IdentifierGetter;
+import net.mograsim.logic.model.serializing.IdentifyParams;
 import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator;
 
 public final class Editor
@@ -179,7 +179,7 @@ public final class Editor
        {
                if (identifierPerComponent.containsKey(c))
                        return identifierPerComponent.get(c);
-               return new IdentifierGetter().componentIDs.apply(c);
+               return c.getIDForSerializing(new IdentifyParams());
        }
 
        public void duplicate()
index 8712ca6..5fe0aa4 100644 (file)
@@ -12,7 +12,7 @@ import net.mograsim.logic.model.editor.Editor;
 import net.mograsim.logic.model.editor.Editor.ComponentInfo;
 import net.mograsim.logic.model.model.ViewModelModifiable;
 import net.mograsim.logic.model.model.components.GUIComponent;
-import net.mograsim.logic.model.serializing.IdentifierGetter;
+import net.mograsim.logic.model.serializing.IdentifyParams;
 
 public class ComponentHandle extends Handle
 {
@@ -90,7 +90,7 @@ public class ComponentHandle extends Handle
        public Optional<ComponentInfo> reqCopy(Point refPoint)
        {
                return Optional.of(new ComponentInfo(parent.getPosX() - refPoint.x, parent.getPosY() - refPoint.y, Editor.getIdentifier(parent),
-                               parent.getParamsForSerializingJSON(new IdentifierGetter())));
+                               parent.getParamsForSerializingJSON(new IdentifyParams())));
        }
 
        @Override
index 2e4d768..6358260 100644 (file)
@@ -11,7 +11,7 @@ import net.haspamelodica.swt.helper.gcs.GeneralGC;
 import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle;
 import net.mograsim.logic.model.model.ViewModelModifiable;
 import net.mograsim.logic.model.model.wires.Pin;
-import net.mograsim.logic.model.serializing.IdentifierGetter;
+import net.mograsim.logic.model.serializing.IdentifyParams;
 import net.mograsim.logic.model.serializing.JSONSerializable;
 import net.mograsim.logic.model.snippets.HighLevelStateHandler;
 
@@ -286,7 +286,7 @@ public abstract class GUIComponent implements JSONSerializable
        // serializing
 
        @Override
-       public Object getParamsForSerializing(IdentifierGetter idGetter)
+       public Object getParamsForSerializing(IdentifyParams idParams)
        {
                return null;
        }
index 5859f1f..f9fd506 100644 (file)
@@ -15,7 +15,7 @@ public class GUIAndGate extends SimpleRectangularGUIGate
 
        public GUIAndGate(ViewModelModifiable model, int logicWidth, String name)
        {
-               super(model, "&", false, logicWidth, name);
+               super(model, "GUIAndGate", "&", false, logicWidth, name);
                setInputCount(2);// TODO make variable
        }
 
index 0115309..8d96d0a 100644 (file)
@@ -15,7 +15,7 @@ import net.mograsim.logic.model.model.wires.Pin;
 import net.mograsim.logic.model.model.wires.PinUsage;
 import net.mograsim.logic.model.modeladapter.ViewLogicModelAdapter;
 import net.mograsim.logic.model.modeladapter.componentadapters.BitDisplayAdapter;
-import net.mograsim.logic.model.serializing.IdentifierGetter;
+import net.mograsim.logic.model.serializing.IdentifyParams;
 import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator;
 import net.mograsim.preferences.Preferences;
 
@@ -91,7 +91,13 @@ public class GUIBitDisplay extends GUIComponent
        }
 
        @Override
-       public Integer getParamsForSerializing(IdentifierGetter idGetter)
+       public String getIDForSerializing(IdentifyParams idParams)
+       {
+               return "GUIBitDisplay";
+       }
+
+       @Override
+       public Integer getParamsForSerializing(IdentifyParams idParams)
        {
                return logicWidth;
        }
index a3ff96c..ffc1115 100644 (file)
@@ -18,7 +18,7 @@ import net.mograsim.logic.model.model.wires.Pin;
 import net.mograsim.logic.model.model.wires.PinUsage;
 import net.mograsim.logic.model.modeladapter.ViewLogicModelAdapter;
 import net.mograsim.logic.model.modeladapter.componentadapters.ClockAdapter;
-import net.mograsim.logic.model.serializing.IdentifierGetter;
+import net.mograsim.logic.model.serializing.IdentifyParams;
 import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator;
 import net.mograsim.logic.model.util.JsonHandler;
 import net.mograsim.preferences.Preferences;
@@ -129,7 +129,13 @@ public class GUIClock extends GUIComponent
        }
 
        @Override
-       public GUIClockParams getParamsForSerializing(IdentifierGetter idGetter)
+       public String getIDForSerializing(IdentifyParams idParams)
+       {
+               return "GUIClock";
+       }
+
+       @Override
+       public GUIClockParams getParamsForSerializing(IdentifyParams idParams)
        {
                return params;
        }
index e9853a1..fce4fff 100644 (file)
@@ -17,7 +17,7 @@ import net.mograsim.logic.model.model.wires.Pin;
 import net.mograsim.logic.model.model.wires.PinUsage;
 import net.mograsim.logic.model.modeladapter.ViewLogicModelAdapter;
 import net.mograsim.logic.model.modeladapter.componentadapters.ManualSwitchAdapter;
-import net.mograsim.logic.model.serializing.IdentifierGetter;
+import net.mograsim.logic.model.serializing.IdentifyParams;
 import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator;
 import net.mograsim.preferences.Preferences;
 
@@ -163,7 +163,13 @@ public class GUIManualSwitch extends GUIComponent
        }
 
        @Override
-       public Integer getParamsForSerializing(IdentifierGetter idGetter)
+       public String getIDForSerializing(IdentifyParams idParams)
+       {
+               return "GUIManualSwitch";
+       }
+
+       @Override
+       public Integer getParamsForSerializing(IdentifyParams idParams)
        {
                return logicWidth;
        }
index 345e360..d7ec677 100644 (file)
@@ -12,7 +12,7 @@ import net.mograsim.logic.model.model.wires.Pin;
 import net.mograsim.logic.model.model.wires.PinUsage;
 import net.mograsim.logic.model.modeladapter.ViewLogicModelAdapter;
 import net.mograsim.logic.model.modeladapter.componentadapters.MergerAdapter;
-import net.mograsim.logic.model.serializing.IdentifierGetter;
+import net.mograsim.logic.model.serializing.IdentifyParams;
 import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator;
 import net.mograsim.preferences.ColorDefinition;
 import net.mograsim.preferences.ColorManager;
@@ -80,7 +80,13 @@ public class GUIMerger extends GUIComponent
        }
 
        @Override
-       public Integer getParamsForSerializing(IdentifierGetter idGetter)
+       public String getIDForSerializing(IdentifyParams idParams)
+       {
+               return "GUIMerger";
+       }
+
+       @Override
+       public Integer getParamsForSerializing(IdentifyParams idParams)
        {
                return logicWidth;
        }
index 1d8f63d..0a8b04d 100644 (file)
@@ -15,7 +15,7 @@ public class GUINandGate extends SimpleRectangularGUIGate
 
        public GUINandGate(ViewModelModifiable model, int logicWidth, String name)
        {
-               super(model, "&", true, logicWidth, name);
+               super(model, "GUINandGate", "&", true, logicWidth, name);
                setInputCount(2);// TODO make variable
        }
 
index 5dc6938..f9fcb4f 100644 (file)
@@ -15,7 +15,7 @@ public class GUINotGate extends SimpleRectangularGUIGate
 
        public GUINotGate(ViewModelModifiable model, int logicWidth, String name)
        {
-               super(model, "1", true, logicWidth, name);
+               super(model, "GUINotGate", "1", true, logicWidth, name);
                setInputCount(1);
        }
 
index 65031a6..f1bd1cc 100644 (file)
@@ -15,7 +15,7 @@ public class GUIOrGate extends SimpleRectangularGUIGate
 
        public GUIOrGate(ViewModelModifiable model, int logicWidth, String name)
        {
-               super(model, "\u22651", false, logicWidth, name);// ">=1"
+               super(model, "GUIOrGate", "\u22651", false, logicWidth, name);// ">=1"
                setInputCount(2);
        }
 
index 635c790..43b744e 100644 (file)
@@ -12,7 +12,7 @@ import net.mograsim.logic.model.model.wires.Pin;
 import net.mograsim.logic.model.model.wires.PinUsage;
 import net.mograsim.logic.model.modeladapter.ViewLogicModelAdapter;
 import net.mograsim.logic.model.modeladapter.componentadapters.SplitterAdapter;
-import net.mograsim.logic.model.serializing.IdentifierGetter;
+import net.mograsim.logic.model.serializing.IdentifyParams;
 import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator;
 import net.mograsim.preferences.ColorDefinition;
 import net.mograsim.preferences.ColorManager;
@@ -80,7 +80,13 @@ public class GUISplitter extends GUIComponent
        }
 
        @Override
-       public Integer getParamsForSerializing(IdentifierGetter idGetter)
+       public String getIDForSerializing(IdentifyParams idParams)
+       {
+               return "GUISplitter";
+       }
+
+       @Override
+       public Integer getParamsForSerializing(IdentifyParams idParams)
        {
                return logicWidth;
        }
index 8900b6e..7f04102 100644 (file)
@@ -14,7 +14,7 @@ import net.mograsim.logic.model.model.wires.Pin;
 import net.mograsim.logic.model.model.wires.PinUsage;
 import net.mograsim.logic.model.modeladapter.ViewLogicModelAdapter;
 import net.mograsim.logic.model.modeladapter.componentadapters.TriStateBufferAdapter;
-import net.mograsim.logic.model.serializing.IdentifierGetter;
+import net.mograsim.logic.model.serializing.IdentifyParams;
 import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator;
 import net.mograsim.logic.model.util.JsonHandler;
 import net.mograsim.preferences.Preferences;
@@ -87,7 +87,13 @@ public class GUITriStateBuffer extends GUIComponent
        }
 
        @Override
-       public GUITriStateBufferParams getParamsForSerializing(IdentifierGetter idGetter)
+       public String getIDForSerializing(IdentifyParams idParams)
+       {
+               return "GUITriStateBuffer";
+       }
+
+       @Override
+       public GUITriStateBufferParams getParamsForSerializing(IdentifyParams idParams)
        {
                return params;
        }
index 86582c7..9b72cb6 100644 (file)
@@ -16,7 +16,7 @@ import net.mograsim.logic.model.model.components.GUIComponent;
 import net.mograsim.logic.model.model.wires.MovablePin;
 import net.mograsim.logic.model.model.wires.Pin;
 import net.mograsim.logic.model.model.wires.PinUsage;
-import net.mograsim.logic.model.serializing.IdentifierGetter;
+import net.mograsim.logic.model.serializing.IdentifyParams;
 import net.mograsim.preferences.Preferences;
 
 public class SimpleRectangularGUIGate extends GUIComponent
@@ -26,6 +26,8 @@ public class SimpleRectangularGUIGate extends GUIComponent
        private static final double fontHeight = 5;
        private static final double invertedCircleDiam = 3.5;
 
+       private final String id;
+
        private final String label;
        private final boolean isInverted;
        protected final int logicWidth;
@@ -34,9 +36,10 @@ public class SimpleRectangularGUIGate extends GUIComponent
        private MovablePin outputPin;
        private final List<Pin> inputPins;
 
-       protected SimpleRectangularGUIGate(ViewModelModifiable model, String label, boolean isInverted, int logicWidth, String name)
+       protected SimpleRectangularGUIGate(ViewModelModifiable model, String id, String label, boolean isInverted, int logicWidth, String name)
        {
                super(model, name);
+               this.id = id;
                this.label = label;
                this.logicWidth = logicWidth;
                this.isInverted = isInverted;
@@ -88,6 +91,12 @@ public class SimpleRectangularGUIGate extends GUIComponent
 
        // serializing
 
+       @Override
+       public String getIDForSerializing(IdentifyParams idParams)
+       {
+               return id;
+       }
+
        /**
         * {@link SimpleRectangularGUIGate}s implementation returns a {@link JsonPrimitive} of type int containing the {@link #logicWidth} of
         * this component.
@@ -95,7 +104,7 @@ public class SimpleRectangularGUIGate extends GUIComponent
         * @see GUIComponent#getParamsForSerializing()
         */
        @Override
-       public Integer getParamsForSerializing(IdentifierGetter idGetter)
+       public Integer getParamsForSerializing(IdentifyParams idParams)
        {
                return logicWidth;
        }
index c06ec14..b79b2e9 100644 (file)
@@ -12,7 +12,7 @@ import net.mograsim.logic.model.model.components.GUIComponent;
 import net.mograsim.logic.model.model.wires.Pin;
 import net.mograsim.logic.model.modeladapter.ViewLogicModelAdapter;
 import net.mograsim.logic.model.modeladapter.componentadapters.SimpleRectangularHardcodedGUIComponentAdapter;
-import net.mograsim.logic.model.serializing.IdentifierGetter;
+import net.mograsim.logic.model.serializing.IdentifyParams;
 import net.mograsim.logic.model.snippets.HighLevelStateHandler;
 import net.mograsim.logic.model.snippets.outlinerenderers.DefaultOutlineRenderer;
 import net.mograsim.logic.model.snippets.symbolrenderers.CenteredTextSymbolRenderer;
@@ -27,6 +27,8 @@ public abstract class SimpleRectangularHardcodedGUIComponent extends GUIComponen
        private static final double pinNamesHeight = 3.5;
        private static final double pinNamesMargin = .5;
 
+       private final String id;
+
        private final DefaultOutlineRenderer outlineRenderer;
        private final CenteredTextSymbolRenderer centerTextRenderer;
        private final PinNamesSymbolRenderer pinNamesRenderer;
@@ -36,9 +38,10 @@ public abstract class SimpleRectangularHardcodedGUIComponent extends GUIComponen
 
        // creation and destruction
 
-       public SimpleRectangularHardcodedGUIComponent(ViewModelModifiable model, String name, String centerText)
+       public SimpleRectangularHardcodedGUIComponent(ViewModelModifiable model, String id, String name, String centerText)
        {
                super(model, name);
+               this.id = id;
                this.outlineRenderer = new DefaultOutlineRenderer(this);
                CenteredTextParams centeredTextParams = new CenteredTextParams();
                centeredTextParams.text = centerText;
@@ -52,7 +55,13 @@ public abstract class SimpleRectangularHardcodedGUIComponent extends GUIComponen
                setHighLevelStateHandler(new HighLevelStateHandler()
                {
                        @Override
-                       public Object getParamsForSerializing(IdentifierGetter idGetter)
+                       public String getIDForSerializing(IdentifyParams idParams)
+                       {
+                               return null;// we don't need to serialize this; it's implicit since we are a SimpleRectangularHardcodedGUIComponent
+                       }
+
+                       @Override
+                       public Object getParamsForSerializing(IdentifyParams idParams)
                        {
                                return null;
                        }
@@ -121,6 +130,14 @@ public abstract class SimpleRectangularHardcodedGUIComponent extends GUIComponen
                pinNamesRenderer.render(gc, visibleRegion);
        }
 
+       // serializing
+
+       @Override
+       public String getIDForSerializing(IdentifyParams idParams)
+       {
+               return id;
+       }
+
        // operations no longer supported
 
        @Override
index d46acb8..f250702 100644 (file)
@@ -9,7 +9,7 @@ import net.mograsim.logic.model.model.ViewModelModifiable;
 import net.mograsim.logic.model.model.components.GUIComponent;
 import net.mograsim.logic.model.modeladapter.ViewLogicModelAdapter;
 import net.mograsim.logic.model.modeladapter.componentadapters.NoLogicAdapter;
-import net.mograsim.logic.model.serializing.IdentifierGetter;
+import net.mograsim.logic.model.serializing.IdentifyParams;
 import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator;
 import net.mograsim.preferences.Preferences;
 
@@ -52,7 +52,13 @@ public class TextComponent extends GUIComponent
        // serializing
 
        @Override
-       public String getParamsForSerializing(IdentifierGetter idGetter)
+       public String getIDForSerializing(IdentifyParams idParams)
+       {
+               return "TextComponent";
+       }
+
+       @Override
+       public String getParamsForSerializing(IdentifyParams idParams)
        {
                return text;
        }
index 46d5945..f67be7d 100644 (file)
@@ -17,7 +17,7 @@ import net.mograsim.logic.model.model.components.GUIComponent;
 import net.mograsim.logic.model.model.wires.MovablePin;
 import net.mograsim.logic.model.model.wires.Pin;
 import net.mograsim.logic.model.model.wires.PinUsage;
-import net.mograsim.logic.model.serializing.IdentifierGetter;
+import net.mograsim.logic.model.serializing.IdentifyParams;
 import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator;
 import net.mograsim.logic.model.serializing.SubmodelComponentParams;
 import net.mograsim.logic.model.serializing.SubmodelComponentSerializer;
@@ -422,9 +422,15 @@ public abstract class SubmodelComponent extends GUIComponent
        // serializing
 
        @Override
-       public SubmodelComponentParams getParamsForSerializing(IdentifierGetter idGetter)
+       public String getIDForSerializing(IdentifyParams idParams)
        {
-               return SubmodelComponentSerializer.serialize(this, idGetter);
+               return "submodel";// TODO what ID?
+       }
+
+       @Override
+       public SubmodelComponentParams getParamsForSerializing(IdentifyParams idParams)
+       {
+               return SubmodelComponentSerializer.serialize(this, idParams);
        }
 
        // operations no longer supported
index 9ac1749..9c4c46d 100644 (file)
@@ -5,6 +5,7 @@ import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle;
 import net.mograsim.logic.model.model.ViewModelModifiable;
 import net.mograsim.logic.model.model.components.GUIComponent;
 import net.mograsim.logic.model.model.wires.Pin;
+import net.mograsim.logic.model.serializing.IdentifyParams;
 
 public class SubmodelInterface extends GUIComponent
 {
@@ -18,6 +19,12 @@ public class SubmodelInterface extends GUIComponent
        {// nothing to do here
        }
 
+       @Override
+       public String getIDForSerializing(IdentifyParams idParams)
+       {
+               throw new UnsupportedOperationException("A SubmodelInterface can't be serialized. Use SubmodelComponent.addSubmodelInterface");
+       }
+
        /**
         * {@inheritDoc}<br>
         * This method is only marked public in {@link SubmodelInterface} for {@link SubmodelComponent} to be able to add / remove pins to /
index d558daa..7d31801 100644 (file)
@@ -7,7 +7,7 @@ import net.mograsim.logic.core.types.BitVectorFormatter;
 import net.mograsim.logic.core.wires.Wire.ReadEnd;
 import net.mograsim.logic.model.model.ViewModelModifiable;
 import net.mograsim.logic.model.model.components.GUIComponent;
-import net.mograsim.logic.model.serializing.IdentifierGetter;
+import net.mograsim.logic.model.serializing.IdentifyParams;
 import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator;
 import net.mograsim.preferences.ColorDefinition;
 import net.mograsim.preferences.ColorManager;
@@ -118,7 +118,13 @@ public class WireCrossPoint extends GUIComponent
        // serializing
 
        @Override
-       public Integer getParamsForSerializing(IdentifierGetter idGetter)
+       public String getIDForSerializing(IdentifyParams idParams)
+       {
+               return "WireCrossPoint";
+       }
+
+       @Override
+       public Integer getParamsForSerializing(IdentifyParams idParams)
        {
                return logicWidth;
        }
diff --git a/net.mograsim.logic.model/src/net/mograsim/logic/model/serializing/IdentifierGetter.java b/net.mograsim.logic.model/src/net/mograsim/logic/model/serializing/IdentifierGetter.java
deleted file mode 100644 (file)
index 7e2cfd8..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-package net.mograsim.logic.model.serializing;
-
-import static net.mograsim.logic.model.snippets.SubmodelComponentSnippetSuppliers.highLevelStateHandlerSupplier;
-import static net.mograsim.logic.model.snippets.SubmodelComponentSnippetSuppliers.outlineRendererSupplier;
-import static net.mograsim.logic.model.snippets.SubmodelComponentSnippetSuppliers.symbolRendererSupplier;
-import static net.mograsim.logic.model.snippets.highlevelstatehandlers.standard.StandardHighLevelStateHandlerSnippetSuppliers.atomicHandlerSupplier;
-import static net.mograsim.logic.model.snippets.highlevelstatehandlers.standard.StandardHighLevelStateHandlerSnippetSuppliers.subcomponentHandlerSupplier;
-
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.function.Function;
-
-import net.mograsim.logic.model.model.components.GUIComponent;
-import net.mograsim.logic.model.snippets.CodeSnippetSupplier;
-import net.mograsim.logic.model.snippets.HighLevelStateHandler;
-import net.mograsim.logic.model.snippets.Renderer;
-import net.mograsim.logic.model.snippets.highlevelstatehandlers.standard.atomic.AtomicHighLevelStateHandler;
-import net.mograsim.logic.model.snippets.highlevelstatehandlers.standard.subcomponent.SubcomponentHighLevelStateHandler;
-
-//TODO better name
-public class IdentifierGetter
-{
-       // TODO save IDs for everything than can be deserialized / serialized (=every JSONSerializable?)
-       public Function<GUIComponent, String> componentIDs;
-       public Function<Renderer, String> symbolRendererIDs;
-       public Function<Renderer, String> outlineRendererIDs;
-       public Function<HighLevelStateHandler, String> highLevelStateHandlerIDs;
-       public Function<SubcomponentHighLevelStateHandler, String> subcomponentHighLevelStateHandlerIDs;
-       public Function<AtomicHighLevelStateHandler, String> atomicHighLevelStateHandlerIDs;
-
-       /**
-        * Creates a new IdentifierGetter using the following as the default for all ID getter functions: <br>
-        * Define the verbose ID as <code>"class:" + canonicalClassName</code>.<br>
-        * If there is a standard ID mapping to this verbose ID recorded in the matching {@link CodeSnippetSupplier}, use this ID; if not, use
-        * the verbose ID.
-        */
-       public IdentifierGetter()
-       {
-               componentIDs = generateStandardIDFunction(IndirectGUIComponentCreator.getStandardComponentIDs());
-               symbolRendererIDs = generateStandardIDFunction(symbolRendererSupplier);
-               outlineRendererIDs = generateStandardIDFunction(outlineRendererSupplier);
-               highLevelStateHandlerIDs = generateStandardIDFunction(highLevelStateHandlerSupplier);
-               atomicHighLevelStateHandlerIDs = generateStandardIDFunction(atomicHandlerSupplier);
-               subcomponentHighLevelStateHandlerIDs = generateStandardIDFunction(subcomponentHandlerSupplier);
-       }
-
-       private static <T> Function<T, String> generateStandardIDFunction(CodeSnippetSupplier<?, T> snippetSupplier)
-       {
-               return generateStandardIDFunction(snippetSupplier.getStandardSnippetIDs());
-       }
-
-       private static <T> Function<T, String> generateStandardIDFunction(Map<String, String> standardComponentIDs)
-       {
-               return t ->
-               {
-                       String verboseID = "class:" + t.getClass().getCanonicalName();
-                       return standardComponentIDs.entrySet().stream().filter(e -> e.getValue().equals(verboseID)).map(Entry::getKey).findAny()
-                                       .orElse(verboseID);
-               };
-       }
-}
\ No newline at end of file
diff --git a/net.mograsim.logic.model/src/net/mograsim/logic/model/serializing/IdentifyParams.java b/net.mograsim.logic.model/src/net/mograsim/logic/model/serializing/IdentifyParams.java
new file mode 100644 (file)
index 0000000..bf6cf61
--- /dev/null
@@ -0,0 +1,6 @@
+package net.mograsim.logic.model.serializing;
+
+public class IdentifyParams
+{
+       // maybe we find something to put here...
+}
\ No newline at end of file
index f40807d..32d9f94 100644 (file)
@@ -6,10 +6,12 @@ import net.mograsim.logic.model.util.JsonHandler;
 
 public interface JSONSerializable
 {
-       public Object getParamsForSerializing(IdentifierGetter idGetter);
+       public String getIDForSerializing(IdentifyParams idParams);
 
-       public default JsonElement getParamsForSerializingJSON(IdentifierGetter idGetter)
+       public Object getParamsForSerializing(IdentifyParams idParams);
+
+       public default JsonElement getParamsForSerializingJSON(IdentifyParams idParams)
        {
-               return JsonHandler.toJsonTree(getParamsForSerializing(idGetter));
+               return JsonHandler.toJsonTree(getParamsForSerializing(idParams));
        }
 }
\ No newline at end of file
index c50019f..dc5d420 100644 (file)
@@ -134,9 +134,9 @@ public final class LegacySubmodelComponentSerializer
         * 
         * @author Daniel Kirschten
         */
-       public static void serialize(SubmodelComponent comp, IdentifierGetter idGetter, String targetPath) throws IOException
+       public static void serialize(SubmodelComponent comp, IdentifyParams idParams, String targetPath) throws IOException
        {
-               JsonHandler.writeJson(serialize(comp, idGetter), targetPath);
+               JsonHandler.writeJson(serialize(comp, idParams), targetPath);
        }
 
        /**
@@ -147,7 +147,7 @@ public final class LegacySubmodelComponentSerializer
         */
        public static LegacySubmodelComponentParams serialize(SubmodelComponent comp)
        {
-               return serialize(comp, new IdentifierGetter());
+               return serialize(comp, new IdentifyParams());
        }
 
        // "core" methods
@@ -218,7 +218,7 @@ public final class LegacySubmodelComponentSerializer
         * @author Fabian Stemmler
         * @author Daniel Kirschten
         */
-       public static LegacySubmodelComponentParams serialize(SubmodelComponent comp, IdentifierGetter idGetter)
+       public static LegacySubmodelComponentParams serialize(SubmodelComponent comp, IdentifyParams idParams)
        {
                LegacySubmodelParameters submodelParams = new LegacySubmodelParameters();
                submodelParams.innerScale = comp.getSubmodelScale();
@@ -240,8 +240,8 @@ public final class LegacySubmodelComponentSerializer
                                innerComponentParams.params = innerCompCasted.paramsForSerializingOverride;
                        } else
                        {
-                               innerComponentParams.id = idGetter.componentIDs.apply(innerComponent);
-                               innerComponentParams.params = innerComponent.getParamsForSerializingJSON(idGetter);
+                               innerComponentParams.id = innerComponent.getIDForSerializing(idParams);
+                               innerComponentParams.params = innerComponent.getParamsForSerializingJSON(idParams);
                        }
                        innerComponentParams.name = innerComponent.name;
                        i1++;
@@ -291,22 +291,22 @@ public final class LegacySubmodelComponentSerializer
                Renderer symbolRenderer = comp.getSymbolRenderer();
                if (symbolRenderer != null)
                {
-                       params.symbolRendererSnippetID = idGetter.symbolRendererIDs.apply(symbolRenderer);
-                       params.symbolRendererParams = symbolRenderer.getParamsForSerializingJSON(idGetter);
+                       params.symbolRendererSnippetID = symbolRenderer.getIDForSerializing(idParams);
+                       params.symbolRendererParams = symbolRenderer.getParamsForSerializingJSON(idParams);
                }
 
                Renderer outlineRenderer = comp.getOutlineRenderer();
                if (outlineRenderer != null)
                {
-                       params.outlineRendererSnippetID = idGetter.outlineRendererIDs.apply(outlineRenderer);
-                       params.outlineRendererParams = outlineRenderer.getParamsForSerializingJSON(idGetter);
+                       params.outlineRendererSnippetID = outlineRenderer.getIDForSerializing(idParams);
+                       params.outlineRendererParams = outlineRenderer.getParamsForSerializingJSON(idParams);
                }
 
                HighLevelStateHandler highLevelStateHandler = comp.getHighLevelStateHandler();
                if (highLevelStateHandler != null)
                {
-                       params.highLevelStateHandlerSnippetID = idGetter.highLevelStateHandlerIDs.apply(highLevelStateHandler);
-                       params.highLevelStateHandlerParams = highLevelStateHandler.getParamsForSerializingJSON(idGetter);
+                       params.highLevelStateHandlerSnippetID = highLevelStateHandler.getIDForSerializing(idParams);
+                       params.highLevelStateHandlerParams = highLevelStateHandler.getParamsForSerializingJSON(idParams);
                }
 
                return params;
index a062eaa..84e9fdb 100644 (file)
@@ -129,9 +129,9 @@ public final class SubmodelComponentSerializer
         * 
         * @author Daniel Kirschten
         */
-       public static void serialize(SubmodelComponent comp, IdentifierGetter idGetter, String targetPath) throws IOException
+       public static void serialize(SubmodelComponent comp, IdentifyParams idParams, String targetPath) throws IOException
        {
-               JsonHandler.writeJson(serialize(comp, idGetter), targetPath);
+               JsonHandler.writeJson(serialize(comp, idParams), targetPath);
        }
 
        /**
@@ -142,7 +142,7 @@ public final class SubmodelComponentSerializer
         */
        public static SubmodelComponentParams serialize(SubmodelComponent comp)
        {
-               return serialize(comp, new IdentifierGetter());
+               return serialize(comp, new IdentifyParams());
        }
 
        // "core" methods
@@ -195,11 +195,11 @@ public final class SubmodelComponentSerializer
         * @author Fabian Stemmler
         * @author Daniel Kirschten
         */
-       public static SubmodelComponentParams serialize(SubmodelComponent comp, IdentifierGetter idGetter)
+       public static SubmodelComponentParams serialize(SubmodelComponent comp, IdentifyParams idParams)
        {
                SubmodelComponentParams params = new SubmodelComponentParams(JSON_VERSION_CURRENT_SERIALIZING);
                params.innerScale = comp.getSubmodelScale();
-               params.submodel = ViewModelSerializer.serialize(comp.submodel, idGetter);
+               params.submodel = ViewModelSerializer.serialize(comp.submodel, idParams);
 
                params.width = comp.getWidth();
                params.height = comp.getHeight();
@@ -222,22 +222,22 @@ public final class SubmodelComponentSerializer
                Renderer symbolRenderer = comp.getSymbolRenderer();
                if (symbolRenderer != null)
                {
-                       params.symbolRendererSnippetID = idGetter.symbolRendererIDs.apply(symbolRenderer);
-                       params.symbolRendererParams = symbolRenderer.getParamsForSerializingJSON(idGetter);
+                       params.symbolRendererSnippetID = symbolRenderer.getIDForSerializing(idParams);
+                       params.symbolRendererParams = symbolRenderer.getParamsForSerializingJSON(idParams);
                }
 
                Renderer outlineRenderer = comp.getOutlineRenderer();
                if (outlineRenderer != null)
                {
-                       params.outlineRendererSnippetID = idGetter.outlineRendererIDs.apply(outlineRenderer);
-                       params.outlineRendererParams = outlineRenderer.getParamsForSerializingJSON(idGetter);
+                       params.outlineRendererSnippetID = outlineRenderer.getIDForSerializing(idParams);
+                       params.outlineRendererParams = outlineRenderer.getParamsForSerializingJSON(idParams);
                }
 
                HighLevelStateHandler highLevelStateHandler = comp.getHighLevelStateHandler();
                if (highLevelStateHandler != null)
                {
-                       params.highLevelStateHandlerSnippetID = idGetter.highLevelStateHandlerIDs.apply(highLevelStateHandler);
-                       params.highLevelStateHandlerParams = highLevelStateHandler.getParamsForSerializingJSON(idGetter);
+                       params.highLevelStateHandlerSnippetID = highLevelStateHandler.getIDForSerializing(idParams);
+                       params.highLevelStateHandlerParams = highLevelStateHandler.getParamsForSerializingJSON(idParams);
                }
 
                return params;
index b6c2879..61d4915 100644 (file)
@@ -78,9 +78,9 @@ public class ViewModelSerializer
         * 
         * @author Daniel Kirschten
         */
-       public static void serialize(ViewModel model, IdentifierGetter idGetter, String targetPath) throws IOException
+       public static void serialize(ViewModel model, IdentifyParams idParams, String targetPath) throws IOException
        {
-               JsonHandler.writeJson(serialize(model, idGetter), targetPath);
+               JsonHandler.writeJson(serialize(model, idParams), targetPath);
        }
 
        /**
@@ -91,7 +91,7 @@ public class ViewModelSerializer
         */
        public static ViewModelParams serialize(ViewModel model)
        {
-               return serialize(model, new IdentifierGetter());
+               return serialize(model, new IdentifyParams());
        }
 
        // "core" methods
@@ -137,7 +137,7 @@ public class ViewModelSerializer
         * @author Fabian Stemmler
         * @author Daniel Kirschten
         */
-       public static ViewModelParams serialize(ViewModel model, IdentifierGetter idGetter)
+       public static ViewModelParams serialize(ViewModel model, IdentifyParams idParams)
        {
                ViewModelParams modelParams = new ViewModelParams(CURRENT_JSON_VERSION);
 
@@ -157,8 +157,8 @@ public class ViewModelSerializer
                                compParams.params = innerCompCasted.paramsForSerializingOverride;
                        } else
                        {
-                               compParams.id = idGetter.componentIDs.apply(component);
-                               compParams.params = component.getParamsForSerializingJSON(idGetter);
+                               compParams.id = component.getIDForSerializing(idParams);
+                               compParams.params = component.getParamsForSerializingJSON(idParams);
                        }
                        compParams.name = component.name;
                }
index 35dc24a..7fd1fc9 100644 (file)
@@ -1,7 +1,7 @@
 package net.mograsim.logic.model.snippets.highlevelstatehandlers;
 
 import net.mograsim.logic.model.model.components.submodels.SubmodelComponent;
-import net.mograsim.logic.model.serializing.IdentifierGetter;
+import net.mograsim.logic.model.serializing.IdentifyParams;
 import net.mograsim.logic.model.snippets.HighLevelStateHandler;
 import net.mograsim.logic.model.snippets.SnippetDefinintion;
 import net.mograsim.logic.model.snippets.SubmodelComponentSnippetSuppliers;
@@ -37,7 +37,13 @@ public class DefaultHighLevelStateHandler implements HighLevelStateHandler
        }
 
        @Override
-       public Void getParamsForSerializing(IdentifierGetter idGetter)
+       public String getIDForSerializing(IdentifyParams idParams)
+       {
+               return "default";
+       }
+
+       @Override
+       public Void getParamsForSerializing(IdentifyParams idParams)
        {
                return null;
        }
index 9afa7c4..af3ad22 100644 (file)
@@ -7,7 +7,7 @@ import java.util.function.BiFunction;
 import java.util.function.Function;
 
 import net.mograsim.logic.model.model.components.submodels.SubmodelComponent;
-import net.mograsim.logic.model.serializing.IdentifierGetter;
+import net.mograsim.logic.model.serializing.IdentifyParams;
 import net.mograsim.logic.model.snippets.HighLevelStateHandler;
 import net.mograsim.logic.model.snippets.SnippetDefinintion;
 import net.mograsim.logic.model.snippets.SubmodelComponentSnippetSuppliers;
@@ -142,7 +142,13 @@ public class StandardHighLevelStateHandler implements HighLevelStateHandler
        }
 
        @Override
-       public StandardHighLevelStateHandlerParams getParamsForSerializing(IdentifierGetter idGetter)
+       public String getIDForSerializing(IdentifyParams idParams)
+       {
+               return "standard";
+       }
+
+       @Override
+       public StandardHighLevelStateHandlerParams getParamsForSerializing(IdentifyParams idParams)
        {
                StandardHighLevelStateHandlerParams params = new StandardHighLevelStateHandlerParams();
                params.subcomponentHighLevelStates = new HashMap<>();
@@ -152,8 +158,8 @@ public class StandardHighLevelStateHandler implements HighLevelStateHandler
                        String stateID = e.getKey();
                        SubcomponentHighLevelStateHandler handler = e.getValue();
                        SubcomponentHighLevelStateHandlerParams handlerParams = new SubcomponentHighLevelStateHandlerParams();
-                       handlerParams.id = idGetter.subcomponentHighLevelStateHandlerIDs.apply(handler);
-                       handlerParams.params = handler.getParamsForSerializingJSON(idGetter);
+                       handlerParams.id = handler.getIDForSerializing(idParams);
+                       handlerParams.params = handler.getParamsForSerializingJSON(idParams);
                        params.subcomponentHighLevelStates.put(stateID, handlerParams);
                }
                for (Entry<String, AtomicHighLevelStateHandler> e : atomicHighLevelStateHandlers.entrySet())
@@ -161,8 +167,8 @@ public class StandardHighLevelStateHandler implements HighLevelStateHandler
                        String stateID = e.getKey();
                        AtomicHighLevelStateHandler handler = e.getValue();
                        AtomicHighLevelStateHandlerParams handlerParams = new AtomicHighLevelStateHandlerParams();
-                       handlerParams.id = idGetter.atomicHighLevelStateHandlerIDs.apply(handler);
-                       handlerParams.params = handler.getParamsForSerializingJSON(idGetter);
+                       handlerParams.id = handler.getIDForSerializing(idParams);
+                       handlerParams.params = handler.getParamsForSerializingJSON(idParams);
                        params.atomicHighLevelStates.put(stateID, handlerParams);
                }
                return params;
index b17af6f..b5630a5 100644 (file)
@@ -6,7 +6,7 @@ import java.util.List;
 import net.mograsim.logic.core.types.Bit;
 import net.mograsim.logic.core.types.BitVector;
 import net.mograsim.logic.model.model.components.submodels.SubmodelComponent;
-import net.mograsim.logic.model.serializing.IdentifierGetter;
+import net.mograsim.logic.model.serializing.IdentifyParams;
 import net.mograsim.logic.model.snippets.SnippetDefinintion;
 import net.mograsim.logic.model.snippets.highlevelstatehandlers.standard.HighLevelStateHandlerContext;
 import net.mograsim.logic.model.snippets.highlevelstatehandlers.standard.StandardHighLevelStateHandlerSnippetSuppliers;
@@ -98,7 +98,13 @@ public class BitVectorSplittingAtomicHighLevelStateHandler implements AtomicHigh
        }
 
        @Override
-       public BitVectorSplittingAtomicHighLevelStateHandlerParams getParamsForSerializing(IdentifierGetter idGetter)
+       public String getIDForSerializing(IdentifyParams idParams)
+       {
+               return "bitVectorSplitting";
+       }
+
+       @Override
+       public BitVectorSplittingAtomicHighLevelStateHandlerParams getParamsForSerializing(IdentifyParams idParams)
        {
                BitVectorSplittingAtomicHighLevelStateHandlerParams params = new BitVectorSplittingAtomicHighLevelStateHandlerParams();
                params.vectorPartTargets = new ArrayList<>(vectorPartTargets);
index de9bc4a..2529179 100644 (file)
@@ -2,7 +2,7 @@ package net.mograsim.logic.model.snippets.highlevelstatehandlers.standard.atomic
 
 import net.mograsim.logic.model.model.components.GUIComponent;
 import net.mograsim.logic.model.model.components.submodels.SubmodelComponent;
-import net.mograsim.logic.model.serializing.IdentifierGetter;
+import net.mograsim.logic.model.serializing.IdentifyParams;
 import net.mograsim.logic.model.snippets.SnippetDefinintion;
 import net.mograsim.logic.model.snippets.highlevelstatehandlers.standard.HighLevelStateHandlerContext;
 import net.mograsim.logic.model.snippets.highlevelstatehandlers.standard.StandardHighLevelStateHandlerSnippetSuppliers;
@@ -66,7 +66,13 @@ public class DelegatingAtomicHighLevelStateHandler implements AtomicHighLevelSta
        }
 
        @Override
-       public DelegatingAtomicHighLevelStateHandlerParams getParamsForSerializing(IdentifierGetter idGetter)
+       public String getIDForSerializing(IdentifyParams idParams)
+       {
+               return "delegating";
+       }
+
+       @Override
+       public DelegatingAtomicHighLevelStateHandlerParams getParamsForSerializing(IdentifyParams idParams)
        {
                DelegatingAtomicHighLevelStateHandlerParams params = new DelegatingAtomicHighLevelStateHandlerParams();
                params.delegateTarget = delegateTarget.name;
index b800934..c1e8faf 100644 (file)
@@ -10,7 +10,7 @@ import net.mograsim.logic.core.types.Bit;
 import net.mograsim.logic.core.types.BitVector;
 import net.mograsim.logic.model.model.components.submodels.SubmodelComponent;
 import net.mograsim.logic.model.model.wires.GUIWire;
-import net.mograsim.logic.model.serializing.IdentifierGetter;
+import net.mograsim.logic.model.serializing.IdentifyParams;
 import net.mograsim.logic.model.snippets.SnippetDefinintion;
 import net.mograsim.logic.model.snippets.highlevelstatehandlers.standard.HighLevelStateHandlerContext;
 import net.mograsim.logic.model.snippets.highlevelstatehandlers.standard.StandardHighLevelStateHandlerSnippetSuppliers;
@@ -107,7 +107,13 @@ public class WireForcingAtomicHighLevelStateHandler implements AtomicHighLevelSt
        }
 
        @Override
-       public WireForcingAtomicHighLevelStateHandlerParams getParamsForSerializing(IdentifierGetter idGetter)
+       public String getIDForSerializing(IdentifyParams idParams)
+       {
+               return "wireForcing";
+       }
+
+       @Override
+       public WireForcingAtomicHighLevelStateHandlerParams getParamsForSerializing(IdentifyParams idParams)
        {
                WireForcingAtomicHighLevelStateHandlerParams params = new WireForcingAtomicHighLevelStateHandlerParams();
                params.wiresToForce = wiresToForce.stream().map(w -> w.name).collect(Collectors.toList());
index 139fc96..80e76b0 100644 (file)
@@ -2,7 +2,7 @@ package net.mograsim.logic.model.snippets.highlevelstatehandlers.standard.subcom
 
 import net.mograsim.logic.model.model.components.GUIComponent;
 import net.mograsim.logic.model.model.components.submodels.SubmodelComponent;
-import net.mograsim.logic.model.serializing.IdentifierGetter;
+import net.mograsim.logic.model.serializing.IdentifyParams;
 import net.mograsim.logic.model.snippets.SnippetDefinintion;
 import net.mograsim.logic.model.snippets.highlevelstatehandlers.standard.HighLevelStateHandlerContext;
 import net.mograsim.logic.model.snippets.highlevelstatehandlers.standard.StandardHighLevelStateHandlerSnippetSuppliers;
@@ -72,7 +72,13 @@ public class DelegatingSubcomponentHighLevelStateHandler implements Subcomponent
        }
 
        @Override
-       public DelegatingSubcomponentHighLevelStateHandlerParams getParamsForSerializing(IdentifierGetter idGetter)
+       public String getIDForSerializing(IdentifyParams idParams)
+       {
+               return "delegating";
+       }
+
+       @Override
+       public DelegatingSubcomponentHighLevelStateHandlerParams getParamsForSerializing(IdentifyParams idParams)
        {
                DelegatingSubcomponentHighLevelStateHandlerParams params = new DelegatingSubcomponentHighLevelStateHandlerParams();
                params.delegateTarget = delegateTarget.name;
index 2bee25f..5207bc9 100644 (file)
@@ -3,7 +3,7 @@ package net.mograsim.logic.model.snippets.outlinerenderers;
 import net.haspamelodica.swt.helper.gcs.GeneralGC;
 import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle;
 import net.mograsim.logic.model.model.components.GUIComponent;
-import net.mograsim.logic.model.serializing.IdentifierGetter;
+import net.mograsim.logic.model.serializing.IdentifyParams;
 import net.mograsim.logic.model.snippets.Renderer;
 import net.mograsim.logic.model.snippets.SnippetDefinintion;
 import net.mograsim.logic.model.snippets.SubmodelComponentSnippetSuppliers;
@@ -35,7 +35,13 @@ public class DefaultOutlineRenderer implements Renderer
        }
 
        @Override
-       public Void getParamsForSerializing(IdentifierGetter idGetter)
+       public String getIDForSerializing(IdentifyParams idParams)
+       {
+               return "default";
+       }
+
+       @Override
+       public Void getParamsForSerializing(IdentifyParams idParams)
        {
                return null;
        }
index 515b7b6..196400d 100644 (file)
@@ -5,7 +5,7 @@ import net.haspamelodica.swt.helper.swtobjectwrappers.Font;
 import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
 import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle;
 import net.mograsim.logic.model.model.components.GUIComponent;
-import net.mograsim.logic.model.serializing.IdentifierGetter;
+import net.mograsim.logic.model.serializing.IdentifyParams;
 import net.mograsim.logic.model.snippets.Renderer;
 import net.mograsim.logic.model.snippets.SnippetDefinintion;
 import net.mograsim.logic.model.snippets.SubmodelComponentSnippetSuppliers;
@@ -47,7 +47,13 @@ public class CenteredTextSymbolRenderer implements Renderer
        }
 
        @Override
-       public CenteredTextParams getParamsForSerializing(IdentifierGetter idGetter)
+       public String getIDForSerializing(IdentifyParams idParams)
+       {
+               return "centeredText";
+       }
+
+       @Override
+       public CenteredTextParams getParamsForSerializing(IdentifyParams idParams)
        {
                CenteredTextParams params = new CenteredTextParams();
                params.text = text;
index 9e097aa..0ff502e 100644 (file)
@@ -4,7 +4,7 @@ import net.haspamelodica.swt.helper.gcs.GeneralGC;
 import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
 import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle;
 import net.mograsim.logic.model.model.components.GUIComponent;
-import net.mograsim.logic.model.serializing.IdentifierGetter;
+import net.mograsim.logic.model.serializing.IdentifyParams;
 import net.mograsim.logic.model.snippets.Renderer;
 import net.mograsim.logic.model.snippets.SnippetDefinintion;
 import net.mograsim.logic.model.snippets.SubmodelComponentSnippetSuppliers;
@@ -40,7 +40,13 @@ public class DefaultSymbolRenderer implements Renderer
        }
 
        @Override
-       public Void getParamsForSerializing(IdentifierGetter idGetter)
+       public String getIDForSerializing(IdentifyParams idParams)
+       {
+               return "default";
+       }
+
+       @Override
+       public Void getParamsForSerializing(IdentifyParams idParams)
        {
                return null;
        }
index d6c76e1..eff5fb6 100644 (file)
@@ -9,7 +9,7 @@ import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
 import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle;
 import net.mograsim.logic.model.model.components.GUIComponent;
 import net.mograsim.logic.model.model.wires.Pin;
-import net.mograsim.logic.model.serializing.IdentifierGetter;
+import net.mograsim.logic.model.serializing.IdentifyParams;
 import net.mograsim.logic.model.snippets.Renderer;
 import net.mograsim.logic.model.snippets.SnippetDefinintion;
 import net.mograsim.logic.model.snippets.SubmodelComponentSnippetSuppliers;
@@ -73,7 +73,13 @@ public class PinNamesSymbolRenderer implements Renderer
        }
 
        @Override
-       public PinNamesParams getParamsForSerializing(IdentifierGetter idGetter)
+       public String getIDForSerializing(IdentifyParams idParams)
+       {
+               return "pinNames";
+       }
+
+       @Override
+       public PinNamesParams getParamsForSerializing(IdentifyParams idParams)
        {
                PinNamesParams params = new PinNamesParams();
                params.pinNamePositions = new HashMap<>();
index 2eda106..f72375e 100644 (file)
@@ -10,7 +10,7 @@ import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
 import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle;
 import net.mograsim.logic.model.model.components.GUIComponent;
 import net.mograsim.logic.model.model.wires.Pin;
-import net.mograsim.logic.model.serializing.IdentifierGetter;
+import net.mograsim.logic.model.serializing.IdentifyParams;
 import net.mograsim.logic.model.snippets.Renderer;
 import net.mograsim.logic.model.snippets.SnippetDefinintion;
 import net.mograsim.logic.model.snippets.SubmodelComponentSnippetSuppliers;
@@ -73,7 +73,13 @@ public class SimpleRectangularLikeSymbolRenderer implements Renderer
        }
 
        @Override
-       public SimpleRectangularLikeParams getParamsForSerializing(IdentifierGetter idGetter)
+       public String getIDForSerializing(IdentifyParams idParams)
+       {
+               return "simpleRectangularLike";
+       }
+
+       @Override
+       public SimpleRectangularLikeParams getParamsForSerializing(IdentifyParams idParams)
        {
                SimpleRectangularLikeParams params = new SimpleRectangularLikeParams();
                params.centerText = centerText;
index f6df419..bd5eba8 100644 (file)
@@ -8,7 +8,7 @@ import net.mograsim.logic.model.model.components.atomic.GUIAndGate;
 import net.mograsim.logic.model.model.wires.Pin;
 import net.mograsim.logic.model.model.wires.PinUsage;
 import net.mograsim.logic.model.modeladapter.ViewLogicModelAdapter;
-import net.mograsim.logic.model.serializing.IdentifierGetter;
+import net.mograsim.logic.model.serializing.IdentifyParams;
 import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator;
 import net.mograsim.logic.model.snippets.Renderer;
 import net.mograsim.logic.model.snippets.outlinerenderers.DefaultOutlineRenderer;
@@ -82,7 +82,13 @@ public class GUIMemoryWA extends GUIComponent
        }
 
        @Override
-       public GUIMemoryWAParams getParamsForSerializing(IdentifierGetter idGetter)
+       public String getIDForSerializing(IdentifyParams idParams)
+       {
+               return "GUIMemoryWA";//TODO
+       }
+
+       @Override
+       public GUIMemoryWAParams getParamsForSerializing(IdentifyParams idParams)
        {
                GUIMemoryWAParams params = new GUIMemoryWAParams();
                params.addrBits = definition.getMemoryAddressBits();