Package ghidra.program.model.data
Interface DataTypeManager
-
- All Known Subinterfaces:
DomainFileBasedDataTypeManager
,FileArchiveBasedDataTypeManager
,FileBasedDataTypeManager
,ProgramBasedDataTypeManager
,ProjectArchiveBasedDataTypeManager
- All Known Implementing Classes:
BuiltInDataTypeManager
,DataTypeManagerDB
,FileDataTypeManager
,ProgramDataTypeManager
,ProjectDataTypeManager
,StandAloneDataTypeManager
public interface DataTypeManager
Interface for Managing data types.
-
-
Field Summary
Fields Modifier and Type Field Description static long
BAD_DATATYPE_ID
ID if data type type is BAD.static long
BUILT_IN_ARCHIVE_KEY
static UniversalID
BUILT_IN_ARCHIVE_UNIVERSAL_ID
static java.lang.String
BUILT_IN_DATA_TYPES_NAME
Name of the category for the build in data types.static long
DEFAULT_DATATYPE_ID
ID for the default (undefined) data type.static long
LOCAL_ARCHIVE_KEY
static UniversalID
LOCAL_ARCHIVE_UNIVERSAL_ID
static long
NULL_DATATYPE_ID
ID if data type type is not known in this data type manager.
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description DataType
addDataType(DataType dataType, DataTypeConflictHandler handler)
Returns a data type after adding it to this data manager.void
addDataTypeManagerListener(DataTypeManagerChangeListener l)
Add a listener that is notified when the dataTypeManger changes.void
addInvalidatedListener(InvalidatedListener listener)
Adds a listener that will be notified when this manager's cache is invalidated.void
associateDataTypeWithArchive(DataType datatype, SourceArchive archive)
void
close()
Closes this dataType manager.boolean
contains(DataType dataType)
Return true if the given dataType exists in this data type manager.boolean
containsCategory(CategoryPath path)
Returns true if the given category path exists in this datatype manager.Category
createCategory(CategoryPath path)
void
dataTypeChanged(DataType dataType)
Notification when data type is changed.void
disassociate(DataType datatype)
If the indicated data type is associated with a source archive, this will remove the association and the data type will become local to this data type manager.void
endTransaction(int transactionID, boolean commit)
Ends the current transactionDataType
findDataType(java.lang.String dataTypePath)
Deprecated.usegetDataType(String)
or better yetgetDataType(DataTypePath)
DataType
findDataTypeForID(UniversalID datatypeID)
Get's the data type with the matching universal data type id.void
findDataTypes(java.lang.String name, java.util.List<DataType> list)
Begin searching at the root category for all data types with the given name.void
findDataTypes(java.lang.String name, java.util.List<DataType> list, boolean caseSensitive, TaskMonitor monitor)
Begin searching at the root category for all data types with names that match the given name that may contain wildcards.void
findEnumValueNames(long value, java.util.Set<java.lang.String> enumValueNames)
Adds all enum value names that match the given value, to the given set.void
flushEvents()
java.util.Iterator<Composite>
getAllComposites()
Returns an iterator over all composite data types (structures and unions) in this manager.java.util.Iterator<DataType>
getAllDataTypes()
Returns an iterator over all the dataTypes in this managervoid
getAllDataTypes(java.util.List<DataType> list)
Adds all data types to the specified list.java.util.Iterator<Structure>
getAllStructures()
Returns an iterator over all structures in this manager.Category
getCategory(long categoryID)
Returns the Category with the given id.Category
getCategory(CategoryPath path)
Get the category that has the given path.int
getCategoryCount()
Returns the total number of data type categoriesDataOrganization
getDataOrganization()
Get the data organization associated with this data type managerDataType
getDataType(long dataTypeID)
Returns the dataType associated with the given dataTypeId or null if the dataTypeId is not valid.DataType
getDataType(SourceArchive sourceArchive, UniversalID datatypeID)
DataType
getDataType(CategoryPath path, java.lang.String name)
Gets the data type with the indicated name in the indicated category.DataType
getDataType(DataTypePath dataTypePath)
Find the dataType for the given dataTypePath.DataType
getDataType(java.lang.String dataTypePath)
Retrieve the data type with the fully qualified path.int
getDataTypeCount(boolean includePointersAndArrays)
Returns the total number of defined data types.java.util.List<DataType>
getDataTypes(SourceArchive sourceArchive)
java.util.Set<DataType>
getDataTypesContaining(DataType dataType)
Returns the data types within this data type manager that contain the specified data type.java.util.List<DataType>
getFavorites()
Returns a list of datatypes that have been designated as favorites.long
getID(DataType dt)
Returns the dataTypeId for the given dataType.long
getLastChangeTimeForMyManager()
SourceArchive
getLocalSourceArchive()
java.lang.String
getName()
Returns this data type manager's name.Pointer
getPointer(DataType datatype)
Returns a default sized pointer to the given datatype.Pointer
getPointer(DataType datatype, int size)
Returns a pointer of the given size to the given datatype.long
getResolvedID(DataType dt)
Returns the dataTypeId for the given dataType.Category
getRootCategory()
Returns the root category ManagerSourceArchive
getSourceArchive(UniversalID sourceID)
java.util.List<SourceArchive>
getSourceArchives()
Returns a list of source archives not including the builtin or the program's archive.ArchiveType
getType()
java.lang.String
getUniqueName(CategoryPath path, java.lang.String baseName)
Returns a unique name not currently used by any other dataType or category with the same baseName.UniversalID
getUniversalID()
Returns the universal ID for this dataType manager.boolean
isFavorite(DataType datatype)
Returns true if the given datatype has been designated as a favorite.boolean
isUpdatable()
Returns true if this DataTypeManager can be modified.boolean
remove(DataType dataType, TaskMonitor monitor)
Remove the given datatype from this managervoid
removeDataTypeManagerListener(DataTypeManagerChangeListener l)
Remove the DataTypeManger change listener.void
removeInvalidatedListener(InvalidatedListener listener)
Removes a previously added InvalidatedListenervoid
removeSourceArchive(SourceArchive sourceArchive)
DataType
replaceDataType(DataType existingDt, DataType replacementDt, boolean updateCategoryPath)
Replace an existing dataType with another.DataType
resolve(DataType dataType, DataTypeConflictHandler handler)
Returns a dataType that is "in" (ie suitable implementation) this Manager, creating a new one if necessary.SourceArchive
resolveSourceArchive(SourceArchive sourceArchive)
void
setFavorite(DataType datatype, boolean isFavorite)
Sets the given dataType to be either a favorite or not a favorite.void
setName(java.lang.String name)
Sets this data type manager's name.int
startTransaction(java.lang.String description)
Starts a transaction for making changes in this data type manager.boolean
updateSourceArchiveName(UniversalID sourceID, java.lang.String name)
Updates the name associated with a source archive in this data type manager.boolean
updateSourceArchiveName(java.lang.String archiveFileID, java.lang.String name)
Updates the name associated with a source archive in this data type manager.
-
-
-
Field Detail
-
DEFAULT_DATATYPE_ID
static final long DEFAULT_DATATYPE_ID
ID for the default (undefined) data type.- See Also:
- Constant Field Values
-
NULL_DATATYPE_ID
static final long NULL_DATATYPE_ID
ID if data type type is not known in this data type manager.- See Also:
- Constant Field Values
-
BAD_DATATYPE_ID
static final long BAD_DATATYPE_ID
ID if data type type is BAD.- See Also:
- Constant Field Values
-
BUILT_IN_DATA_TYPES_NAME
static final java.lang.String BUILT_IN_DATA_TYPES_NAME
Name of the category for the build in data types.- See Also:
- Constant Field Values
-
LOCAL_ARCHIVE_KEY
static final long LOCAL_ARCHIVE_KEY
- See Also:
- Constant Field Values
-
BUILT_IN_ARCHIVE_KEY
static final long BUILT_IN_ARCHIVE_KEY
- See Also:
- Constant Field Values
-
LOCAL_ARCHIVE_UNIVERSAL_ID
static final UniversalID LOCAL_ARCHIVE_UNIVERSAL_ID
-
BUILT_IN_ARCHIVE_UNIVERSAL_ID
static final UniversalID BUILT_IN_ARCHIVE_UNIVERSAL_ID
-
-
Method Detail
-
getUniversalID
UniversalID getUniversalID()
Returns the universal ID for this dataType manager.
-
containsCategory
boolean containsCategory(CategoryPath path)
Returns true if the given category path exists in this datatype manager.- Parameters:
path
-- Returns:
-
getUniqueName
java.lang.String getUniqueName(CategoryPath path, java.lang.String baseName)
Returns a unique name not currently used by any other dataType or category with the same baseName.- Parameters:
baseName
- the base name to be made unique.- Returns:
- a unique name starting with baseName.
-
resolve
DataType resolve(DataType dataType, DataTypeConflictHandler handler)
Returns a dataType that is "in" (ie suitable implementation) this Manager, creating a new one if necessary. Also the returned dataType will be in a category in this dataTypeManager that is equivalent to the category of the passed in dataType.- Parameters:
dataType
- the dataType to be resolved.handler
- used to resolve conflicts with existing dataTypes.- Returns:
- an equivalent dataType that "belongs" to this dataTypeManager.
-
addDataType
DataType addDataType(DataType dataType, DataTypeConflictHandler handler)
Returns a data type after adding it to this data manager. The returned dataType will be in a category in this dataTypeManager that is equivalent to the category of the passed in dataType.- Parameters:
dataType
- the dataType to be resolved.handler
- used to resolve conflicts with existing dataTypes.- Returns:
- an equivalent dataType that "belongs" to this dataTypeManager.
-
getAllDataTypes
java.util.Iterator<DataType> getAllDataTypes()
Returns an iterator over all the dataTypes in this manager
-
getAllDataTypes
void getAllDataTypes(java.util.List<DataType> list)
Adds all data types to the specified list.- Parameters:
list
-
-
getAllStructures
java.util.Iterator<Structure> getAllStructures()
Returns an iterator over all structures in this manager.
-
getAllComposites
java.util.Iterator<Composite> getAllComposites()
Returns an iterator over all composite data types (structures and unions) in this manager.
-
findDataTypes
void findDataTypes(java.lang.String name, java.util.List<DataType> list)
Begin searching at the root category for all data types with the given name. Places all the data types in this data type manager with the given name into the list.- Parameters:
name
- name of the data typelist
- list that will be populated with matching DataType objects
-
findDataTypes
void findDataTypes(java.lang.String name, java.util.List<DataType> list, boolean caseSensitive, TaskMonitor monitor)
Begin searching at the root category for all data types with names that match the given name that may contain wildcards.- Parameters:
name
- name to match; may contain wildcardslist
- list that will be populated with matching DataType objectscaseSensitive
- true if the match is case sensitivemonitor
- task monitor to cancel the search
-
replaceDataType
DataType replaceDataType(DataType existingDt, DataType replacementDt, boolean updateCategoryPath) throws DataTypeDependencyException
Replace an existing dataType with another. All instances and references will be updated to use the replacement dataType.- Parameters:
existingDt
- the dataType to be replaced.replacementDt
- the dataType to use as the replacement.updateCategoryPath
- if true, the replacementDt will have its categoryPath changed to the exitingDt's path.- Returns:
- the resolved replacement dataType.
- Throws:
DataTypeDependencyException
- if the replacement datatype depends on the existing dataType;
-
getDataType
DataType getDataType(java.lang.String dataTypePath)
Retrieve the data type with the fully qualified path. So you can get the data named "bar" in the category "foo" by calling getDataType("/foo/bar"). This method can be problematic now that datatype names can contain slashes. It will work provided that the part of the datatype name that precedes its internal slash is not also the name of a category in the same category as the datatype. For example, if you call getDataType("/a/b/c"), and "b/c" is the name of your datatype, it will find it unless there is also a category "b" under category "a". A better solution is to use thegetDataType(DataTypePath)
method because the DataTypePath keeps the category and datatype name separate.- Parameters:
dataType
- path;- Returns:
- the dataType or null if it isn't found.
-
findDataType
@Deprecated DataType findDataType(java.lang.String dataTypePath)
Deprecated.usegetDataType(String)
or better yetgetDataType(DataTypePath)
Gets the dataType for the given path. SeegetDataType(String)
for details.- Parameters:
dataTypePath
- dataType path- Returns:
- dataType at the given path
-
getDataType
DataType getDataType(DataTypePath dataTypePath)
Find the dataType for the given dataTypePath.- Parameters:
dataTypePath
- the DataTypePath for the datatype- Returns:
- the datatype for the given path.
-
getResolvedID
long getResolvedID(DataType dt)
Returns the dataTypeId for the given dataType. If the dataType is not currently in the dataTypeManger, it will be added.
-
getID
long getID(DataType dt)
Returns the dataTypeId for the given dataType. If the dataType does not exist, a -1 will be returned- Parameters:
dt
- the datatype to get an id for.
-
getDataType
DataType getDataType(long dataTypeID)
Returns the dataType associated with the given dataTypeId or null if the dataTypeId is not valid.
-
getCategory
Category getCategory(long categoryID)
Returns the Category with the given id.- Parameters:
categoryID
- id of the desired category.
-
getCategory
Category getCategory(CategoryPath path)
Get the category that has the given path.
-
dataTypeChanged
void dataTypeChanged(DataType dataType)
Notification when data type is changed.- Parameters:
dataType
- data type that is changed
-
addDataTypeManagerListener
void addDataTypeManagerListener(DataTypeManagerChangeListener l)
Add a listener that is notified when the dataTypeManger changes.- Parameters:
l
- the listener
-
removeDataTypeManagerListener
void removeDataTypeManagerListener(DataTypeManagerChangeListener l)
Remove the DataTypeManger change listener.- Parameters:
l
- the listener
-
addInvalidatedListener
void addInvalidatedListener(InvalidatedListener listener)
Adds a listener that will be notified when this manager's cache is invalidated. This will happen when the system has changed and the manager cannot determine the exact change, like during an undo or a redo.- Parameters:
listener
- The listener to add
-
removeInvalidatedListener
void removeInvalidatedListener(InvalidatedListener listener)
Removes a previously added InvalidatedListener- Parameters:
listener
- the listener to remove.
-
remove
boolean remove(DataType dataType, TaskMonitor monitor)
Remove the given datatype from this manager- Parameters:
dataType
- the dataType to be removed.monitor
- the task monitor
-
contains
boolean contains(DataType dataType)
Return true if the given dataType exists in this data type manager.
-
createCategory
Category createCategory(CategoryPath path)
- Parameters:
path
-
-
getDataType
DataType getDataType(CategoryPath path, java.lang.String name)
Gets the data type with the indicated name in the indicated category.- Parameters:
path
- the path for the categoryname
- the data type's name- Returns:
- the data type.
-
getName
java.lang.String getName()
Returns this data type manager's name.
-
setName
void setName(java.lang.String name) throws InvalidNameException
Sets this data type manager's name.- Parameters:
name
- the new name- Throws:
InvalidNameException
-
startTransaction
int startTransaction(java.lang.String description)
Starts a transaction for making changes in this data type manager.- Parameters:
description
- a short description of the changes to be made.
-
isUpdatable
boolean isUpdatable()
Returns true if this DataTypeManager can be modified.- Returns:
- true if this DataTypeMangaer can be modified.
-
endTransaction
void endTransaction(int transactionID, boolean commit)
Ends the current transaction- Parameters:
transactionID
- id of the transaction to endcommit
- if true the changes are commited, otherwise all changes in transaction are revoked.
-
flushEvents
void flushEvents()
-
close
void close()
Closes this dataType manager.
-
getPointer
Pointer getPointer(DataType datatype)
Returns a default sized pointer to the given datatype. The pointer size is established dynamically based upon the data organization established by the compiler specification.- Parameters:
datatype
- the pointed to data type.
-
getPointer
Pointer getPointer(DataType datatype, int size)
Returns a pointer of the given size to the given datatype. Note: It is preferred to use default sized pointers when possible (i.e., size=-1, seegetPointer(DataType)
) instead of explicitly specifying the size value.- Parameters:
datatype
- the pointed to data type.size
- the size of the pointer to be created or -1 for a default sized pointer.
-
getRootCategory
Category getRootCategory()
Returns the root category Manager
-
isFavorite
boolean isFavorite(DataType datatype)
Returns true if the given datatype has been designated as a favorite. If the datatype does not belong to this datatype manager, then false will be returned.- Parameters:
datatype
- the datatype to check.- Returns:
- true if the given datatype is a favorite in this manager.
-
setFavorite
void setFavorite(DataType datatype, boolean isFavorite)
Sets the given dataType to be either a favorite or not a favorite.- Parameters:
datatype
- the datatype for which to change its status as a favorite.isFavorite
- true if the datatype is to be a favorite or false otherwise.- Throws:
java.lang.IllegalArgumentException
- if the given datatype does not belong to this manager.
-
getFavorites
java.util.List<DataType> getFavorites()
Returns a list of datatypes that have been designated as favorites.- Returns:
- the list of favorite datatypes in this manager.
-
getCategoryCount
int getCategoryCount()
Returns the total number of data type categories
-
getDataTypeCount
int getDataTypeCount(boolean includePointersAndArrays)
Returns the total number of defined data types.- Parameters:
includePointersAndArrays
- if true all pointers and array data types will be included.
-
findEnumValueNames
void findEnumValueNames(long value, java.util.Set<java.lang.String> enumValueNames)
Adds all enum value names that match the given value, to the given set.- Parameters:
value
- the value to look for enum name matchesenumValueNames
- the set to add matches to.
-
getDataType
DataType getDataType(SourceArchive sourceArchive, UniversalID datatypeID)
-
findDataTypeForID
DataType findDataTypeForID(UniversalID datatypeID)
Get's the data type with the matching universal data type id.- Parameters:
datatypeID
- The universal id of the data type to search for- Returns:
- The data type with the matching UUID, or null if no such data type can be found.
-
getLastChangeTimeForMyManager
long getLastChangeTimeForMyManager()
-
getSourceArchive
SourceArchive getSourceArchive(UniversalID sourceID)
-
getType
ArchiveType getType()
-
getDataTypes
java.util.List<DataType> getDataTypes(SourceArchive sourceArchive)
-
getLocalSourceArchive
SourceArchive getLocalSourceArchive()
-
associateDataTypeWithArchive
void associateDataTypeWithArchive(DataType datatype, SourceArchive archive)
-
disassociate
void disassociate(DataType datatype)
If the indicated data type is associated with a source archive, this will remove the association and the data type will become local to this data type manager.- Parameters:
datatype
- the data type to be disassociated from a source archive.
-
updateSourceArchiveName
boolean updateSourceArchiveName(java.lang.String archiveFileID, java.lang.String name)
Updates the name associated with a source archive in this data type manager.- Parameters:
archiveFileID
- Universal domain file ID of the source data type archive that has a new name.name
- the new name of the program or archive.- Returns:
- true if the name associated with the source data type archive was changed. false if it wasn't changed.
-
updateSourceArchiveName
boolean updateSourceArchiveName(UniversalID sourceID, java.lang.String name)
Updates the name associated with a source archive in this data type manager.- Parameters:
sourceID
- Universal archive ID of the source data type archive that has a new name.name
- the new name of the program or archive.- Returns:
- true if the name associated with the source data type archive was changed. false if it wasn't changed.
-
getDataOrganization
DataOrganization getDataOrganization()
Get the data organization associated with this data type manager- Returns:
- data organization (will never be null)
-
getSourceArchives
java.util.List<SourceArchive> getSourceArchives()
Returns a list of source archives not including the builtin or the program's archive.- Returns:
- a list of source archives not including the builtin or the program's archive.
-
removeSourceArchive
void removeSourceArchive(SourceArchive sourceArchive)
-
resolveSourceArchive
SourceArchive resolveSourceArchive(SourceArchive sourceArchive)
-
-