001package jmri.jmrit.logixng; 002 003import jmri.Manager; 004 005/** 006 * Manager for ConditionalNG 007 * 008 * @author Dave Duchamp Copyright (C) 2007 009 * @author Daniel Bergqvist Copyright (C) 2018 010 * @author Dave Sand Copyright (C) 2021 011 */ 012public interface ConditionalNG_Manager extends Manager<ConditionalNG> { 013 014 /** 015 * Create a new ConditionalNG if the ConditionalNG does not exist. 016 * 017 * @param logixNG The parent LogixNG 018 * @param systemName The system name 019 * @param userName The user name 020 * @return a new ConditionalNG or null if unable to create 021 */ 022 ConditionalNG createConditionalNG(LogixNG logixNG, String systemName, String userName) 023 throws IllegalArgumentException; 024 025 /** 026 * For use with User GUI, to allow the auto generation of systemNames, where 027 * the user can optionally supply a username. 028 * 029 * @param logixNG The parent LogixNG 030 * @param userName The user name 031 * @return a new ConditionalNG or null if unable to create 032 */ 033 ConditionalNG createConditionalNG(LogixNG logixNG, String userName) 034 throws IllegalArgumentException; 035 036 /** 037 * Create a new ConditionalNG if the ConditionalNG does not exist. 038 * 039 * @param logixNG The parent LogixNG 040 * @param systemName The system name 041 * @param userName The user name 042 * @param threadID The thread ID that this ConditionalNG will execute on 043 * @return a new ConditionalNG or null if unable to create 044 */ 045 ConditionalNG createConditionalNG( 046 LogixNG logixNG, String systemName, String userName, int threadID) 047 throws IllegalArgumentException; 048 049 /** 050 * For use with User GUI, to allow the auto generation of systemNames, where 051 * the user can optionally supply a username. 052 * 053 * @param logixNG The parent LogixNG 054 * @param userName The user name 055 * @param threadID The thread ID that this ConditionalNG will execute on 056 * @return a new ConditionalNG or null if unable to create 057 */ 058 ConditionalNG createConditionalNG(LogixNG logixNG, String userName, int threadID) 059 throws IllegalArgumentException; 060 061 /** 062 * Locate via user name using the LogixNG, then system name if needed. Does not create a new 063 * one if nothing found 064 * 065 * @param logixNG The LogixNG for the user name match. If null, only do a system name match. 066 * @param name User name or system name to match 067 * @return null if no match found 068 */ 069 ConditionalNG getConditionalNG(LogixNG logixNG, String name); 070 071 /** 072 * Find the LogixNG which has the ConditionalNG system name in its ConditionalNG_Entry list. 073 * @param systemName The ConditionalNG system name. 074 * @return the parent LogixNG or null if none found. 075 */ 076 LogixNG getParentLogixNG(String systemName); 077 078 /** 079 * Find the ConditionalNG which is a member of the LogixNG with the supplied user name. 080 * @param logixNG The LogixNG that contains the requested ConditionalNG. 081 * @param name The requested ConditionalNG user name. 082 * @return the ConditionalNG or null if none found. 083 */ 084 ConditionalNG getByUserName(LogixNG logixNG, String name); 085 086 /** {@inheritDoc} */ 087 @Override 088 ConditionalNG getByUserName(String name); 089 090 /** {@inheritDoc} */ 091 @Override 092 ConditionalNG getBySystemName(String name); 093 094 /** 095 * {@inheritDoc} 096 * 097 * The sub system prefix for the ConditionalNG_Manager is 098 * {@link #getSystemNamePrefix() } and "C"; 099 */ 100 @Override 101 default String getSubSystemNamePrefix() { 102 return getSystemNamePrefix() + "C"; 103 } 104 105 /** 106 * Create a new system name for a ConditionalNG. 107 * @return a new system name 108 */ 109 String getAutoSystemName(); 110 111 /** 112 * Delete ConditionalNG by removing it from the manager. The ConditionalNG must first 113 * be deactivated so it stops processing. 114 * 115 * @param x the ConditionalNG to delete 116 */ 117 void deleteConditionalNG(ConditionalNG x); 118 119 /** 120 * Support for loading ConditionalNGs in a disabled state 121 * 122 * @param s true if ConditionalNG should be disabled when loaded 123 */ 124 void setLoadDisabled(boolean s); 125 126 /** 127 * Set whenether execute() should run on the GUI thread at once or should 128 * dispatch the call until later, for all ConditionalNGs registered in this 129 * manager. 130 * Most tests turns off the delay to simplify the tests. 131 * @param value true if execute() should run on GUI thread delayed, 132 * false otherwise. 133 */ 134 void setRunOnGUIDelayed(boolean value); 135 136}