Package ghidra.program.database.data

# Class ProgramDataTypeManager

java.lang.Object
ghidra.program.database.data.DataTypeManagerDB
ghidra.program.database.data.ProgramBasedDataTypeManagerDB
ghidra.program.database.data.ProgramDataTypeManager

All Implemented Interfaces:
  `ManagerDB`, `DataTypeManager`, `DomainFileBasedDataTypeManager`, `FileBasedDataTypeManager`, `ProgramBasedDataTypeManager`

public class ProgramDataTypeManager extends ProgramBasedDataTypeManagerDB implements ManagerDB
Class for managing data types in a program

- ## Field Summary

  ### 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
  Constructor
  Description
  `ProgramDataTypeManager(DBHandle handle, AddressMap addrMap, int openMode, ErrorHandler errHandler, Lock lock, TaskMonitor monitor)`
  Constructor

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `allowsDefaultBuiltInSettings()`
  Determine if settings are supported for BuiltIn datatypes within this datatype manager.
  `protected void`
  `categoryCreated(Category newCategory)`
  `protected void`
  `categoryMoved(CategoryPath oldPath, Category category)`
  `protected void`
  `categoryRemoved(Category parent, String name, long categoryID)`
  `protected void`
  `categoryRenamed(CategoryPath oldPath, Category category)`
  `void`
  `close()`
  Closes this dataType manager
  `protected void`
  `dataSettingChanged(Address dataAddr)`
  Provides notification when a data instance setting has changed at a specific address.
  `protected void`
  `dataTypeAdded(DataType newDt, DataType originalDataType)`
  `void`
  `dataTypeChanged(DataType dt, boolean isAutoChange)`
  Notification when data type is changed.
  `protected void`
  `dataTypeDeleted(long deletedID, DataTypePath deletedDataTypePath)`
  `protected void`
  `dataTypeMoved(DataType dt, DataTypePath oldPath, DataTypePath newPath)`
  `protected void`
  `dataTypeNameChanged(DataType dt, String oldName)`
  `protected void`
  `dataTypeReplaced(long existingDtID, DataTypePath existingPath, DataType replacementDt)`
  `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
  `protected void`
  `favoritesChanged(DataType dataType, boolean isFavorite)`
  `void`
  `flushEvents()`
  Force all pending notification events to be flushed
  `DomainFile`
  `getDomainFile()`
  `String`
  `getDomainFileID()`
  `String`
  `getName()`
  Returns this data type manager's name
  `String`
  `getPath()`
  `Program`
  `getProgram()`
  Get the program instance associated with this datatype manager
  `ArchiveType`
  `getType()`
  Returns this manager's archive type
  `void`
  `invalidateCache(boolean all)`
  Clears all data caches.
  `boolean`
  `isUpdatable()`
  Returns true if this DataTypeManager can be modified.
  `void`
  `languageChanged(TaskMonitor monitor)`
  Update program-architecture information following a language upgrade/change
  `Transaction`
  `openTransaction(String description)`
  Open new transaction.
  `void`
  `programReady(int openMode, int currentRevision, TaskMonitor monitor)`
  Callback from program made to each manager after the program has completed initialization.
  `protected void`
  `replaceDataTypeIDs(long oldDataTypeID, long newDataTypeID)`
  Replace all datatype uses external to the datatype manager if applicable.
  `void`
  `saveDataOrganization()`
  Save the current data organization to facilitate future change detection and upgrades.
  `void`
  `setName(String name)`
  Sets this data type manager's name
  `void`
  `setProgram(ProgramDB p)`
  Callback from program used to indicate all manager have been created.
  `protected void`
  `sourceArchiveAdded(UniversalID sourceArchiveID)`
  `void`
  `sourceArchiveChanged(UniversalID sourceArchiveID)`
  `int`
  `startTransaction(String description)`
  Starts a transaction for making changes in this data type manager.

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

  `clearAllSettings, clearSetting, deleteAddressRange, getInstanceSettingsNames, getLongSettingsValue, getSettings, getStringSettingsValue, initializeOtherAdapters, invalidateCache, isChangeAllowed, isEmptySetting, moveAddressRange, setLongSettingsValue, setSettings, setStringSettingsValue`

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

  `addDataType, addDataTypeManagerListener, addDataTypes, addDataTypeToDelete, addInvalidatedListener, allowsDefaultComponentSettings, associateDataTypeWithArchive, compilerSpecChanged, contains, containsCategory, createCategory, dataTypeSettingsChanged, dbError, disassociate, dispose, doSourceArchiveUpdates, 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, getProgramArchitectureSummary, getResolvedID, getRootCategory, getSourceArchive, getSourceArchive, getSourceArchives, getUniqueName, getUniversalID, getUnusedConflictName, getUnusedConflictName, getVariableStorageManager, handleDataOrganizationChange, hasDataOrganizationChange, isChanged, isCreatingDataType, isFavorite, isTransactionActive, migrateOldFlexArrayComponentsIfRequired, readDataOrganization, remove, removeDataTypeManagerListener, removeInvalidatedListener, removeSourceArchive, replaceDataType, replaceSourceArchive, resolve, resolveSourceArchive, setFavorite, setProgramArchitecture, updateID, updateLastChangeTime, updateSourceArchiveName, updateSourceArchiveName`

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

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

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

  `addDataType, addDataTypeManagerListener, addDataTypes, addInvalidatedListener, allowsDefaultComponentSettings, associateDataTypeWithArchive, contains, containsCategory, createCategory, disassociate, findDataType, findDataTypeForID, findDataTypes, findDataTypes, findEnumValueNames, getAddressMap, getAllComposites, getAllDataTypes, getAllDataTypes, getAllFunctionDefinitions, getAllStructures, getCallingConvention, getCategory, getCategory, getCategoryCount, getDataOrganization, getDataType, getDataType, getDataType, getDataType, getDataType, getDataTypeCount, getDataTypes, getDataTypesContaining, getDefaultCallingConvention, getDefinedCallingConventionNames, getFavorites, getID, getKnownCallingConventionNames, getLastChangeTimeForMyManager, getLocalSourceArchive, getPointer, getPointer, getProgramArchitecture, getProgramArchitectureSummary, getResolvedID, getRootCategory, getSourceArchive, getSourceArchives, getUniqueName, getUniversalID, isFavorite, remove, removeDataTypeManagerListener, removeInvalidatedListener, removeSourceArchive, replaceDataType, resolve, resolveSourceArchive, setFavorite, updateSourceArchiveName, updateSourceArchiveName`

  ### Methods inherited from interface ghidra.program.database.ManagerDB

  `deleteAddressRange, dispose, moveAddressRange`

- ## Constructor Details

  - ### ProgramDataTypeManager

    public ProgramDataTypeManager(DBHandle handle, AddressMap addrMap, int openMode, ErrorHandler errHandler, Lock lock, TaskMonitor monitor) throws CancelledException, VersionException, IOException
    Constructor
    Parameters:
      `handle` - open database handle
      `addrMap` - the address map
      `openMode` - the program open mode (see `DBConstants`)
      `errHandler` - the database io error handler
      `lock` - the program synchronization lock
      `monitor` - the progress monitor
    Throws:
      `CancelledException` - if the user cancels an upgrade
      `VersionException` - if the database does not match the expected version.
      `IOException` - if a database IO error occurs.

- ## Method Details

  - ### saveDataOrganization

    public void saveDataOrganization() throws IOException
    Save the current data organization to facilitate future change detection and upgrades. This method must be invoked by `ProgramDB` during the final stage of program creation (i.e., openMode == CREATE).
    Overrides:
      `saveDataOrganization` in class `DataTypeManagerDB`
    Throws:
      `IOException` - if failure occured while saving data organization.

  - ### dataSettingChanged

    protected void dataSettingChanged(Address dataAddr)
    Description copied from class: `ProgramBasedDataTypeManagerDB`
    Provides notification when a data instance setting has changed at a specific address.
    Specified by:
      `dataSettingChanged` in class `ProgramBasedDataTypeManagerDB`
    Parameters:
      `dataAddr` - data address

  - ### allowsDefaultBuiltInSettings

    public boolean allowsDefaultBuiltInSettings()
    Description copied from interface: `DataTypeManager`
    Determine if settings are supported for BuiltIn datatypes within this datatype manager.
    Specified by:
      `allowsDefaultBuiltInSettings` in interface `DataTypeManager`
    Overrides:
      `allowsDefaultBuiltInSettings` in class `DataTypeManagerDB`
    Returns:
      true if BuiltIn Settings are permitted

  - ### setProgram

    public void setProgram(ProgramDB p)
    Description copied from interface: `ManagerDB`
    Callback from program used to indicate all manager have been created. When this method is invoked, all managers have been instantiated but may not be fully initialized.
    Specified by:
      `setProgram` in interface `ManagerDB`
    Parameters:
      `p` - the program is set when all the initializations have been completed.

  - ### invalidateCache

    public void invalidateCache(boolean all) throws IOException
    Description copied from interface: `ManagerDB`
    Clears all data caches.
    Specified by:
      `invalidateCache` in interface `ManagerDB`
    Parameters:
      `all` - if false, some managers may not need to update their cache if they can tell that its not necessary. If this flag is true, then all managers should clear their cache no matter what.
    Throws:
      `IOException` - if a database io error occurs.

  - ### programReady

    public void programReady(int openMode, int currentRevision, TaskMonitor monitor) throws IOException, CancelledException
    Description copied from interface: `ManagerDB`
    Callback from program made to each manager after the program has completed initialization. This method may be used by managers to perform additional upgrading which may have been deferred.
    Specified by:
      `programReady` in interface `ManagerDB`
    Parameters:
      `openMode` - the mode that the program is being opened.
      `currentRevision` - current program revision. If openMode is UPGRADE, this value reflects the pre-upgrade value.
      `monitor` - the task monitor to use in any upgrade operations.
    Throws:
      `IOException` - if a database io error occurs.
      `CancelledException` - if the user cancelled the operation via the task monitor.

  - ### languageChanged

    public void languageChanged(TaskMonitor monitor) throws IOException, CancelledException
    Update program-architecture information following a language upgrade/change
    Parameters:
      `monitor` - task monitor
    Throws:
      `IOException` - if IO error occurs
      `CancelledException` - if task monitor cancelled

  - ### 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)

  - ### sourceArchiveChanged

    public void sourceArchiveChanged(UniversalID sourceArchiveID)
    Overrides:
      `sourceArchiveChanged` in class `DataTypeManagerDB`

  - ### sourceArchiveAdded

    protected void sourceArchiveAdded(UniversalID sourceArchiveID)
    Overrides:
      `sourceArchiveAdded` in class `DataTypeManagerDB`

  - ### dataTypeChanged

    public void dataTypeChanged(DataType dt, boolean isAutoChange)
    Description copied from class: `DataTypeManagerDB`
    Notification when data type is changed.
    Overrides:
      `dataTypeChanged` in class `DataTypeManagerDB`
    Parameters:
      `dt` - data type that is changed
      `isAutoChange` - true if change was an automatic change in response to another datatype's change (e.g., size, alignment).

  - ### dataTypeAdded

    protected void dataTypeAdded(DataType newDt, DataType originalDataType)
    Overrides:
      `dataTypeAdded` in class `DataTypeManagerDB`

  - ### dataTypeReplaced

    protected void dataTypeReplaced(long existingDtID, DataTypePath existingPath, DataType replacementDt)
    Overrides:
      `dataTypeReplaced` in class `DataTypeManagerDB`

  - ### dataTypeDeleted

    protected void dataTypeDeleted(long deletedID, DataTypePath deletedDataTypePath)
    Overrides:
      `dataTypeDeleted` in class `DataTypeManagerDB`

  - ### dataTypeMoved

    protected void dataTypeMoved(DataType dt, DataTypePath oldPath, DataTypePath newPath)
    Overrides:
      `dataTypeMoved` in class `DataTypeManagerDB`

  - ### dataTypeNameChanged

    protected void dataTypeNameChanged(DataType dt, String oldName)
    Overrides:
      `dataTypeNameChanged` in class `DataTypeManagerDB`

  - ### categoryCreated

    protected void categoryCreated(Category newCategory)
    Overrides:
      `categoryCreated` in class `DataTypeManagerDB`

  - ### categoryRenamed

    protected void categoryRenamed(CategoryPath oldPath, Category category)
    Overrides:
      `categoryRenamed` in class `DataTypeManagerDB`

  - ### categoryRemoved

    protected void categoryRemoved(Category parent, String name, long categoryID)
    Overrides:
      `categoryRemoved` in class `DataTypeManagerDB`

  - ### categoryMoved

    protected void categoryMoved(CategoryPath oldPath, Category category)
    Overrides:
      `categoryMoved` in class `DataTypeManagerDB`

  - ### favoritesChanged

    protected void favoritesChanged(DataType dataType, boolean isFavorite)
    Overrides:
      `favoritesChanged` in class `DataTypeManagerDB`

  - ### replaceDataTypeIDs

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

  - ### deleteDataTypeIDs

    protected void deleteDataTypeIDs(LinkedList<Long> deletedIds, TaskMonitor monitor) throws CancelledException
    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
    Throws:
      `CancelledException` - if operation cancelled

  - ### isUpdatable

    public boolean isUpdatable()
    Description copied from interface: `DataTypeManager`
    Returns true if this DataTypeManager can be modified.
    Specified by:
      `isUpdatable` in interface `DataTypeManager`
    Overrides:
      `isUpdatable` in class `DataTypeManagerDB`
    Returns:
      true if this DataTypeMangaer can be modified.

  - ### 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

  - ### close

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

  - ### getProgram

    public Program getProgram()
    Description copied from interface: `ProgramBasedDataTypeManager`
    Get the program instance associated with this datatype manager
    Specified by:
      `getProgram` in interface `ProgramBasedDataTypeManager`
    Returns:
      program instance associated with this datatype manager

  - ### getDomainFile

    public DomainFile getDomainFile()
    Specified by:
      `getDomainFile` in interface `DomainFileBasedDataTypeManager`

  - ### getDomainFileID

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

  - ### getPath

    public String getPath()
    Specified by:
      `getPath` in interface `FileBasedDataTypeManager`
    Specified by:
      `getPath` in class `DataTypeManagerDB`

  - ### getType

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