001package jmri.jmrix.dccpp.serial.configurexml;
002
003import jmri.jmrix.dccpp.configurexml.AbstractDCCppSerialConnectionConfigXml;
004import jmri.jmrix.dccpp.serial.ConnectionConfig;
005import jmri.jmrix.dccpp.serial.DCCppAdapter;
006
007/**
008 * Handle XML persistence of layout connections by persistening the DCC++ serial adapter
009 * (and connections). Note this is named as the XML version of a
010 * ConnectionConfig object, but it's actually persisting the DCCppAdapter.
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 *
016 * @author Paul Bender Copyright (c) 2005
017 * @author Mark Underwood Copyright (c) 2015
018 */
019public class ConnectionConfigXml extends AbstractDCCppSerialConnectionConfigXml {
020
021    public ConnectionConfigXml() {
022        super();
023    }
024
025    @Override
026    protected void getInstance() {
027        if (adapter == null) {
028            adapter = new DCCppAdapter();
029        }
030    }
031
032    @Override
033    protected void getInstance(Object object) {
034        adapter = ((ConnectionConfig) object).getAdapter();
035    }
036
037    @Override
038    protected void register() {
039        this.register(new ConnectionConfig(adapter));
040    }
041
042}