#include <sc_store.h>

Public Member Functions

void AppendSearchPath (const char *utf8_search_path)
 
 Cache (Cache &&that)
 
void Close (Model &model)
 
const char * Exists (const char *utf8_model_path)
 
const char *const * GetModelPaths (size_t &out_count)
 
Model Open (const char *utf8_model_path, bool read_only=false)
 
void RemoveTemporaryFiles ()
 
void SetSearchPath (const char *utf8_search_path)
 
void SetWorkspacePath (const char *utf8_directory_path)
 
 ~Cache ()
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ ~Cache()

SC::Store::Cache::~Cache ( )

◆ Cache()

SC::Store::Cache::Cache ( Cache &&  that)

Member Function Documentation

◆ AppendSearchPath()

void SC::Store::Cache::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_pathA path to search for models.

◆ Close()

void SC::Store::Cache::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
modelThe Model to close.

◆ Exists()

const char* SC::Store::Cache::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_pathThe path or partial path of the model to query.
Returns
The 'C' string UTF8 file system path if found or nullptr if not found.

◆ GetModelPaths()

const char* const* SC::Store::Cache::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_countA 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.

◆ Open()

Model SC::Store::Cache::Open ( const char *  utf8_model_path,
bool  read_only = false 
)

Opens a Model object. New Models can only be created writable.

Parameters
utf8_model_pathAn absolute or partial path of a model directory.
read_onlyIf true the Model will be read only.
Returns
A Model object.

◆ RemoveTemporaryFiles()

void SC::Store::Cache::RemoveTemporaryFiles ( )

Remove any temporary files created by the cache. This includes decompressed files and directories created when opening a compressed SCZ file.

◆ SetSearchPath()

void SC::Store::Cache::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_pathA path to search for models.

◆ SetWorkspacePath()

void SC::Store::Cache::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_pathA path to use for a temporary work space.