Interface MemoryManager
- All Superinterfaces:
Manager<Memory>,PropertyChangeProvider,ProvidingManager<Memory>,SilenceablePropertyChangeProvider,VetoableChangeProvider
- All Known Implementing Classes:
AbstractMemoryManager,DefaultMemoryManager
Memory objects are obtained from a MemoryManager, which in turn is generally located from the InstanceManager. A typical call sequence might be:
Memory memory = InstanceManager.memoryManagerInstance().provideMemory("status");
Each Memory has two names. The "user" name is entirely free form, and can be used for any purpose. The "system" name is provided by the system-specific implementations, if any, and provides a unique mapping to the layout control system (for example LocoNet or NCE) and address within that system. Note that most (all?) layout systems don't have anything corresponding to this, in which case the "Internal" Memory objects are still available with names like IM23.
Much of the bookkeeping is implemented in the AbstractMemoryManager class,
which can form the basis for a system-specific implementation.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface jmri.Manager
Manager.ManagerDataEvent<E extends NamedBean>, Manager.ManagerDataListener<E extends NamedBean>, Manager.NameValidity -
Field Summary
Fields inherited from interface jmri.Manager
ANALOGIOS, AUDIO, BLOCKBOSS, BLOCKS, CONDITIONALS, CTCDATA, ENTRYEXIT, IDTAGS, LAYOUTBLOCKS, LIGHTS, LOGIXNG_ANALOG_ACTIONS, LOGIXNG_ANALOG_EXPRESSIONS, LOGIXNG_CONDITIONALNGS, LOGIXNG_DIGITAL_ACTIONS, LOGIXNG_DIGITAL_BOOLEAN_ACTIONS, LOGIXNG_DIGITAL_EXPRESSIONS, LOGIXNG_GLOBAL_VARIABLES, LOGIXNG_MODULES, LOGIXNG_STRING_ACTIONS, LOGIXNG_STRING_EXPRESSIONS, LOGIXNG_TABLES, LOGIXNGS, LOGIXS, MEMORIES, METERFRAMES, METERS, OBLOCKS, PANELFILES, PROPERTY_BEANS, PROPERTY_CAN_DELETE, PROPERTY_DISPLAY_LIST_NAME, PROPERTY_DO_DELETE, PROPERTY_DO_NOT_DELETE, PROPERTY_LENGTH, REPORTERS, ROUTES, SECTIONS, SENSORGROUPS, SENSORS, SIGNALGROUPS, SIGNALHEADS, SIGNALMASTLOGICS, SIGNALMASTS, STRINGIOS, TIMEBASE, TRANSITS, TURNOUTS, WARRANTS -
Method Summary
Modifier and TypeMethodDescriptiongetBySystemName(String systemName) Locate an existing Memory based on a system name.getByUserName(String userName) Locate an existing Memory based on a user name.Get an existing Memory or return null if it doesn't exist.For use with User GUI, to allow the auto generation of systemNames, where the user can optionally supply a username.Return a Memory with the specified system and user names.provideMemory(String name) Get the Memory with the user name, then system name if needed; if that fails, create a new Memory.Methods inherited from interface jmri.Manager
addDataListener, deleteBean, deregister, dispose, getBeanTypeHandled, getBeanTypeHandled, getEntryToolTip, getKnownBeanProperties, getMemo, getNamedBean, getNamedBeanClass, getNamedBeanSet, getObjectCount, getSubSystemNamePrefix, getSystemNamePrefix, getSystemPrefix, getXMLOrder, isValidSystemNameFormat, makeSystemName, makeSystemName, makeSystemName, register, removeDataListener, setDataListenerMute, typeLetter, validateBadCharsInSystemNameFormat, validateIntegerSystemNameFormat, validateNmraAccessorySystemNameFormat, validateSystemNameFormat, validateSystemNameFormat, validateSystemNameFormatOnlyNumeric, validateSystemNamePrefix, validateTrimmedMin1NumberSystemNameFormat, validateTrimmedSystemNameFormat, validateUppercaseTrimmedSystemNameFormat, validSystemNameFormatMethods inherited from interface jmri.beans.PropertyChangeProvider
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListenerMethods inherited from interface jmri.ProvidingManager
provideMethods inherited from interface jmri.beans.SilenceablePropertyChangeProvider
setPropertyChangesSilencedMethods inherited from interface jmri.beans.VetoableChangeProvider
addVetoableChangeListener, addVetoableChangeListener, getVetoableChangeListeners, getVetoableChangeListeners, removeVetoableChangeListener, removeVetoableChangeListener
-
Method Details
-
provideMemory
Get the Memory with the user name, then system name if needed; if that fails, create a new Memory. If the name is a valid system name, it will be used for the new Memory. Otherwise, the makeSystemName method will attempt to turn it into a valid system name.- Parameters:
name- User name, system name, or address which can be promoted to system name- Returns:
- Never null
- Throws:
IllegalArgumentException- if Memory doesn't already exist and the manager cannot create the Memory due to an illegal name or name that can't be parsed.
-
getMemory
Get an existing Memory or return null if it doesn't exist. Locates via user name, then system name if needed.- Parameters:
name- User name or system name to match- Returns:
- null if no match found
-
getBySystemName
Locate an existing Memory based on a system name. Returns null if no instance already exists.- Specified by:
getBySystemNamein interfaceManager<Memory>- Parameters:
systemName- the system name- Returns:
- requested Memory object or null if none exists
-
getByUserName
Locate an existing Memory based on a user name. Returns null if no instance already exists.- Specified by:
getByUserNamein interfaceManager<Memory>- Parameters:
userName- the user name- Returns:
- requested Memory object or null if none exists
-
newMemory
@Nonnull Memory newMemory(@Nonnull String systemName, @CheckForNull String userName) throws IllegalArgumentException Return a Memory with the specified system and user names. Note that two calls with the same arguments will get the same instance; there is only one Memory object representing a given physical Memory and therefore only one with a specific system or user name.This will always return a valid object reference; a new object will be created if necessary. In that case:
- If a null reference is given for user name, no user name will be associated with the Memory object created; a valid system name must be provided
- If both names are provided, the system name defines the hardware access of the desired Memory, and the user address is associated with it. The system name must be valid.
- Parameters:
systemName- the system nameuserName- the user name- Returns:
- requested Memory object (never null)
- Throws:
IllegalArgumentException- if cannot create the Memory due to e.g. an illegal name or name that can't be parsed.
-
newMemory
For use with User GUI, to allow the auto generation of systemNames, where the user can optionally supply a username.This will always return a valid object reference; a new object will be created if necessary.
- Parameters:
userName- the user name, can be null- Returns:
- requested Memory object (never null)
- Throws:
IllegalArgumentException- if cannot create the Memory due to e.g. an illegal name or name that can't be parsed.
-