Constructor
# new MoorhenTimeCapsule(moleculesRef, mapsRef, activeMapRef, glRef, store)
Parameters:
Name | Type | Description |
---|---|---|
moleculesRef |
React.RefObject.<Array.<moorhen.Molecule>>
|
A react reference to the list of loaded molecules |
mapsRef |
React.RefObject.<Array.<moorhen.Map>>
|
A react reference to the list of loaded maps |
activeMapRef |
React.RefObject.<moorhen.Map>
|
A react reference to the currently active map |
glRef |
React.RefObject.<webGL.MGWebGL>
|
A react reference to the molecular graphics renderer |
store |
ToolkitStore
|
The Redux store |
Properties:
Name | Type | Description |
---|---|---|
version |
string
|
Version number of the current time capsule |
busy |
boolean
|
Indicates if time capsule is busy loading from local storage |
disableBackups |
boolean
|
Disable time capsule |
maxBackupCount |
number
|
Maximum number of automatic backups to store in local storage |
modificationCountBackupThreshold |
number
|
Number of modifications to trigger an automatic backup |
onIsBusyChange |
function
|
Callback function called whenever there's a change in the `this.busy` state |
Classes
Methods
# async addModification() → {Promise.<string>}
Add a modification to the modification counter and create a backup if the modification count has reached
the modification threshold
Backup key if a backup was created
Promise.<string>
# async checkVersion() → {Promise.<void>}
Check if the current version is compatible with that stored in local storage
Promise.<void>
# async cleanupIfFull() → {Promise.<void>}
Remove the oldest automatic backup if the number of backups in the local storage has reached the threshold
Promise.<void>
# async cleanupUnusedDataFiles() → {Promise.<void>}
Remove orphan metadata files with no backup session associated
Promise.<void>
# async createBackup(key, value) → {string}
Create a session backup
Parameters:
Name | Type | Description |
---|---|---|
key |
string
|
Backup key |
value |
string
|
JSON structure with session data |
Backup key
string
# async fetchSession(includeAdditionalMapDataopt) → {Promise.<moorhen.backupSession>}
Fetch a backup session
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
includeAdditionalMapData |
boolean
|
<optional> |
true | True if map data should be fetched and included in the resulting session |
A backup for the current session
Promise.<moorhen.backupSession>
# async getSortedKeys() → {Array.<moorhen.backupKey>}
Get backup keys sorted by date
A list of backup keys
Array.<moorhen.backupKey>
# async removeBackup(key) → {Promise.<void>}
Remove a specific backup
Parameters:
Name | Type | Description |
---|---|---|
key |
string
|
Backup key |
Promise.<void>
# async retrieveBackup(key) → {Promise.<(string|ArrayBuffer)>}
Retrieve a session backup
Parameters:
Name | Type | Description |
---|---|---|
key |
string
|
Backup key |
Promise.<(string|ArrayBuffer)>
# async retrieveLastBackup() → {string}
Retrieve the latest backup stored in local storage
JSON structure with session data
string
# setBusy(newValue)
Sets instance attr. this.busy and calls this.onIsBusyChange()
Parameters:
Name | Type | Description |
---|---|---|
newValue |
boolea
|
The new value for the busy attr. |
# toggleDisableBackups()
Toggles the time capsule disabled state
# async updateDataFiles() → {Promise.<Array.<string>>}
Update metadata files currently stored in the local storage. It might be required to call this function before
using MoorhenTimeCapsule.fetchSession
Backup keys for the new metadata files that were created if any
Promise.<Array.<string>>
# static getBackupLabel(key) → {string}
A static function that can be used to get the backup label for a given key object
Parameters:
Name | Type | Description |
---|---|---|
key |
moorhen.backupKey
|
An object with the backup key data |
A string corresponding with the backup label
string
# async static loadSessionData(sessionData, monomerLibraryPath, molecules, maps, commandCentre, timeCapsuleRef, glRef, store, dispatch) → {number}
A static function that can be used to load a session data object
Parameters:
Name | Type | Description |
---|---|---|
sessionData |
moorhen.backupSession
|
An object containing session data |
monomerLibraryPath |
string
|
Path to the monomer library |
molecules |
Array.<moorhen.Molecule>
|
State containing current molecules loaded in the session |
maps |
Array.<moorhen.Map>
|
State containing current maps loaded in the session |
commandCentre |
React.RefObject.<moorhen.CommandCentre>
|
React reference to the command centre |
timeCapsuleRef |
React.RefObject.<moorhen.TimeCapsule>
|
React reference to the time capsule |
glRef |
React.RefObject.<webGL.MGWebGL>
|
React reference to the webGL renderer |
store |
ToolkitStore
|
The Redux store |
dispatch |
Dispatch.<AnyAction>
|
Dispatch method for the MoorhenReduxStore |
Returns -1 if there was an error loading the session otherwise 0
number
# async static loadSessionFromArrayBuffer(sessionArrayBuffer, monomerLibraryPath, molecules, maps, commandCentre, timeCapsuleRef, glRef, store, dispatch) → {number}
A static function that can be used to load a session from an array buffer
Parameters:
Name | Type | Description |
---|---|---|
sessionArrayBuffer |
ArrayBuffer
|
An object containing session data |
monomerLibraryPath |
string
|
Path to the monomer library |
molecules |
Array.<moorhen.Molecule>
|
State containing current molecules loaded in the session |
maps |
Array.<moorhen.Map>
|
State containing current maps loaded in the session |
commandCentre |
React.RefObject.<moorhen.CommandCentre>
|
React reference to the command centre |
timeCapsuleRef |
React.RefObject.<moorhen.TimeCapsule>
|
React reference to the time capsule |
glRef |
React.RefObject.<webGL.MGWebGL>
|
React reference to the webGL renderer |
store |
ToolkitStore
|
The Redux store |
dispatch |
Dispatch.<AnyAction>
|
Dispatch method for the MoorhenReduxStore |
Returns -1 if there was an error loading the session otherwise 0
number
# async static loadSessionFromJsonString(sessionDataString, monomerLibraryPath, molecules, maps, commandCentre, timeCapsuleRef, glRef, store, dispatch) → {number}
A static function that can be used to load a session from a JSON string representation of a session data object
Parameters:
Name | Type | Description |
---|---|---|
sessionDataString |
string
|
A JSON string representation of the object containing session data |
monomerLibraryPath |
string
|
Path to the monomer library |
molecules |
Array.<moorhen.Molecule>
|
State containing current molecules loaded in the session |
maps |
Array.<moorhen.Map>
|
State containing current maps loaded in the session |
commandCentre |
React.RefObject.<moorhen.CommandCentre>
|
React reference to the command centre |
timeCapsuleRef |
React.RefObject.<moorhen.TimeCapsule>
|
React reference to the time capsule |
glRef |
React.RefObject.<webGL.MGWebGL>
|
React reference to the webGL renderer |
store |
ToolkitStore
|
The Redux store |
dispatch |
Dispatch.<AnyAction>
|
Dispatch method for the MoorhenReduxStore |
Returns -1 if there was an error loading the session otherwise 0
number
# async static loadSessionFromProtoMessage(sessionProtoMessage, monomerLibraryPath, molecules, maps, commandCentre, timeCapsuleRef, glRef, store, dispatch) → {number}
A static function that can be used to load a session from a protobuf message
Parameters:
Name | Type | Description |
---|---|---|
sessionProtoMessage |
string
|
A protobuf message for the object containing session data |
monomerLibraryPath |
string
|
Path to the monomer library |
molecules |
Array.<moorhen.Molecule>
|
State containing current molecules loaded in the session |
maps |
Array.<moorhen.Map>
|
State containing current maps loaded in the session |
commandCentre |
React.RefObject.<moorhen.CommandCentre>
|
React reference to the command centre |
timeCapsuleRef |
React.RefObject.<moorhen.TimeCapsule>
|
React reference to the time capsule |
glRef |
React.RefObject.<webGL.MGWebGL>
|
React reference to the webGL renderer |
store |
ToolkitStore
|
The Redux store |
dispatch |
Dispatch.<AnyAction>
|
Dispatch method for the MoorhenReduxStore |
Returns -1 if there was an error loading the session otherwise 0
number