001package jmri.jmrit.logixng.implementation;
002
003import java.util.Arrays;
004import java.util.Set;
005
006import jmri.InstanceInitializer;
007import jmri.InstanceManager;
008import jmri.implementation.AbstractInstanceInitializer;
009import jmri.jmrit.logixng.*;
010import jmri.jmrix.internal.InternalSystemConnectionMemo;
011
012import org.openide.util.lookup.ServiceProvider;
013
014/**
015 * Provide the usual default implementations for the
016 * {@link jmri.InstanceManager}.
017 * <P>
018 * Not all {@link jmri.InstanceManager} related classes are provided by this
019 * class. See the discussion in {@link jmri.InstanceManager} of initialization
020 * methods.
021 * <hr>
022 * This file is part of JMRI.
023 * <P>
024 * JMRI is free software; you can redistribute it and/or modify it under the
025 * terms of version 2 of the GNU General Public License as published by the Free
026 * Software Foundation. See the "COPYING" file for a copy of this license.
027 * <P>
028 * JMRI is distributed in the hope that it will be useful, but WITHOUT ANY
029 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
030 * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
031 * <P>
032 * @author Bob Jacobsen Copyright (C) 2001, 2008, 2014
033 * @since 2.9.4
034 */
035@ServiceProvider(service = InstanceInitializer.class)
036public class LogixNG_DigitalInstanceInitializer extends AbstractInstanceInitializer {
037
038    @Override
039    public <T> Object getDefault(Class<T> type) {
040        
041        // In order for getDefault() to be called for a particular manager,
042        // the manager also needs to be added to the method getInitalizes()
043        // below.
044        
045        if (type == DigitalActionManager.class) {
046            return new DefaultDigitalActionManager();
047        }
048
049        if (type == DigitalBooleanActionManager.class) {
050            return new DefaultDigitalBooleanActionManager();
051        }
052
053        if (type == DigitalExpressionManager.class) {
054            return new DefaultDigitalExpressionManager();
055        }
056
057        return super.getDefault(type);
058    }
059
060    @Override
061    public Set<Class<?>> getInitalizes() {
062        Set<Class<?>> set = super.getInitalizes();
063        set.addAll(Arrays.asList(
064                DigitalActionManager.class,
065                DigitalBooleanActionManager.class,
066                DigitalExpressionManager.class
067        ));
068        return set;
069    }
070
071}