Cache
Functions
~Cache |
|
Cache |
|
| Model | Open |
| void | Close |
| void | SetSearchPath |
| void | AppendSearchPath |
| void | SetWorkspacePath |
| const char * | Exists |
| const char *const * | GetModelPaths |
| void | RemoveTemporaryFiles |
Detailed Description
-
class
Cache This class is used to create and open existing models. Creation is done by simply opening a non-existent model. The cache can query known model names and whether or not a model exists in the system.
A cache is closed when its destructor is called or Database::Close(cache) is called.
In general invalid usage will throw exceptions. Using try catch blocks around your code is advised.
Public Functions
-
~Cache()
-
Model
Open(const char *utf8_model_path, bool read_only = false) Opens a Model object. New Models can only be created writable.
Parameters: - utf8_model_path – An absolute or partial path of a model directory.
- read_only – If true the Model will be read only.
Returns: A Model object.
-
void
Close(Model &model) Closes a Model object. The model object will be invalid after this call. This has the same effect as deleting the model object.
Parameters: model – The Model to close.
-
void
SetSearchPath(const char *utf8_search_path) Sets the paths that this Cache will use to search for models provided with a partial path. The provided path string will be parsed and broken on ‘;’. The ‘*’ character is not allowed. Existing search path will be reset. An example path: “e:/sc_test;e:/sc_data”.
Parameters: utf8_search_path – A path to search for models.
-
void
AppendSearchPath(const char *utf8_search_path) Appends more paths that this Cache will use to search for models provided with a partial path. The provided path string will be parsed and broken on ‘;’. The ‘*’ character is not allowed. An example path: “e:/sc_test;e:/sc_data”.
Parameters: utf8_search_path – A path to search for models.
-
void
SetWorkspacePath(const char *utf8_directory_path) Sets a path that this Cache will use as a temporary work space. This is a good idea if .scz files are in use. If the Cache exits normally the workspace will be left clean. If this is not set then the directory containing a .scz file will be used and must be writable.
Parameters: utf8_directory_path – A path to use for a temporary work space.
-
const char *
Exists(const char *utf8_model_path) Query if the specified model is a model known to the Cache. The returned pointer is only valid until the next call. If the utf8_model_path is not an absolute path the search path will be scanned. The utf8_model_path will not be expanded by the current working directory.
Parameters: utf8_model_path – The path or partial path of the model to query. Returns: The ‘C’ string UTF8 file system path if found or nullptr if not found.
-
const char *const *
GetModelPaths(size_t &out_count) Query the models known to the Cache. This will scan the search path for valid models. The returned pointer is only valid until the next call.
Parameters: out_count – A write back value containing the number of models found. Returns: An array of count length of ‘C’ string UTF8 file system paths of the known models.
-
void
RemoveTemporaryFiles() Remove any temporary files created by the cache. This includes decompressed files and directories created when opening a compressed SCZ file.
-