001package jmri.jmrit.audio.configurexml;
002
003import jmri.InstanceManager;
004import jmri.managers.configurexml.AbstractAudioManagerConfigXML;
005import org.jdom2.Element;
006
007/**
008 * Persistency implementation for the default AudioManager persistence.
009 * <p>
010 * The state of audio objects is not persisted, just their existence.
011 *
012 * <hr>
013 * This file is part of JMRI.
014 * <p>
015 * JMRI is free software; you can redistribute it and/or modify it under the
016 * terms of version 2 of the GNU General Public License as published by the Free
017 * Software Foundation. See the "COPYING" file for a copy of this license.
018 * <p>
019 * JMRI is distributed in the hope that it will be useful, but WITHOUT ANY
020 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
021 * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
022 *
023 * @author Matthew Harris copyright (c) 2009
024 */
025public class DefaultAudioManagerXml extends AbstractAudioManagerConfigXML {
026
027    /**
028     * Default constructor
029     */
030    public DefaultAudioManagerXml() {
031    }
032
033    /**
034     * Subclass provides implementation to create the correct top element,
035     * including the type information. Default implementation is to use the
036     * local class here.
037     *
038     * @param audio The top-level element being created
039     */
040    @Override
041    public void setStoreElementClass(Element audio) {
042        audio.setAttribute("class", "jmri.jmrit.audio.configurexml.DefaultAudioManagerXml");
043    }
044
045    /**
046     * Create a AudioManager object of the correct class, then register and fill
047     * it.
048     *
049     * @param shared Top level Element to unpack.
050     * @param perNode Per-node top level Element to unpack.
051     * @return true if successful
052     */
053    @Override
054    public boolean load(Element shared, Element perNode) {
055        // create the master object
056        InstanceManager.getDefault(jmri.AudioManager.class);
057        // load individual shared objects
058        loadAudio(shared);
059        return true;
060    }
061}