001package jmri.jmrix.openlcb.configurexml;
002
003import jmri.InstanceManager;
004import jmri.jmrix.openlcb.OlcbConfigurationManager;
005
006import org.jdom2.Element;
007import javax.annotation.Nonnull;
008
009/**
010 * Provides load and store functionality for configuring OlcbLightManagers.
011 * <p>
012 * Uses the store method from the abstract base class, but provides a load
013 * method here.
014 *
015 * @author Jeff Collell
016 */
017public class OlcbLightManagerXml extends jmri.managers.configurexml.AbstractLightManagerConfigXML {
018
019    public OlcbLightManagerXml() {
020        super();
021    }
022
023    @Override
024    public void setStoreElementClass(Element lights) {
025        lights.setAttribute("class", this.getClass().getName());
026    }
027
028    @Override
029    public boolean load(@Nonnull Element shared, Element perNode) {
030        boolean result;
031        // We tell the Light managers that we will be loading Lights from XML and they should
032        // expect additional property set sequences. This is somewhat tricky in the face of
033        // possibly multiple OpenLCB buses registered.
034        for (OlcbConfigurationManager cfg : InstanceManager.getList(OlcbConfigurationManager
035                .class)) {
036            cfg.getLightManager().startLoad();
037        }
038
039        // load individual lights
040        result = loadLights(shared);
041
042        // Notifies OpenLCB Light managers that the loading of XML is complete.
043        for (OlcbConfigurationManager cfg : InstanceManager.getList(OlcbConfigurationManager
044                .class)) {
045            cfg.getLightManager().finishLoad();
046        }
047        
048        return result;
049    }
050
051//    private final static Logger log = LoggerFactory.getLogger(OlcbLightManagerXml.class);
052}