001package jmri.jmrix.cmri.serial.sim.configurexml;
002
003import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
004import jmri.jmrix.cmri.serial.sim.ConnectionConfig;
005import jmri.jmrix.cmri.serial.sim.SimDriverAdapter;
006
007/**
008 * Handle XML persistance of layout connections by persisting the
009 * SimDriverAdapter (and connections). Note this is named as the XML version of
010 * a ConnectionConfig object, but it's actually persisting the SimDriverAdapter.
011 * <p>
012 * This class is invoked from jmrix.JmrixConfigPaneXml on write, as that class
013 * is the one actually registered. Reads are brought here directly via the class
014 * attribute in the XML.
015 * <p>
016 * This inherits from the cmri.serial.serialdriver version, so it can reuse (and
017 * benefit from changes to) that code.
018 *
019 * @author Bob Jacobsen Copyright: Copyright (c) 2003, 2008
020 */
021@SuppressFBWarnings(value = "NM_SAME_SIMPLE_NAME_AS_SUPERCLASS") // OK by convention
022public class ConnectionConfigXml extends jmri.jmrix.cmri.serial.serialdriver.configurexml.ConnectionConfigXml {
023
024    public ConnectionConfigXml() {
025        super();
026    }
027
028    @Override
029    protected void getInstance() {
030        if(adapter == null) {
031           adapter = new SimDriverAdapter();
032        }
033    }
034
035    @Override
036    protected void getInstance(Object object) {
037        adapter = ((ConnectionConfig) object).getAdapter();
038    }
039
040    @Override
041    protected void register() {
042        this.register(new ConnectionConfig(adapter));
043    }
044
045}