001package jmri;
002
003import java.util.ArrayList;
004import java.util.List;
005import java.util.Objects;
006import java.util.Set;
007
008import javax.annotation.CheckForNull;
009import javax.annotation.Nonnull;
010import jmri.managers.AbstractManager;
011
012import jmri.jmrit.display.layoutEditor.LayoutEditor;
013
014/**
015 * Basic Implementation of a SectionManager.
016 * <p>
017 * This doesn't have a "new" interface, since Sections are independently
018 * implemented, instead of being system-specific.
019 * <p>
020 * Note that Section system names must begin with system prefix and type character,
021 * usually IY, and be followed by a string, usually, but not always, a number. This
022 * is enforced when a Section is created.
023 * <br>
024 * <hr>
025 * This file is part of JMRI.
026 * <p>
027 * JMRI is free software; you can redistribute it and/or modify it under the
028 * terms of version 2 of the GNU General Public License as published by the Free
029 * Software Foundation. See the "COPYING" file for a copy of this license.
030 * <p>
031 * JMRI is distributed in the hope that it will be useful, but WITHOUT ANY
032 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
033 * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
034 *
035 * @author Dave Duchamp Copyright (C) 2008
036 */
037public interface SectionManager extends Manager<Section> {
038
039    // void addListeners();
040
041    /**
042     * Create a new Section if the Section does not exist.
043     *
044     * @param systemName the desired system name
045     * @param userName   the desired user name
046     * @return a new Section or
047     * @throws IllegalArgumentException if a Section with the same systemName or
048     *         userName already exists, or if there is trouble creating a new
049     *         Section.
050     */
051    @Nonnull
052    public Section createNewSection(@Nonnull String systemName, String userName) throws IllegalArgumentException;
053
054    /**
055     * Create a New Section with Auto System Name.
056     * @param userName UserName for new Section
057     * @return new Section with Auto System Name.
058     * @throws IllegalArgumentException if existing Section, or
059     *          unable to create a new Section.
060     */
061    @Nonnull
062    public Section createNewSection(String userName) throws IllegalArgumentException;
063
064    /**
065     * Remove an existing Section.
066     *
067     * @param y the section to remove
068     */
069    public void deleteSection(Section y);
070
071    /**
072     * Get an existing Section. First look up assuming that name is a User
073     * Name. If this fails look up assuming that name is a System Name.
074     *
075     * @param name the name to find; user names are searched for a match first,
076     *             followed by system names
077     * @return the found section of null if no matching Section found
078     */
079    public Section getSection(String name);
080
081    /**
082     * Validate all Sections.
083     *
084     * @return number or validation errors; -2 is returned if there are no sections
085     */
086    public int validateAllSections();
087
088    /**
089     * Check direction sensors in SSL for signals.
090     *
091     * @return the number or errors; 0 if no errors; -1 if the panel is null; -2 if there are no sections
092     */
093    public int setupDirectionSensors();
094
095    /**
096     * Remove direction sensors from SSL for all signals.
097     *
098     * @return the number or errors; 0 if no errors; -1 if the panel is null; -2 if there are no sections
099     */
100    public int removeDirectionSensorsFromSSL();
101
102    /**
103     * Initialize all blocking sensors that exist - set them to 'ACTIVE'.
104     */
105    public void initializeBlockingSensors();
106
107    /**
108     * Generate Block Sections in stubs/sidings. Called after generating signal logic.
109     */
110    public void generateBlockSections();
111
112}