Package ghidra.program.model.data

# Class StandAloneDataTypeManager

java.lang.Object
ghidra.program.database.data.DataTypeManagerDB
ghidra.program.model.data.StandAloneDataTypeManager

All Implemented Interfaces:
  `DataTypeManager`, `Closeable`, `AutoCloseable`

Direct Known Subclasses:
  `BuiltInDataTypeManager`, `FileDataTypeManager`, `ProjectDataTypeManager`

public class StandAloneDataTypeManager extends DataTypeManagerDB implements Closeable
Basic implementation of the DataTypeManger interface

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static enum`
  `StandAloneDataTypeManager.ArchiveWarning`
  `static enum`
  `StandAloneDataTypeManager.ArchiveWarningLevel`
  `static enum`
  `StandAloneDataTypeManager.LanguageUpdateOption`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected String`
  `name`

  ### Fields inherited from class ghidra.program.database.data.DataTypeManagerDB

  `addrMap, dbHandle, DEFAULT_CALLING_CONVENTION_ID, defaultListener, errHandler, lock, readOnlyMode, sourceArchiveAdapter, tablePrefix, universalID, UNKNOWN_CALLING_CONVENTION_ID`

  ### Fields inherited from interface ghidra.program.model.data.DataTypeManager

  `BAD_DATATYPE_ID, BUILT_IN_ARCHIVE_KEY, BUILT_IN_ARCHIVE_UNIVERSAL_ID, BUILT_IN_DATA_TYPES_NAME, DEFAULT_DATATYPE_ID, LOCAL_ARCHIVE_KEY, LOCAL_ARCHIVE_UNIVERSAL_ID, NULL_DATATYPE_ID`

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `StandAloneDataTypeManager(DBHandle handle, int openMode, ErrorHandler errHandler, Lock lock, TaskMonitor monitor)`
  Constructor for a data-type manager using a specified DBHandle.
  `protected`
  `StandAloneDataTypeManager(ResourceFile packedDbfile, int openMode, TaskMonitor monitor)`
  Constructor for a data-type manager backed by a packed database file.
  ``
  `StandAloneDataTypeManager(String rootName)`
  Constructor for new temporary data-type manager using the default DataOrganization.
  ``
  `StandAloneDataTypeManager(String rootName, DataOrganization dataOrganzation)`
  Constructor for new temporary data-type manager using a specified DataOrganization.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `clearProgramArchitecture(TaskMonitor monitor)`
  Clear the program architecture setting and all architecture-specific data from this archive.
  `void`
  `close()`
  Closes this dataType manager
  `protected void`
  `deleteDataTypeIDs(LinkedList<Long> deletedIds, TaskMonitor monitor)`
  Delete all datatype uses external to the datatype manager if applicable.
  `void`
  `endTransaction(int transactionID, boolean commit)`
  Ends the current transaction
  `void`
  `finalize()`
  `void`
  `flushEvents()`
  Force all pending notification events to be flushed
  `protected String`
  `getDomainFileID()`
  `String`
  `getName()`
  Returns this data type manager's name
  `String`
  `getPath()`
  Get the path name associated with the storage of this stand alone datatype manager.
  `String`
  `getProgramArchitectureSummary()`
  Get the program architecture information which has been associated with this datatype manager.
  `ArchiveType`
  `getType()`
  Returns this manager's archive type
  `StandAloneDataTypeManager.ArchiveWarning`
  `getWarning()`
  Get the `StandAloneDataTypeManager.ArchiveWarning` which may have occured immediately following instatiation of this `StandAloneDataTypeManager`.
  `Exception`
  `getWarningDetail()`
  Get the detail exception associated with `StandAloneDataTypeManager.ArchiveWarning.LANGUAGE_NOT_FOUND` or `StandAloneDataTypeManager.ArchiveWarning.COMPILER_SPEC_NOT_FOUND` warning (see `getWarning()`) immediately following instatiation of this `StandAloneDataTypeManager`.
  `String`
  `getWarningMessage(boolean includeDetails)`
  Get a suitable warning message.
  `protected void`
  `handleDataOrganizationChange(int openMode, TaskMonitor monitor)`
  `protected void`
  `initializeOtherAdapters(int openMode, TaskMonitor monitor)`
  Initialize other DB adapters after base implementation adapters has been initialized.
  `protected boolean`
  `isArchitectureChangeAllowed()`
  Determine if a program architecture change is permitted
  `boolean`
  `isProgramArchitectureMissing()`
  Indicates that a failure occured establishing the program architecture for the associated archive.
  `boolean`
  `isProgramArchitectureUpgradeRequired()`
  Indicates that an program architecture upgrade is required in order to constitute associated data.
  `protected void`
  `logWarning()`
  Due to the supression of error and warning conditions during instantiation this method should be invoked at the end of instatiation when `getName()` and `getPath()` are ready to be invoked safely.
  `Transaction`
  `openTransaction(String description)`
  Open new transaction.
  `protected void`
  `replaceDataTypeIDs(long oldID, long newID)`
  Replace all datatype uses external to the datatype manager if applicable.
  `void`
  `setName(String name)`
  Sets this data type manager's name
  `void`
  `setProgramArchitecture(Language language, CompilerSpecID compilerSpecId, StandAloneDataTypeManager.LanguageUpdateOption updateOption, TaskMonitor monitor)`
  Establish the program architecture for this datatype manager.
  `protected void`
  `setProgramArchitecture(ProgramArchitecture programArchitecture, VariableStorageManager variableStorageMgr, boolean store, TaskMonitor monitor)`
  Set the architecture-specific details associated with a new datatype manager.
  `int`
  `startTransaction(String description)`
  Starts a transaction for making changes in this data type manager.

  ### Methods inherited from class ghidra.program.database.data.DataTypeManagerDB

  `addDataType, addDataTypeManagerListener, addDataTypes, addDataTypeToDelete, addInvalidatedListener, allowsDefaultBuiltInSettings, allowsDefaultComponentSettings, associateDataTypeWithArchive, categoryCreated, categoryMoved, categoryRemoved, categoryRenamed, compilerSpecChanged, contains, containsCategory, createCategory, dataTypeAdded, dataTypeChanged, dataTypeDeleted, dataTypeMoved, dataTypeNameChanged, dataTypeReplaced, dataTypeSettingsChanged, dbError, disassociate, dispose, doSourceArchiveUpdates, favoritesChanged, findDataType, findDataTypeForID, findDataTypes, findDataTypes, findEnumValueNames, fixupComposites, getAddressMap, getAllComposites, getAllDataTypes, getAllDataTypes, getAllFunctionDefinitions, getAllStructures, getCallingConvention, getCallingConventionID, getCallingConventionName, getCategory, getCategory, getCategoryCount, getDataMap, getDataOrganization, getDataType, getDataType, getDataType, getDataType, getDataType, getDataTypeCount, getDataTypes, getDataTypes, getDataTypesContaining, getDefaultCallingConvention, getDefinedCallingConventionNames, getFavorites, getID, getKnownCallingConventionNames, getLastChangeTimeForMyManager, getLocalSourceArchive, getPointer, getPointer, getProgramArchitecture, getProgramArchitectureSummary, getResolvedID, getRootCategory, getSourceArchive, getSourceArchive, getSourceArchives, getUniqueName, getUniversalID, getUnusedConflictName, getUnusedConflictName, getVariableStorageManager, hasDataOrganizationChange, invalidateCache, isChanged, isCreatingDataType, isFavorite, isTransactionActive, isUpdatable, migrateOldFlexArrayComponentsIfRequired, readDataOrganization, remove, removeDataTypeManagerListener, removeInvalidatedListener, removeSourceArchive, replaceDataType, replaceSourceArchive, resolve, resolveSourceArchive, saveDataOrganization, setFavorite, sourceArchiveAdded, sourceArchiveChanged, updateID, updateLastChangeTime, updateSourceArchiveName, updateSourceArchiveName`

  ### Methods inherited from class java.lang.Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### name

    protected String name

- ## Constructor Details

  - ### StandAloneDataTypeManager

    public StandAloneDataTypeManager(String rootName) throws RuntimeIOException
    Constructor for new temporary data-type manager using the default DataOrganization. Note that this manager does not support the save or saveAs operation.
    Parameters:
      `rootName` - Name of the root category.
    Throws:
      `RuntimeIOException` - if database error occurs during creation

  - ### StandAloneDataTypeManager

    public StandAloneDataTypeManager(String rootName, DataOrganization dataOrganzation) throws RuntimeIOException
    Constructor for new temporary data-type manager using a specified DataOrganization. Note that this manager does not support the save or saveAs operation.
    Parameters:
      `rootName` - Name of the root category.
      `dataOrganzation` - applicable data organization
    Throws:
      `RuntimeIOException` - if database error occurs during creation

  - ### StandAloneDataTypeManager

    protected StandAloneDataTypeManager(ResourceFile packedDbfile, int openMode, TaskMonitor monitor) throws IOException, CancelledException
    Constructor for a data-type manager backed by a packed database file. When opening for UPDATE an automatic upgrade will be performed if required.

    NOTE: `logWarning()` should be invoked immediately after instantiating a `StandAloneDataTypeManager` for an existing database after `getName()` and `getPath()` can be invoked safely. In addition, it may be appropriate to use `check for warnings` prior to use.

    Parameters:
      `packedDbfile` - packed datatype archive file (i.e., *.gdt resource).
      `openMode` - open mode CREATE, READ_ONLY or UPDATE (see `DBConstants`)
      `monitor` - the progress monitor
    Throws:
      `IOException` - a low-level IO error. This exception may also be thrown when a version error occurs (cause is VersionException).
      `CancelledException` - if task cancelled

  - ### StandAloneDataTypeManager

    protected StandAloneDataTypeManager(DBHandle handle, int openMode, ErrorHandler errHandler, Lock lock, TaskMonitor monitor) throws CancelledException, VersionException, IOException
    Constructor for a data-type manager using a specified DBHandle.

    NOTE: `logWarning()` should be invoked immediately after instantiating a `StandAloneDataTypeManager` for an existing database after `getName()` and `getPath()` can be invoked safely. In addition, it may be appropriate to use `check for warnings` prior to use.

    Parameters:
      `handle` - open database handle
      `openMode` - open mode CREATE, READ_ONLY or UPDATE (see `DBConstants`)
      `errHandler` - the database I/O error handler
      `lock` - the program synchronization lock
      `monitor` - the progress monitor
    Throws:
      `CancelledException` - if task cancelled
      `VersionException` - if the database does not match the expected version.
      `IOException` - if a database I/O error occurs.

- ## Method Details

  - ### getWarning

    public StandAloneDataTypeManager.ArchiveWarning getWarning()
    Get the `StandAloneDataTypeManager.ArchiveWarning` which may have occured immediately following instatiation of this `StandAloneDataTypeManager`. `StandAloneDataTypeManager.ArchiveWarning.NONE` will be returned if not warning condition.
    Returns:
      warning type.

  - ### getWarningDetail

    public Exception getWarningDetail()
    Get the detail exception associated with `StandAloneDataTypeManager.ArchiveWarning.LANGUAGE_NOT_FOUND` or `StandAloneDataTypeManager.ArchiveWarning.COMPILER_SPEC_NOT_FOUND` warning (see `getWarning()`) immediately following instatiation of this `StandAloneDataTypeManager`.
    Returns:
      warning detail exception or null

  - ### getWarningMessage

    public String getWarningMessage(boolean includeDetails)
    Get a suitable warning message. See `getWarning()` for type and its severity level `StandAloneDataTypeManager.ArchiveWarning.level()`.
    Parameters:
      `includeDetails` - if false simple message returned, otherwise more details are included.
    Returns:
      warning message or null if `getWarning()` is `StandAloneDataTypeManager.ArchiveWarning.NONE`.

  - ### logWarning

    protected void logWarning()
    Due to the supression of error and warning conditions during instantiation this method should be invoked at the end of instatiation when `getName()` and `getPath()` are ready to be invoked safely. Logging will be performed via `Msg`.

  - ### initializeOtherAdapters

    protected void initializeOtherAdapters(int openMode, TaskMonitor monitor) throws CancelledException, IOException, VersionException
    Description copied from class: `DataTypeManagerDB`
    Initialize other DB adapters after base implementation adapters has been initialized.
    Overrides:
      `initializeOtherAdapters` in class `DataTypeManagerDB`
    Parameters:
      `openMode` - the DB open mode (see `DBConstants`)
      `monitor` - the progress monitor
    Throws:
      `CancelledException` - if the user cancels an upgrade
      `IOException` - if a database IO error occurs.
      `VersionException` - if the database does not match the expected version.

  - ### handleDataOrganizationChange

    protected void handleDataOrganizationChange(int openMode, TaskMonitor monitor) throws LanguageVersionException, CancelledException, IOException
    Overrides:
      `handleDataOrganizationChange` in class `DataTypeManagerDB`
    Throws:
      `LanguageVersionException`
      `CancelledException`
      `IOException`

  - ### getProgramArchitectureSummary

    public String getProgramArchitectureSummary()
    Get the program architecture information which has been associated with this datatype manager. If `DataTypeManagerDB.getProgramArchitecture()` returns null this method may still return information if the program architecture was set on an archive and either `isProgramArchitectureMissing()` or `isProgramArchitectureUpgradeRequired()` returns true.
    Specified by:
      `getProgramArchitectureSummary` in interface `DataTypeManager`
    Overrides:
      `getProgramArchitectureSummary` in class `DataTypeManagerDB`
    Returns:
      program architecture summary if it has been set

  - ### isProgramArchitectureUpgradeRequired

    public boolean isProgramArchitectureUpgradeRequired()
    Indicates that an program architecture upgrade is required in order to constitute associated data. If true, the associated archive must be open for update to allow the upgrade to complete, or a new program architecture may be set/cleared if such an operation is supported.
    Returns:
      true if a program architecture upgrade is required, else false

  - ### isProgramArchitectureMissing

    public boolean isProgramArchitectureMissing()
    Indicates that a failure occured establishing the program architecture for the associated archive.
    Returns:
      true if a failure occured establishing the program architecture

  - ### clearProgramArchitecture

    public void clearProgramArchitecture(TaskMonitor monitor) throws CancelledException, IOException, LockException
    Clear the program architecture setting and all architecture-specific data from this archive. Archive will revert to using the default `DataOrganization`. Archive must be open for update for this method to be used.
    Parameters:
      `monitor` - task monitor
    Throws:
      `CancelledException` - if task cancelled. If thrown, this data type manager is no longer stable and should be closed without saving.
      `IOException` - if IO error occurs
      `LockException` - failure if exclusive access is required
      `javax.help.UnsupportedOperationException` - if architecture change is not permitted by implementation (e.g., `BuiltInDataTypeManager`).

  - ### setProgramArchitecture

    public void setProgramArchitecture(Language language, CompilerSpecID compilerSpecId, StandAloneDataTypeManager.LanguageUpdateOption updateOption, TaskMonitor monitor) throws CompilerSpecNotFoundException, LanguageNotFoundException, IOException, CancelledException, LockException, javax.help.UnsupportedOperationException, IncompatibleLanguageException
    Establish the program architecture for this datatype manager. The current setting can be determined from `DataTypeManagerDB.getProgramArchitecture()`. Archive must be open for update for this method to be used.
    Parameters:
      `language` - language
      `compilerSpecId` - compiler specification ID defined by the language.
      `updateOption` - indicates how variable storage data should be transitioned. If `isProgramArchitectureMissing()` is true and `StandAloneDataTypeManager.LanguageUpdateOption.TRANSLATE` specified, the translator will be based on whatever language version can be found. In this situation it may be best to force a `StandAloneDataTypeManager.LanguageUpdateOption.CLEAR`.
      `monitor` - task monitor (cancel not permitted to avoid corrupt state)
    Throws:
      `CompilerSpecNotFoundException` - if invalid compilerSpecId specified for language
      `LanguageNotFoundException` - if current language is not found (if required for data transition)
      `IOException` - if IO error occurs
      `CancelledException` - if task cancelled. If thrown, this data type manager is no longer stable and should be closed without saving.
      `LockException` - failure if exclusive access is required
      `javax.help.UnsupportedOperationException` - if architecture change is not permitted
      `IncompatibleLanguageException` - if translation requested but not possible due to incompatible language architectures

  - ### setProgramArchitecture

    protected void setProgramArchitecture(ProgramArchitecture programArchitecture, VariableStorageManager variableStorageMgr, boolean store, TaskMonitor monitor) throws IOException, CancelledException
    Set the architecture-specific details associated with a new datatype manager. This method is intended to be used during instantiation of derived implementations.
    Overrides:
      `setProgramArchitecture` in class `DataTypeManagerDB`
    Parameters:
      `programArchitecture` - program architecture details (required)
      `variableStorageMgr` - variable storage manager. Must be null.
      `store` - if true database update will occur and datatypes will be updated if any change to the data organization is detected (a stored copy may be used to detect this condition). This should never be passed as true if opened read-only. If true and no variable storage is specified it will be created.
      `monitor` - task monitor
    Throws:
      `IOException` - if IO error occurs
      `CancelledException` - if task cancelled
      `javax.help.UnsupportedOperationException` - if language was previously set

  - ### isArchitectureChangeAllowed

    protected boolean isArchitectureChangeAllowed()
    Determine if a program architecture change is permitted
    Returns:
      true if change allowed else false if disallowed

  - ### getName

    public String getName()
    Description copied from interface: `DataTypeManager`
    Returns this data type manager's name
    Specified by:
      `getName` in interface `DataTypeManager`
    Returns:
      the name

  - ### setName

    public void setName(String name) throws InvalidNameException
    Description copied from interface: `DataTypeManager`
    Sets this data type manager's name
    Specified by:
      `setName` in interface `DataTypeManager`
    Parameters:
      `name` - the new name
    Throws:
      `InvalidNameException` - if the given name is invalid (such as when null or empty)

  - ### openTransaction

    public Transaction openTransaction(String description) throws IllegalStateException
    Description copied from interface: `DataTypeManager`
    Open new transaction. This should generally be done with a try-with-resources block:

         try (Transaction tx = dtm.openTransaction(description)) {
                // ... Do something
         }

    Specified by:
      `openTransaction` in interface `DataTypeManager`
    Parameters:
      `description` - a short description of the changes to be made.
    Returns:
      transaction object
    Throws:
      `IllegalStateException` - if this `DataTypeManager` has already been closed.

  - ### startTransaction

    public int startTransaction(String description)
    Description copied from interface: `DataTypeManager`
    Starts a transaction for making changes in this data type manager.
    Specified by:
      `startTransaction` in interface `DataTypeManager`
    Parameters:
      `description` - a short description of the changes to be made.
    Returns:
      the transaction ID

  - ### flushEvents

    public void flushEvents()
    Description copied from interface: `DataTypeManager`
    Force all pending notification events to be flushed
    Specified by:
      `flushEvents` in interface `DataTypeManager`

  - ### endTransaction

    public void endTransaction(int transactionID, boolean commit)
    Description copied from interface: `DataTypeManager`
    Ends the current transaction
    Specified by:
      `endTransaction` in interface `DataTypeManager`
    Parameters:
      `transactionID` - id of the transaction to end
      `commit` - true if changes are committed, false if changes in transaction are revoked

  - ### replaceDataTypeIDs

    protected void replaceDataTypeIDs(long oldID, long newID)
    Description copied from class: `DataTypeManagerDB`
    Replace all datatype uses external to the datatype manager if applicable.
    Specified by:
      `replaceDataTypeIDs` in class `DataTypeManagerDB`
    Parameters:
      `oldID` - old datatype ID
      `newID` - new datatype ID

  - ### deleteDataTypeIDs

    protected void deleteDataTypeIDs(LinkedList<Long> deletedIds, TaskMonitor monitor)
    Description copied from class: `DataTypeManagerDB`
    Delete all datatype uses external to the datatype manager if applicable.
    Specified by:
      `deleteDataTypeIDs` in class `DataTypeManagerDB`
    Parameters:
      `deletedIds` - old datatype IDs which were deleted
      `monitor` - task monitor

  - ### close

    public void close()
    Description copied from interface: `DataTypeManager`
    Closes this dataType manager
    Specified by:
      `close` in interface `AutoCloseable`
    Specified by:
      `close` in interface `Closeable`
    Specified by:
      `close` in interface `DataTypeManager`
    Overrides:
      `close` in class `DataTypeManagerDB`

  - ### finalize

    public void finalize()
    Overrides:
      `finalize` in class `Object`

  - ### getDomainFileID

    protected String getDomainFileID()
    Specified by:
      `getDomainFileID` in class `DataTypeManagerDB`

  - ### getPath

    public String getPath()
    Get the path name associated with the storage of this stand alone datatype manager.
    Specified by:
      `getPath` in class `DataTypeManagerDB`
    Returns:
      path name or null if not applicable

  - ### getType

    public ArchiveType getType()
    Description copied from interface: `DataTypeManager`
    Returns this manager's archive type
    Specified by:
      `getType` in interface `DataTypeManager`
    Returns:
      the type