Package ghidra.program.database
Class DataTypeArchiveDB
java.lang.Object
ghidra.framework.data.DomainObjectAdapter
ghidra.framework.data.DomainObjectAdapterDB
ghidra.program.database.DataTypeArchiveDB
- All Implemented Interfaces:
ErrorHandler
,DataTypeManagerOwner
,DomainObject
,DataTypeManagerDomainObject
,DataTypeArchive
Database implementation for Data Type Archive.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Name of data type archive information property liststatic final String
Name of data type archive settings property liststatic final String
Name of Ghidra version propertystatic final String
Name of date created propertystatic final Date
A date from January 1, 1970Fields inherited from class ghidra.framework.data.DomainObjectAdapterDB
changeSet, dbh, NUM_UNDOS, options
Fields inherited from class ghidra.framework.data.DomainObjectAdapter
changed, changeSupportMap, DEFAULT_NAME, lock, metadata, name, temporary
Fields inherited from interface ghidra.program.model.listing.DataTypeArchive
DATA_TYPE_ARCHIVE_INFO, DATA_TYPE_ARCHIVE_SETTINGS
Fields inherited from interface ghidra.framework.model.DomainObject
DO_DOMAIN_FILE_CHANGED, DO_OBJECT_CLOSED, DO_OBJECT_ERROR, DO_OBJECT_RENAMED, DO_OBJECT_RESTORED, DO_OBJECT_SAVED, DO_PROPERTY_CHANGED, undoLock
-
Constructor Summary
ConstructorDescriptionDataTypeArchiveDB
(DBHandle dbh, OpenMode openMode, TaskMonitor monitor, Object consumer) Constructs a new DataTypeArchiveDBDataTypeArchiveDB
(DomainFolder folder, String name, Object consumer) Constructs a new DataTypeArchiveDB within a project folder. -
Method Summary
Modifier and TypeMethodDescriptionvoid
categoryAdded
(long categoryID, ProgramEvent eventType, Object oldValue, Object newValue) Notification that a category was added.void
categoryChanged
(long categoryID, ProgramEvent eventType, Object oldValue, Object newValue) Notification that a category was changed.protected void
clearCache
(boolean all) protected void
close()
void
dataTypeAdded
(long dataTypeID, ProgramEvent eventType, Object oldValue, Object newValue) Notification that a data type was added.void
dataTypeChanged
(long dataTypeID, ProgramEvent eventType, boolean isAutoResponseChange, Object oldValue, Object newValue) notification the a data type has changedprotected void
Indicates that this domain object has been restored to a completely different state due to a transaction undo/redo/rollback or a database merge operation.ghidra.program.database.DataTypeArchiveDBChangeSet
Get the data type archive changes since the last save as a set of addresses.Returns the creation date of this data type archive.Gets the associated data type manager.int
Gets the default pointer size as it may be stored within the data type archive.Returns a word or short phrase that best describes or categorizes the object in terms that a user will understand.Returns a map containing all the stored metadata associated with this domain object.boolean
Returns true if changes are permitted.protected boolean
propertyChanged
(String propertyName, Object oldValue, Object newValue) Notification of property changevoid
save
(String comment, TaskMonitor monitor) Saves changes to the DomainFile.void
saveToPackedFile
(File outputFile, TaskMonitor monitor) Saves (i.e., serializes) the current content to a packed file.protected void
setChanged
(boolean b) void
setChanged
(ProgramEvent eventType, Object oldValue, Object newValue) Mark the state this Data Type Archive as having changed and generate the event.protected void
Set theDomainFile
associated with this instance.void
Set the name for this domain object.void
updateID()
protected void
This method is called before a save, saveAs, or saveToPackedFile to update common meta dataMethods inherited from class ghidra.framework.data.DomainObjectAdapterDB
addSynchronizedDomainObject, addTransactionListener, canLock, canRedo, canSave, canUndo, clearUndo, clearUndo, dbError, endTransaction, flushWriteCache, forceLock, getAllRedoNames, getAllUndoNames, getChangeSet, getCurrentTransactionInfo, getDBHandle, getOptions, getOptionsNames, getRedoName, getSynchronizedDomainObjects, getUndoName, getUndoStackDepth, getUserData, hasTerminatedTransaction, invalidate, invalidateWriteCache, isChanged, isClosed, isLocked, loadMetadata, lock, openTransaction, performPropertyListAlterations, redo, releaseSynchronizedDomainObject, removeTransactionListener, saveMetadata, setImmutable, startTransaction, startTransaction, undo, unlock
Methods inherited from class ghidra.framework.data.DomainObjectAdapter
addCloseListener, addConsumer, addDomainFileListener, addListener, checkExclusiveAccess, createPrivateEventQueue, fatalErrorOccurred, fireEvent, flushEvents, flushPrivateEventQueue, getAssociatedUserFilesystem, getChangeStatus, getConsumerList, getContentHandler, getContentHandler, getContentHandler, getContentHandlers, getDomainFile, getLock, getModificationNumber, getName, hasExclusiveAccess, isSendingEvents, isTemporary, isUsedBy, release, removeCloseListener, removeDomainFileListener, removeListener, removePrivateEventQueue, setEventsEnabled, setTemporary, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface ghidra.program.model.listing.DataTypeArchive
hasExclusiveAccess, invalidate
Methods inherited from interface ghidra.framework.model.DomainObject
addCloseListener, addConsumer, addDomainFileListener, addListener, addSynchronizedDomainObject, addTransactionListener, canLock, canRedo, canSave, canUndo, clearUndo, createPrivateEventQueue, endTransaction, flushEvents, flushPrivateEventQueue, forceLock, getAllRedoNames, getAllUndoNames, getConsumerList, getCurrentTransactionInfo, getDomainFile, getModificationNumber, getName, getOptions, getOptionsNames, getRedoName, getSynchronizedDomainObjects, getUndoName, hasTerminatedTransaction, isChanged, isClosed, isLocked, isSendingEvents, isTemporary, isUsedBy, lock, openTransaction, redo, release, releaseSynchronizedDomainObject, removeCloseListener, removeDomainFileListener, removeListener, removePrivateEventQueue, removeTransactionListener, setEventsEnabled, setTemporary, startTransaction, startTransaction, undo, unlock, withTransaction, withTransaction
-
Field Details
-
ARCHIVE_INFO
Name of data type archive information property list- See Also:
-
ARCHIVE_SETTINGS
Name of data type archive settings property list- See Also:
-
DATE_CREATED
Name of date created property- See Also:
-
CREATED_WITH_GHIDRA_VERSION
Name of Ghidra version property- See Also:
-
JANUARY_1_1970
A date from January 1, 1970
-
-
Constructor Details
-
DataTypeArchiveDB
public DataTypeArchiveDB(DomainFolder folder, String name, Object consumer) throws IOException, DuplicateNameException, InvalidNameException Constructs a new DataTypeArchiveDB within a project folder.- Parameters:
folder
- folder within which the project archive will be createdname
- the name of the data type archiveconsumer
- the object that is using this data type archive.- Throws:
IOException
- if there is an error accessing the database.InvalidNameException
DuplicateNameException
-
DataTypeArchiveDB
public DataTypeArchiveDB(DBHandle dbh, OpenMode openMode, TaskMonitor monitor, Object consumer) throws IOException, VersionException, CancelledException Constructs a new DataTypeArchiveDB- Parameters:
dbh
- a handle to an open data type archive database.openMode
- one of: READ_ONLY: the original database will not be modified UPDATE: the database can be written to. UPGRADE: the database is upgraded to the latest schema as it is opened.monitor
- TaskMonitor that allows the open to be canceled.consumer
- the object that keeping the program open.- Throws:
IOException
- if an error accessing the database occurs.VersionException
- if database version does not match implementation, UPGRADE may be possible.CancelledException
- if instantiation is canceled by monitor
-
-
Method Details
-
close
protected void close()- Overrides:
close
in classDomainObjectAdapterDB
-
setDomainFile
Description copied from class:DomainObjectAdapter
Set theDomainFile
associated with this instance.- Overrides:
setDomainFile
in classDomainObjectAdapter
- Parameters:
df
- domain file
-
propertyChanged
Description copied from class:DomainObjectAdapterDB
Notification of property change- Overrides:
propertyChanged
in classDomainObjectAdapterDB
- Parameters:
propertyName
-oldValue
-newValue
-- Returns:
- true if change is OK, false value should be reverted
-
getDataTypeManager
Description copied from interface:DataTypeManagerOwner
Gets the associated data type manager.- Specified by:
getDataTypeManager
in interfaceDataTypeManagerOwner
- Returns:
- the data type manager.
- See Also:
-
getCreationDate
Description copied from interface:DataTypeArchive
Returns the creation date of this data type archive. existed, then Jan 1, 1970 is returned.- Specified by:
getCreationDate
in interfaceDataTypeArchive
- Returns:
- the creation date of this data type archive
- See Also:
-
getDefaultPointerSize
public int getDefaultPointerSize()Description copied from interface:DataTypeArchive
Gets the default pointer size as it may be stored within the data type archive.- Specified by:
getDefaultPointerSize
in interfaceDataTypeArchive
- Returns:
- default pointer size.
- See Also:
-
getChanges
public ghidra.program.database.DataTypeArchiveDBChangeSet getChanges()Description copied from interface:DataTypeArchive
Get the data type archive changes since the last save as a set of addresses.- Specified by:
getChanges
in interfaceDataTypeArchive
- Returns:
- set of changed addresses within program.
- See Also:
-
dataTypeChanged
public void dataTypeChanged(long dataTypeID, ProgramEvent eventType, boolean isAutoResponseChange, Object oldValue, Object newValue) notification the a data type has changed- Parameters:
dataTypeID
- the id of the data type that changed.eventType
- the type of the change (moved, renamed, etc.)isAutoResponseChange
- true if change is an auto-response change caused by another datatype's change (e.g., size, alignment), else false in which case this change will be added to archive change-set to aid merge conflict detection.oldValue
- the old data type.newValue
- the new data type.
-
dataTypeAdded
public void dataTypeAdded(long dataTypeID, ProgramEvent eventType, Object oldValue, Object newValue) Notification that a data type was added.- Parameters:
dataTypeID
- the id if the data type that was added.eventType
- should always be DATATYPE_ADDEDoldValue
- always nullnewValue
- the data type added.
-
categoryChanged
public void categoryChanged(long categoryID, ProgramEvent eventType, Object oldValue, Object newValue) Notification that a category was changed.- Parameters:
categoryID
- the id of the data type that was added.eventType
- the type of changeoldValue
- old value depends on the type.newValue
- new value depends on the type.
-
categoryAdded
public void categoryAdded(long categoryID, ProgramEvent eventType, Object oldValue, Object newValue) Notification that a category was added.- Parameters:
categoryID
- the id of the data type that was added.eventType
- the type of change (should always be CATEGORY_ADDED)oldValue
- always nullnewValue
- new value depends on the type.
-
setChanged
Mark the state this Data Type Archive as having changed and generate the event. Any or all parameters may be null.- Parameters:
eventType
- event typeoldValue
- original valuenewValue
- new value
-
setName
Description copied from interface:DomainObject
Set the name for this domain object.- Specified by:
setName
in interfaceDomainObject
- Overrides:
setName
in classDomainObjectAdapter
- Parameters:
newName
- object name
-
getDescription
Description copied from interface:DomainObject
Returns a word or short phrase that best describes or categorizes the object in terms that a user will understand.- Specified by:
getDescription
in interfaceDomainObject
- Specified by:
getDescription
in classDomainObjectAdapter
- Returns:
- the description
-
clearCache
protected void clearCache(boolean all) - Overrides:
clearCache
in classDomainObjectAdapterDB
-
isChangeable
public boolean isChangeable()Description copied from interface:DomainObject
Returns true if changes are permitted.- Specified by:
isChangeable
in interfaceDomainObject
- Returns:
- true if changes are permitted.
-
setChanged
protected void setChanged(boolean b) - Overrides:
setChanged
in classDomainObjectAdapterDB
-
save
Description copied from interface:DomainObject
Saves changes to the DomainFile.- Specified by:
save
in interfaceDomainObject
- Overrides:
save
in classDomainObjectAdapterDB
- Parameters:
comment
- comment used for new versionmonitor
- monitor that shows the progress of the save- Throws:
IOException
- thrown if there was an error accessing this domain objectCancelledException
- thrown if the user canceled the save operation
-
saveToPackedFile
public void saveToPackedFile(File outputFile, TaskMonitor monitor) throws IOException, CancelledException Description copied from interface:DomainObject
Saves (i.e., serializes) the current content to a packed file.- Specified by:
saveToPackedFile
in interfaceDomainObject
- Overrides:
saveToPackedFile
in classDomainObjectAdapterDB
- Parameters:
outputFile
- packed output filemonitor
- progress monitor- Throws:
IOException
- if an exception occursCancelledException
- if the user cancels
-
getMetadata
Description copied from interface:DomainObject
Returns a map containing all the stored metadata associated with this domain object. The map contains key,value pairs and are ordered by their insertion order.- Specified by:
getMetadata
in interfaceDomainObject
- Overrides:
getMetadata
in classDomainObjectAdapter
- Returns:
- a map containing all the stored metadata associated with this domain object.
-
updateMetadata
Description copied from class:DomainObjectAdapterDB
This method is called before a save, saveAs, or saveToPackedFile to update common meta data- Overrides:
updateMetadata
in classDomainObjectAdapterDB
- Throws:
IOException
-
updateID
public void updateID()- Specified by:
updateID
in interfaceDataTypeArchive
-
domainObjectRestored
protected void domainObjectRestored()Description copied from class:DomainObjectAdapterDB
Indicates that this domain object has been restored to a completely different state due to a transaction undo/redo/rollback or a database merge operation.- Overrides:
domainObjectRestored
in classDomainObjectAdapterDB
-