001package jmri.jmrix.sprog.pi.pisprogonecs.configurexml;
002
003import jmri.jmrix.configurexml.AbstractSerialConnectionConfigXml;
004import jmri.jmrix.sprog.pi.pisprogonecs.ConnectionConfig;
005import jmri.jmrix.sprog.pi.pisprogonecs.PiSprogOneCSSerialDriverAdapter;
006
007/**
008 * Handle XML persistance of layout connections by persistening the
009 * SerialDriverAdapter (and connections). Note this is named as the XML version
010 * of a ConnectionConfig object, but it's actually persisting the
011 * SerialDriverAdapter.
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 Andrew Crosland Copyright: Copyright (c) 2016
018 */
019public class ConnectionConfigXml extends AbstractSerialConnectionConfigXml {
020
021    public ConnectionConfigXml() {
022        super();
023    }
024
025    @Override
026    protected void getInstance() {
027        if (adapter == null) {
028            adapter = new PiSprogOneCSSerialDriverAdapter();
029        }
030    }
031
032    @Override
033    protected void getInstance(Object object) {
034        adapter = ((ConnectionConfig) object).getAdapter();
035    }
036
037
038    @Override
039    protected void register() {
040        this.register(new ConnectionConfig(adapter));
041    }
042
043    // initialize logging
044    // private final static Logger log = LoggerFactory.getLogger(ConnectionConfigXml.class);
045
046}