001package jmri.jmrix.openlcb.configurexml;
002
003import jmri.InstanceManager;
004import jmri.configurexml.JmriConfigureXmlException;
005import jmri.jmrix.openlcb.OlcbConfigurationManager;
006
007import org.jdom2.Element;
008
009/**
010 * Provides load and store functionality for configuring OlcbStringIOManagers.
011 *
012 * @author Bob Jacobsen      Copyright: Copyright (c) 2003
013 * @author Daniel Bergqvist  Copyright: Copyright (c) 2021
014 */
015public class OlcbStringIOManagerXml extends jmri.managers.configurexml.AbstractStringIOManagerConfigXML {
016
017    public OlcbStringIOManagerXml() {
018        super();
019    }
020
021    @Override
022    public void setStoreElementClass(Element sensors) {
023        sensors.setAttribute("class", this.getClass().getName());
024    }
025
026
027    @Override
028    public boolean load(Element shared, Element perNode) throws JmriConfigureXmlException {
029        boolean result;
030        // We tell the StringIO manager(s) that we will be loading StringIOs from XML and they should
031        // expect additional property set sequences. This is somewhat tricky in the face of
032        // possibly multiple OpenLCB buses registered.
033        for (OlcbConfigurationManager cfg : InstanceManager.getList(OlcbConfigurationManager
034                .class)) {
035            cfg.getStringIOManager().startLoad();
036        }
037
038        // load individual sensors
039        result = loadStringIOs(shared);
040
041        // Notifies OpenLCB Sensor managers that the loading of XML is complete.
042        for (OlcbConfigurationManager cfg : InstanceManager.getList(OlcbConfigurationManager
043                .class)) {
044            cfg.getStringIOManager().finishLoad();
045        }
046        
047        return result;
048    }
049
050//    private final static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(OlcbStringIOManagerXml.class);
051}