001package jmri.jmrix.dccpp.network.configurexml;
002
003import jmri.jmrix.configurexml.AbstractNetworkConnectionConfigXml;
004import jmri.jmrix.dccpp.network.ConnectionConfig;
005import jmri.jmrix.dccpp.network.DCCppEthernetAdapter;
006
007/**
008 * Handle XML persistence of layout connections by persisting the DCC++ Server
009 * (and connections). Note this is named as the XML version of a
010 * ConnectionConfig object, but it's actually persisting the DCC++ Server.
011 * <p>
012 * NOTE: The DCC++ Server currently has no options, so this class does not store
013 * any.
014 * <p>
015 * This class is invoked from jmrix.JmrixConfigPaneXml on write, as that class
016 * is the one actually registered. Reads are brought here directly via the class
017 * attribute in the XML.
018 *
019 * @author Paul Bender Copyright (C) 2011
020 * @author Mark Underwood Copyright (C) 2015
021 */
022public class ConnectionConfigXml extends AbstractNetworkConnectionConfigXml {
023
024    public ConnectionConfigXml() {
025        super();
026    }
027
028    @Override
029    protected void getInstance() {
030        if (adapter == null) {
031            adapter = new DCCppEthernetAdapter();
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}