Skip to content

Commit

Permalink
Refactor ConditionalNGs to be children of LogixNGs
Browse files Browse the repository at this point in the history
  • Loading branch information
dsand47 committed May 13, 2021
1 parent 5399e8c commit 1255297
Show file tree
Hide file tree
Showing 36 changed files with 1,211 additions and 1,195 deletions.
82 changes: 44 additions & 38 deletions java/src/jmri/jmrit/logixng/ConditionalNG_Manager.java
Expand Up @@ -7,55 +7,60 @@

/**
* Manager for ConditionalNG
*
*
* @author Dave Duchamp Copyright (C) 2007
* @author Daniel Bergqvist Copyright (C) 2018
* @author Dave Sand Copyright (C) 2021
*/
public interface ConditionalNG_Manager extends Manager<ConditionalNG> {

/**
* Create a new ConditionalNG if the ConditionalNG does not exist.
*
* @param systemName the system name
* @param userName the user name
* @param logixNG The parent LogixNG
* @param systemName The system name
* @param userName The user name
* @return a new ConditionalNG or null if unable to create
*/
public ConditionalNG createConditionalNG(String systemName, String userName)
public ConditionalNG createConditionalNG(LogixNG logixNG, String systemName, String userName)
throws IllegalArgumentException;

/**
* For use with User GUI, to allow the auto generation of systemNames, where
* the user can optionally supply a username.
*
* @param userName the user name
* @param logixNG The parent LogixNG
* @param userName The user name
* @return a new ConditionalNG or null if unable to create
*/
public ConditionalNG createConditionalNG(String userName)
public ConditionalNG createConditionalNG(LogixNG logixNG, String userName)
throws IllegalArgumentException;

/**
* Create a new ConditionalNG if the ConditionalNG does not exist.
*
* @param systemName the system name
* @param userName the user name
* @param threadID the thread ID that this ConditionalNG will execute on
* @param logixNG The parent LogixNG
* @param systemName The system name
* @param userName The user name
* @param threadID The thread ID that this ConditionalNG will execute on
* @return a new ConditionalNG or null if unable to create
*/
public ConditionalNG createConditionalNG(
String systemName, String userName, int threadID)
LogixNG logixNG, String systemName, String userName, int threadID)
throws IllegalArgumentException;

/**
* For use with User GUI, to allow the auto generation of systemNames, where
* the user can optionally supply a username.
*
* @param userName the user name
* @param threadID the thread ID that this ConditionalNG will execute on
* @param logixNG The parent LogixNG
* @param userName The user name
* @param threadID The thread ID that this ConditionalNG will execute on
* @return a new ConditionalNG or null if unable to create
*/
public ConditionalNG createConditionalNG(String userName, int threadID)
public ConditionalNG createConditionalNG(LogixNG logixNG, String userName, int threadID)
throws IllegalArgumentException;

/**
* Locate via user name, then system name if needed. Does not create a new
* one if nothing found
Expand All @@ -64,45 +69,46 @@ public ConditionalNG createConditionalNG(String userName, int threadID)
* @return null if no match found
*/
public ConditionalNG getConditionalNG(String name);


/**
* Find the LogixNG which has the ConditionalNG system name in its ConditionalNG_Entry list.
* @param systemName The ConditionalNG system name.
* @return the parent LogixNG or null if none found.
*/
public LogixNG getParentLogixNG(String systemName);

/**
* Find the ConditionalNG which is a member of the LogixNG with the supplied user name.
* @param logixNG The LogixNG that contains the requested ConditionalNG.
* @param name The requested ConditionalNG user name.
* @return the ConditionalNG or null if none found.
*/
public ConditionalNG getByUserName(LogixNG logixNG, String name);

/** {@inheritDoc} */
@Override
public ConditionalNG getByUserName(String name);

/** {@inheritDoc} */
@Override
public ConditionalNG getBySystemName(String name);

/**
* {@inheritDoc}
*
*
* The sub system prefix for the ConditionalNG_Manager is
* {@link #getSystemNamePrefix() } and "C";
*/
@Override
public default String getSubSystemNamePrefix() {
return getSystemNamePrefix() + "C";
}

/**
* Create a new system name for a ConditionalNG.
* @return a new system name
*/
public String getAutoSystemName();

/**
* Resolve all the ConditionalNG trees.
* <P>
* This method ensures that everything in the ConditionalNG tree has a pointer
* to its parent.
*/
public void resolveAllTrees();

/**
* Setup all ConditionalNGs. This method is called after a configuration file is
* loaded.
*/
public void setupAllConditionalNGs();

/**
* Delete ConditionalNG by removing it from the manager. The ConditionalNG must first
Expand All @@ -114,11 +120,11 @@ public default String getSubSystemNamePrefix() {

/**
* Support for loading ConditionalNGs in a disabled state
*
*
* @param s true if ConditionalNG should be disabled when loaded
*/
public void setLoadDisabled(boolean s);

/**
* Set whenether execute() should run on the GUI thread at once or should
* dispatch the call until later, for all ConditionalNGs registered in this
Expand Down
20 changes: 13 additions & 7 deletions java/src/jmri/jmrit/logixng/LogixNG.java
Expand Up @@ -4,8 +4,9 @@

/**
* LogixNG.
*
*
* @author Daniel Bergqvist Copyright 2018
* @author Dave Sand Copyright 2021
*/
public interface LogixNG extends Base, NamedBean {

Expand All @@ -14,33 +15,33 @@ public interface LogixNG extends Base, NamedBean {
* <P>
* This method must call registerListeners() / unregisterListeners() and
* also call execute() if enable is true.
*
*
* @param enable true if this LogixNG should be enabled, false otherwise
*/
public void setEnabled(boolean enable);

/**
* Determines whether this LogixNG is enabled.
*
*
* @return true if the LogixNG is enabled, false otherwise
*/
@Override
public boolean isEnabled();

/**
* Set the system name for the conditionalNG at the specified position in this list
* @param index index of the element to set the system name
* @return the system name
*/
public String getConditionalNG_SystemName(int index);

/**
* Set the system name for the conditionalNG at the specified position in this list
* @param index index of the element to set the system name
* @param systemName the new system name
*/
public void setConditionalNG_SystemName(int index, String systemName);

/**
* Get number of ConditionalNGs for this LogixNG.
*
Expand Down Expand Up @@ -70,6 +71,11 @@ public interface LogixNG extends Base, NamedBean {

/**
* Add a child ConditionalNG to the parent LogixNG.
* <p>
* The first part handles adding conditionalNGs to the LogixNG list
* during file loading.
* <p>
* The second part handles normal additions using the GUI, Logix imports or tests.
*
* @param conditionalNG The ConditionalNG object.
* @return true if the ConditionalNG was added, false otherwise.
Expand Down

0 comments on commit 1255297

Please sign in to comment.