001package jmri.jmrix.roco.z21.simulator.configurexml;
002
003import jmri.jmrix.roco.z21.simulator.Z21SimulatorAdapter;
004import jmri.jmrix.roco.z21.simulator.Z21SimulatorConnectionConfig;
005
006/**
007 * Handle XML persistence of layout connections by persisting the
008 * Z21SimulatorAdapter (and connections).
009 * <p>
010 * Note this is named as the XML version of a Z21SimulatorConnectionConfig
011 * object, but it's actually persisting the Z21SimulatorAdapter.
012 * <p>
013 * This class is invoked from jmrix.JmrixConfigPaneXml on write, as that class
014 * is the one actually registered. Reads are brought here directly via the class
015 * attribute in the XML.
016 *
017 * @author Bob Jacobsen Copyright: Copyright (c) 2003
018 * @author Paul Bender Copyright: Copyright (c) 2009
019 */
020public class Z21SimulatorConnectionConfigXml extends jmri.jmrix.roco.z21.configurexml.ConnectionConfigXml {
021
022    public Z21SimulatorConnectionConfigXml() {
023        super();
024    }
025
026    @Override
027    protected void getInstance() {
028        if (adapter == null) {
029            adapter = new Z21SimulatorAdapter();
030        }
031    }
032
033    @Override
034    protected void getInstance(Object object) {
035        adapter = ((Z21SimulatorConnectionConfig) object).getAdapter();
036    }
037
038    @Override
039    protected void register() {
040        this.register(new Z21SimulatorConnectionConfig(adapter));
041    }
042
043}