001package jmri.jmrit.logixng;
002
003import java.beans.PropertyVetoException;
004
005import javax.annotation.Nonnull;
006
007import jmri.Manager;
008import jmri.NamedBean;
009
010/**
011 * Base interface for the LogixNG action and expression managers.
012 * 
013 * @param <E> the type of NamedBean supported by this manager
014 * 
015 * @author Daniel Bergqvist 2020
016 */
017public interface BaseManager<E extends NamedBean> extends Manager<E> {
018    
019    /**
020     * Remember a NamedBean Object created outside the manager.
021     * <p>
022     * The non-system-specific SignalHeadManagers use this method extensively.
023     *
024     * @param maleSocket the bean
025     * @return the registered bean with attached male sockets
026     * @throws NamedBean.DuplicateSystemNameException if a different bean with the same
027     *                                                system name is already registered in
028     *                                                the manager
029     */
030    E registerBean(@Nonnull E maleSocket);
031    
032    /**
033     * Method for a UI to delete a bean.
034     * <p>
035     * The UI should first request a "CanDelete", this will return a list of
036     * locations (and descriptions) where the bean is in use via throwing a
037     * VetoException, then if that comes back clear, or the user agrees with the
038     * actions, then a "DoDelete" can be called which inform the listeners to
039     * delete the bean, then it will be deregistered and disposed of.
040     * <p>
041     * If a property name of "DoNotDelete" is thrown back in the VetoException
042     * then the delete process should be aborted.
043     *
044     * @param maleSocket The MaleSocket to be deleted
045     * @param property   The programmatic name of the request. "CanDelete" will
046     *                   enquire with all listeners if the item can be deleted.
047     *                   "DoDelete" tells the listener to delete the item
048     * @throws java.beans.PropertyVetoException If the recipients wishes the
049     *                                          delete to be aborted (see above)
050     */
051    void deleteBean(@Nonnull MaleSocket maleSocket, @Nonnull String property) throws PropertyVetoException;
052    
053    /**
054     * Get the default male socket class
055     * @return the class
056     */
057    Class<? extends MaleSocket> getMaleSocketClass();
058    
059    /**
060     * Get the last item registered in the mananger.
061     * @return the last item
062     */
063    MaleSocket getLastRegisteredMaleSocket();
064    
065    /**
066     * Register a male socket factory.
067     * @param factory the factory
068     */
069    void registerMaleSocketFactory(MaleSocketFactory<E> factory);
070    
071}