{
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);
{
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);
{
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);
{
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);
{
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);
{
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);
{
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);
{
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);
{
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);
{
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);
{
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);
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;
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;
}
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
{
if (identifierPerComponent.containsKey(c))
return identifierPerComponent.get(c);
- return new IdentifierGetter().componentIDs.apply(c);
+ return c.getIDForSerializing(new IdentifyParams());
}
public void duplicate()
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
{
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
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;
// serializing
@Override
- public Object getParamsForSerializing(IdentifierGetter idGetter)
+ public Object getParamsForSerializing(IdentifyParams idParams)
{
return null;
}
public GUIAndGate(ViewModelModifiable model, int logicWidth, String name)
{
- super(model, "&", false, logicWidth, name);
+ super(model, "GUIAndGate", "&", false, logicWidth, name);
setInputCount(2);// TODO make variable
}
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;
}
@Override
- public Integer getParamsForSerializing(IdentifierGetter idGetter)
+ public String getIDForSerializing(IdentifyParams idParams)
+ {
+ return "GUIBitDisplay";
+ }
+
+ @Override
+ public Integer getParamsForSerializing(IdentifyParams idParams)
{
return logicWidth;
}
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;
}
@Override
- public GUIClockParams getParamsForSerializing(IdentifierGetter idGetter)
+ public String getIDForSerializing(IdentifyParams idParams)
+ {
+ return "GUIClock";
+ }
+
+ @Override
+ public GUIClockParams getParamsForSerializing(IdentifyParams idParams)
{
return params;
}
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;
}
@Override
- public Integer getParamsForSerializing(IdentifierGetter idGetter)
+ public String getIDForSerializing(IdentifyParams idParams)
+ {
+ return "GUIManualSwitch";
+ }
+
+ @Override
+ public Integer getParamsForSerializing(IdentifyParams idParams)
{
return logicWidth;
}
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;
}
@Override
- public Integer getParamsForSerializing(IdentifierGetter idGetter)
+ public String getIDForSerializing(IdentifyParams idParams)
+ {
+ return "GUIMerger";
+ }
+
+ @Override
+ public Integer getParamsForSerializing(IdentifyParams idParams)
{
return logicWidth;
}
public GUINandGate(ViewModelModifiable model, int logicWidth, String name)
{
- super(model, "&", true, logicWidth, name);
+ super(model, "GUINandGate", "&", true, logicWidth, name);
setInputCount(2);// TODO make variable
}
public GUINotGate(ViewModelModifiable model, int logicWidth, String name)
{
- super(model, "1", true, logicWidth, name);
+ super(model, "GUINotGate", "1", true, logicWidth, name);
setInputCount(1);
}
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);
}
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;
}
@Override
- public Integer getParamsForSerializing(IdentifierGetter idGetter)
+ public String getIDForSerializing(IdentifyParams idParams)
+ {
+ return "GUISplitter";
+ }
+
+ @Override
+ public Integer getParamsForSerializing(IdentifyParams idParams)
{
return logicWidth;
}
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;
}
@Override
- public GUITriStateBufferParams getParamsForSerializing(IdentifierGetter idGetter)
+ public String getIDForSerializing(IdentifyParams idParams)
+ {
+ return "GUITriStateBuffer";
+ }
+
+ @Override
+ public GUITriStateBufferParams getParamsForSerializing(IdentifyParams idParams)
{
return params;
}
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
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;
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;
// 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.
* @see GUIComponent#getParamsForSerializing()
*/
@Override
- public Integer getParamsForSerializing(IdentifierGetter idGetter)
+ public Integer getParamsForSerializing(IdentifyParams idParams)
{
return logicWidth;
}
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;
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;
// 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;
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;
}
pinNamesRenderer.render(gc, visibleRegion);
}
+ // serializing
+
+ @Override
+ public String getIDForSerializing(IdentifyParams idParams)
+ {
+ return id;
+ }
+
// operations no longer supported
@Override
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;
// serializing
@Override
- public String getParamsForSerializing(IdentifierGetter idGetter)
+ public String getIDForSerializing(IdentifyParams idParams)
+ {
+ return "TextComponent";
+ }
+
+ @Override
+ public String getParamsForSerializing(IdentifyParams idParams)
{
return text;
}
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;
// 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
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
{
{// 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 /
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;
// serializing
@Override
- public Integer getParamsForSerializing(IdentifierGetter idGetter)
+ public String getIDForSerializing(IdentifyParams idParams)
+ {
+ return "WireCrossPoint";
+ }
+
+ @Override
+ public Integer getParamsForSerializing(IdentifyParams idParams)
{
return logicWidth;
}
+++ /dev/null
-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
--- /dev/null
+package net.mograsim.logic.model.serializing;
+
+public class IdentifyParams
+{
+ // maybe we find something to put here...
+}
\ No newline at end of file
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
*
* @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);
}
/**
*/
public static LegacySubmodelComponentParams serialize(SubmodelComponent comp)
{
- return serialize(comp, new IdentifierGetter());
+ return serialize(comp, new IdentifyParams());
}
// "core" methods
* @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();
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++;
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;
*
* @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);
}
/**
*/
public static SubmodelComponentParams serialize(SubmodelComponent comp)
{
- return serialize(comp, new IdentifierGetter());
+ return serialize(comp, new IdentifyParams());
}
// "core" methods
* @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();
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;
*
* @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);
}
/**
*/
public static ViewModelParams serialize(ViewModel model)
{
- return serialize(model, new IdentifierGetter());
+ return serialize(model, new IdentifyParams());
}
// "core" methods
* @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);
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;
}
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;
}
@Override
- public Void getParamsForSerializing(IdentifierGetter idGetter)
+ public String getIDForSerializing(IdentifyParams idParams)
+ {
+ return "default";
+ }
+
+ @Override
+ public Void getParamsForSerializing(IdentifyParams idParams)
{
return null;
}
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;
}
@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<>();
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())
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;
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;
}
@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);
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;
}
@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;
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;
}
@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());
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;
}
@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;
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;
}
@Override
- public Void getParamsForSerializing(IdentifierGetter idGetter)
+ public String getIDForSerializing(IdentifyParams idParams)
+ {
+ return "default";
+ }
+
+ @Override
+ public Void getParamsForSerializing(IdentifyParams idParams)
{
return null;
}
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;
}
@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;
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;
}
@Override
- public Void getParamsForSerializing(IdentifierGetter idGetter)
+ public String getIDForSerializing(IdentifyParams idParams)
+ {
+ return "default";
+ }
+
+ @Override
+ public Void getParamsForSerializing(IdentifyParams idParams)
{
return null;
}
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;
}
@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<>();
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;
}
@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;
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;
}
@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();