001package jmri.jmrix.can.adapters.gridconnect.usblcc.serialdriver.configurexml;
002
003import org.jdom2.Element;
004
005import jmri.jmrix.PortAdapter;
006import jmri.jmrix.can.adapters.gridconnect.usblcc.serialdriver.ConnectionConfig;
007import jmri.jmrix.can.adapters.gridconnect.usblcc.serialdriver.SerialDriverAdapter;
008import jmri.jmrix.configurexml.AbstractSerialConnectionConfigXml;
009
010/**
011 * Handle XML persistance of layout connections by persistening the
012 * SerialDriverAdapter (and connections). Note this is named as the XML version
013 * of a ConnectionConfig object, but it's actually persisting the
014 * SerialDriverAdapter.
015 * <p>
016 * This class is invoked from jmrix.JmrixConfigPaneXml on write, as that class
017 * is the one actually registered. Reads are brought here directly via the class
018 * attribute in the XML.
019 *
020 * @author Bob Jacobsen Copyright: Copyright (c) 2003
021 * @author Andrew Crosland 2008
022 * @author Andrew Crosland 2023
023 */
024public class ConnectionConfigXml extends AbstractSerialConnectionConfigXml {
025
026    public ConnectionConfigXml() {
027        super();
028    }
029
030    @Override
031    protected void getInstance() {
032        adapter = new SerialDriverAdapter();
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    @Override
046    protected void loadOptions(Element shared, Element perNode, PortAdapter adapter) {
047        super.loadOptions(shared, perNode, adapter);
048
049        jmri.jmrix.openlcb.configurexml.ConnectionConfigXml.maybeLoadOlcbProfileSettings(
050                shared.getParentElement(), perNode.getParentElement(), adapter);
051    }
052
053    @Override
054    protected void extendElement(Element e) {
055        jmri.jmrix.openlcb.configurexml.ConnectionConfigXml.maybeSaveOlcbProfileSettings(
056                e, adapter);
057    }
058}