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