Package ghidra.program.database
Class DataTypeArchiveDB
java.lang.Object
ghidra.framework.data.DomainObjectAdapter
ghidra.framework.data.DomainObjectAdapterDB
ghidra.program.database.DataTypeArchiveDB
- All Implemented Interfaces:
DBConstants,ErrorHandler,DataTypeManagerOwner,DomainObject,Undoable,UndoableDomainObject,DataTypeManagerDomainObject,DataTypeArchive,DataTypeArchiveChangeManager
public class DataTypeArchiveDB
extends DomainObjectAdapterDB
implements DataTypeArchive, DataTypeArchiveChangeManager
Database implementation for Data Type Archive.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringName of data type archive information property liststatic final StringName of data type archive settings property liststatic final StringName of Ghidra version propertystatic final StringName of date created propertystatic final DateA date from January 1, 1970Fields inherited from class ghidra.framework.data.DomainObjectAdapterDB
changeSet, dbh, NUM_UNDOS, optionsFields inherited from class ghidra.framework.data.DomainObjectAdapter
changed, changeSupportMap, DEFAULT_NAME, lock, metadata, name, temporaryFields inherited from interface ghidra.program.model.listing.DataTypeArchive
DATA_TYPE_ARCHIVE_INFO, DATA_TYPE_ARCHIVE_SETTINGSFields inherited from interface ghidra.program.util.DataTypeArchiveChangeManager
DOCR_CATEGORY_ADDED, DOCR_CATEGORY_MOVED, DOCR_CATEGORY_REMOVED, DOCR_CATEGORY_RENAMED, DOCR_CUSTOM_FORMAT_ADDED, DOCR_CUSTOM_FORMAT_REMOVED, DOCR_DATA_TYPE_ADDED, DOCR_DATA_TYPE_CHANGED, DOCR_DATA_TYPE_MOVED, DOCR_DATA_TYPE_REMOVED, DOCR_DATA_TYPE_RENAMED, DOCR_DATA_TYPE_REPLACED, DOCR_DATA_TYPE_SETTING_CHANGEDFields inherited from interface db.DBConstants
CREATE, READ_ONLY, UPDATE, UPGRADEFields 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
ConstructorsConstructorDescriptionDataTypeArchiveDB(DBHandle dbh, int 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 TypeMethodDescriptionvoidcategoryAdded(long categoryID, int type, Object oldValue, Object newValue) Notification that a category was added.voidcategoryChanged(long categoryID, int type, Object oldValue, Object newValue) Notification that a category was changed.protected voidclearCache(boolean all) protected voidclose()voiddataTypeAdded(long dataTypeID, int type, Object oldValue, Object newValue) Notification that a data type was added.voiddataTypeChanged(long dataTypeID, int type, boolean isAutoResponseChange, Object oldValue, Object newValue) notification the a data type has changedghidra.program.database.DataTypeArchiveDBChangeSetGet 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.intGets 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.voidInvalidates any caching in a data type archive.booleanReturns true if changes are permitted.protected booleanpropertyChanged(String propertyName, Object oldValue, Object newValue) Notification of property changeprotected voidsetChanged(boolean b) voidsetChanged(int type, Object oldValue, Object newValue) Mark the state this Data Type Archive as having changed and generate the event.protected voidvoidSet the name for this domain object.voidsetObjChanged(int type, Object affectedObj, Object oldValue, Object newValue) Mark the state of a Program as having changed and generate the event.voidupdateID()protected voidThis 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, invalidateWriteCache, isChanged, isClosed, isLocked, loadMetadata, lock, openTransaction, performPropertyListAlterations, redo, releaseSynchronizedDomainObject, removeTransactionListener, save, saveMetadata, saveToPackedFile, startTransaction, startTransaction, undo, unlockMethods inherited from class ghidra.framework.data.DomainObjectAdapter
addCloseListener, addConsumer, addDomainFileListener, addListener, checkExclusiveAccess, createPrivateEventQueue, fatalErrorOccurred, fireEvent, flushEvents, flushPrivateEventQueue, getAssociatedUserFilesystem, getChangeStatus, getConsumerList, getContentHandler, getDomainFile, getLock, getModificationNumber, getName, hasExclusiveAccess, isSendingEvents, isTemporary, isUsedBy, release, removeCloseListener, removeDomainFileListener, removeListener, removePrivateEventQueue, setDefaultContentClass, setEventsEnabled, setTemporary, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ghidra.program.model.listing.DataTypeArchive
hasExclusiveAccessMethods inherited from interface ghidra.framework.model.DomainObject
addCloseListener, addConsumer, addDomainFileListener, addListener, canLock, canSave, createPrivateEventQueue, flushEvents, flushPrivateEventQueue, forceLock, getConsumerList, getDomainFile, getModificationNumber, getName, getOptions, getOptionsNames, isChanged, isClosed, isLocked, isSendingEvents, isTemporary, isUsedBy, lock, release, removeCloseListener, removeDomainFileListener, removeListener, removePrivateEventQueue, save, saveToPackedFile, setEventsEnabled, setTemporary, unlockMethods inherited from interface ghidra.framework.model.Undoable
addTransactionListener, canRedo, canUndo, clearUndo, getAllRedoNames, getAllUndoNames, getRedoName, getUndoName, redo, removeTransactionListener, undoMethods inherited from interface ghidra.framework.model.UndoableDomainObject
addSynchronizedDomainObject, endTransaction, getCurrentTransactionInfo, getSynchronizedDomainObjects, hasTerminatedTransaction, openTransaction, releaseSynchronizedDomainObject, startTransaction, startTransaction, 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.InvalidNameExceptionDuplicateNameException
-
DataTypeArchiveDB
public DataTypeArchiveDB(DBHandle dbh, int 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:
closein classDomainObjectAdapterDB
-
setDomainFile
- Overrides:
setDomainFilein classDomainObjectAdapter
-
propertyChanged
Description copied from class:DomainObjectAdapterDBNotification of property change- Overrides:
propertyChangedin classDomainObjectAdapterDB- Returns:
- true if change is OK, false value should be reverted
-
getDataTypeManager
Description copied from interface:DataTypeManagerOwnerGets the associated data type manager.- Specified by:
getDataTypeManagerin interfaceDataTypeManagerOwner- Returns:
- the data type manager.
- See Also:
-
getCreationDate
Description copied from interface:DataTypeArchiveReturns the creation date of this data type archive. existed, then Jan 1, 1970 is returned.- Specified by:
getCreationDatein interfaceDataTypeArchive- Returns:
- the creation date of this data type archive
- See Also:
-
getDefaultPointerSize
public int getDefaultPointerSize()Description copied from interface:DataTypeArchiveGets the default pointer size as it may be stored within the data type archive.- Specified by:
getDefaultPointerSizein interfaceDataTypeArchive- Returns:
- default pointer size.
- See Also:
-
getChanges
public ghidra.program.database.DataTypeArchiveDBChangeSet getChanges()Description copied from interface:DataTypeArchiveGet the data type archive changes since the last save as a set of addresses.- Specified by:
getChangesin interfaceDataTypeArchive- Returns:
- set of changed addresses within program.
- See Also:
-
dataTypeChanged
public void dataTypeChanged(long dataTypeID, int type, boolean isAutoResponseChange, Object oldValue, Object newValue) notification the a data type has changed- Parameters:
dataTypeID- the id of the data type that changed.type- 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
Notification that a data type was added.- Parameters:
dataTypeID- the id if the data type that was added.type- should always be DATATYPE_ADDEDoldValue- always nullnewValue- the data type added.
-
categoryChanged
Notification that a category was changed.- Parameters:
categoryID- the id of the data type that was added.type- the type of changedoldValue- old value depends on the type.newValue- new value depends on the type.
-
categoryAdded
Notification that a category was added.- Parameters:
categoryID- the id of the data type that was added.type- the type of changed (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.- Specified by:
setChangedin interfaceDataTypeArchive- Specified by:
setChangedin interfaceDataTypeArchiveChangeManager- Parameters:
type- event typeoldValue- original valuenewValue- new value
-
setObjChanged
Mark the state of a Program as having changed and generate the event. Any or all parameters may be null. NOTE: ChangeSet data will not be updated since this a very generic change not related to a specific address.- Specified by:
setObjChangedin interfaceDataTypeArchive- Specified by:
setObjChangedin interfaceDataTypeArchiveChangeManager- Parameters:
type- event typeaffectedObj- object that is the subject of the eventoldValue- original value or an Object that is related to the eventnewValue- new value or an Object that is related to the the event
-
setName
Description copied from interface:DomainObjectSet the name for this domain object.- Specified by:
setNamein interfaceDomainObject- Overrides:
setNamein classDomainObjectAdapter- Parameters:
newName- object name
-
getDescription
Description copied from interface:DomainObjectReturns a word or short phrase that best describes or categorizes the object in terms that a user will understand.- Specified by:
getDescriptionin interfaceDomainObject- Specified by:
getDescriptionin classDomainObjectAdapter- Returns:
- the description
-
clearCache
protected void clearCache(boolean all) - Overrides:
clearCachein classDomainObjectAdapterDB
-
invalidate
public void invalidate()Description copied from interface:DataTypeArchiveInvalidates any caching in a data type archive. NOTE: Over-using this method can adversely affect system performance.- Specified by:
invalidatein interfaceDataTypeArchive- See Also:
-
isChangeable
public boolean isChangeable()Description copied from interface:DomainObjectReturns true if changes are permitted.- Specified by:
isChangeablein interfaceDomainObject- Returns:
- true if changes are permitted.
-
setChanged
protected void setChanged(boolean b) - Overrides:
setChangedin classDomainObjectAdapterDB
-
getMetadata
Description copied from interface:DomainObjectReturns 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:
getMetadatain interfaceDomainObject- Overrides:
getMetadatain classDomainObjectAdapter- Returns:
- a map containing all the stored metadata associated with this domain object.
-
updateMetadata
Description copied from class:DomainObjectAdapterDBThis method is called before a save, saveAs, or saveToPackedFile to update common meta data- Overrides:
updateMetadatain classDomainObjectAdapterDB- Throws:
IOException
-
updateID
public void updateID()- Specified by:
updateIDin interfaceDataTypeArchive
-