LokStorageManager¶
Inherits:
The LokStorageManager is the super class of the LokGlobalStorageManager and LokSceneStorageManager classes.
Description¶
This super class serves as an interface for the save_data, load_data, read_data and remove_data methods, so that its sub classes can override them.
Version: 1.0.0 Author: github.com/nadjiel <github.com/nadjiel>_
Property Index¶
Type |
Name |
Default value |
|---|---|---|
String |
|
Method Index¶
Signal Descriptions¶
saving_started()¶
The saving_started signal is emitted when a save operation was started by this LokStorageManager.
loading_started()¶
The loading_started signal is emitted when a load operation was started by this LokStorageManager.
reading_started()¶
The reading_started signal is emitted when a read operation was started by this LokStorageManager.
removing_started()¶
The removing_started signal is emitted when a remove operation was started by this LokStorageManager.
saving_finished(Dictionary result)¶
The saving_finished signal is emitted when a save operation was finished by this LokStorageManager.
This signal brings a Dictionary representing the result of the operation. This Dictionary has a "status" key, with a @GlobalScope.Error code and a "data" key, with the data saved.
loading_finished(Dictionary result)¶
The loading_finished signal is emitted when a load operation was finished by this LokStorageManager.
This signal brings a Dictionary representing the result of the operation. This Dictionary has a "status" key, with a @GlobalScope.Error code and a "data" key, with the data loaded.
reading_finished(Dictionary result)¶
The reading_finished signal is emitted when a read operation was finished by this LokStorageManager.
This signal brings a Dictionary representing the result of the operation. This Dictionary has a "status" key, with a @GlobalScope.Error code and a "data" key, with the data readed.
removing_finished(Dictionary result)¶
The removing_finished signal is emitted when a remove operation was finished by this LokStorageManager.
This signal brings a Dictionary representing the result of the operation. This Dictionary has a "status" key, with a @GlobalScope.Error code and a "data" key, with the data removed.
Property Descriptions¶
String current_file = ""¶
The current_file property stores the id of the default file to be used when performing operations with this LokStorageManager.
Method Descriptions¶
Dictionary save_data(String file_id = current_file, String version_number = current_version, LokStorageAccessor <LokStorageAccessor>`[] included_accessors = ``[]`, bool replace = false)¶
The save_data method should save the information from all active LokAccessorGroup.accessors of this LokStorageManager in a desired file.
This method receives several parameters to customize that process.
The file_id should determine in what file the game should be saved. This id defaults to the one set in the current_file property.
The version_number parameter is supposed to specify what version of the registered LokStorageAccessor, which converts to the latest version available.
The included_accessors parameter is an Array that represents what is the subset of LokStorageAccessor <LokStorageAccessor>`s that should be involved in this saving process. If left empty, as default, it would mean that all :ref:`LokStorageAccessor <LokStorageAccessor>`s currently registered would have their informations saved.
The ``replace` parameter is a flag that tells whether the previous data saved, if any, should be overwritten by the new one. It’s not recommended setting this flag to true since LokStorageAccessor with a "status" key specifying a @GlobalScope.Error code, and a "data" key storing all data saved.
The start and finish of this operation should be notified via the saving_started and saving_finished signals.
Dictionary load_data(String file_id = current_file, LokStorageAccessor <LokStorageAccessor>`[] included_accessors = ``[]`, String <String>`[] partition_ids = ``[]`, String <String>`[] version_numbers = ``[]`)¶
The load_data method should load the information from all active LokAccessorGroup.accessors of this LokStorageManager from a desired file and further distribute it to them, so they can use it with their LokStorageAccessor.consume_data method.
This method receives several parameters to customize that process.
The file_id should determine from what file the game should be loaded. This id defaults to the one set in the current_file property.
Besides that, the included_accessors parameter is an Array that represents what is the subset of LokStorageAccessor <LokStorageAccessor>`s that should be involved in this loading process. If left empty, as default, it would mean that all :ref:`LokStorageAccessor <LokStorageAccessor>`s currently registered would have their informations loaded.
To provide yet more control over what data is loaded, the ``partition_ids` and version_numbers parameters can be passed, serving to filter what information should be applied to the game.
If you have sure about in what partitions is the data you want to load, passing their partition_ids is more efficient since the loading only needs to check those partitions.
If the optional parameters are left empty, as default, it means that all included_accessors, partition_ids and version_numbers are used when loading.
At the end, this method should return the result of the loading via a Dictionary with a "status" key specifying a @GlobalScope.Error code, and a "data" key storing all data loaded.
The start and finish of this operation should be notified via the loading_started and loading_finished signals.
Dictionary read_data(String file_id = current_file, LokStorageAccessor <LokStorageAccessor>`[] included_accessors = ``[]`, String <String>`[] partition_ids = ``[]`, String <String>`[] version_numbers = ``[]`)¶
The read_data method should read the information from a desired file, like the load_data method, but not distribute that data to its respective LokStorageAccessor method, but more inclined for possibilitating saved data analysis without necessarily applying it to the game. To read more about the parameters and return of this method, see the load_data method. The start and finish of this operation should be notified via the reading_started and reading_finished signals.
Dictionary remove_data(String file_id = current_file, LokStorageAccessor <LokStorageAccessor>`[] included_accessors = ``[]`, String <String>`[] partition_ids = ``[]`, String <String>`[] version_numbers = ``[]`)¶
The remove_data method should remove the information from a desired file of specified by the file_id parameter.
By default, that file_id is set to the current_file property.
The included_accessors, partition_ids and version_numbers parameters can be used to filter what should be removed, if it’s not desired to remove the entire file.
To read more about those parameters, see the load_data method, which uses them as filters in the same way.
At the end, this method should return the result of the removing via a Dictionary with a "status" key specifying a @GlobalScope.Error code, a "data" key storing all data removed, and an "updated_data" key storing all data kept.
The start and finish of this operation should be notified via the removing_started and removing_finished signals.
String _get_readable_name()¶
The _get_readable_name method is a utility for debugging. It returns a more user friendly name for this node, so that errors can use it to be clearer.