Class

MoorhenTimeCapsule

MoorhenTimeCapsule(moleculesRef, mapsRef, activeMapRef, glRef, store)

Represents a time capsule with session backups
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

View Source utils/MoorhenTimeCapsule.ts, line 29

Classes

MoorhenTimeCapsule

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

View Source utils/MoorhenTimeCapsule.ts, line 767

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

View Source utils/MoorhenTimeCapsule.ts, line 743

Promise.<void>

# async cleanupIfFull() → {Promise.<void>}

Remove the oldest automatic backup if the number of backups in the local storage has reached the threshold

View Source utils/MoorhenTimeCapsule.ts, line 774

Promise.<void>

# async cleanupUnusedDataFiles() → {Promise.<void>}

Remove orphan metadata files with no backup session associated

View Source utils/MoorhenTimeCapsule.ts, line 781

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

View Source utils/MoorhenTimeCapsule.ts, line 790

Backup key
string

# async dropAllBackups() → {Promise.<void>}

Remove all backups

View Source utils/MoorhenTimeCapsule.ts, line 820

Promise.<void>

# 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

View Source utils/MoorhenTimeCapsule.ts, line 759

A backup for the current session
Promise.<moorhen.backupSession>

# async getSortedKeys() → {Array.<moorhen.backupKey>}

Get backup keys sorted by date

View Source utils/MoorhenTimeCapsule.ts, line 827

A list of backup keys
Array.<moorhen.backupKey>

# init() → {Promise.<void>}

Intiate the time capsule

View Source utils/MoorhenTimeCapsule.ts, line 725

Promise.<void>

# async removeBackup(key) → {Promise.<void>}

Remove a specific backup
Parameters:
Name Type Description
key string Backup key

View Source utils/MoorhenTimeCapsule.ts, line 813

Promise.<void>

# async retrieveBackup(key) → {Promise.<(string|ArrayBuffer)>}

Retrieve a session backup
Parameters:
Name Type Description
key string Backup key

View Source utils/MoorhenTimeCapsule.ts, line 798

Promise.<(string|ArrayBuffer)>

# async retrieveLastBackup() → {string}

Retrieve the latest backup stored in local storage

View Source utils/MoorhenTimeCapsule.ts, line 805

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.

View Source utils/MoorhenTimeCapsule.ts, line 736

# toggleDisableBackups()

Toggles the time capsule disabled state

View Source utils/MoorhenTimeCapsule.ts, line 730

# 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

View Source utils/MoorhenTimeCapsule.ts, line 751

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

View Source utils/MoorhenTimeCapsule.ts, line 834

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

View Source utils/MoorhenTimeCapsule.ts, line 850

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

View Source utils/MoorhenTimeCapsule.ts, line 866

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

View Source utils/MoorhenTimeCapsule.ts, line 898

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

View Source utils/MoorhenTimeCapsule.ts, line 882

Returns -1 if there was an error loading the session otherwise 0
number