VRS
A file format for sensor data.
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
vrs::FileCache Class Reference

Utility class to manage various forms of file caching. Disabled by default. More...

#include <FileCache.h>

Public Member Functions

int getFile (const string &filename, string &outFilePath)
 
int getFile (const string &domain, const string &filename, string &outFilePath)
 

Static Public Member Functions

static int makeFileCache (const string &app, const string &parentFolder={})
 
static void disableFileCache ()
 To disable the file cache. Safe to call even if not enabled.
 
static FileCachegetFileCache ()
 

Protected Member Functions

 FileCache (string mainFolder)
 

Detailed Description

Utility class to manage various forms of file caching. Disabled by default.

There is a main file cache, which needs to be created for file caching to be enabled.

Member Function Documentation

◆ getFile() [1/2]

int vrs::FileCache::getFile ( const string &  domain,
const string &  filename,
string &  outFilePath 
)

Look-up a file in the cache, specifying a domain. Useful, if you want to cache a bunch of derived objects from a particular object, placing all those cached objects in a folder named after the main object.

Parameters
domainthe primary domain. Might be an identifier for a specific VRS file...
filenamea filename for the object.
outFilePatha path to the object in the cache.
Returns
0 if the file exists, and outFilePath has been set. Returns FILE_NOT_FOUND if the file doesn't exist, and outFilePath has been set, for you to add the object in the cache at that location. Returns another error code and outFilePath isn't set, if some error occurred, and the object doesn't exist and can't be created, maybe because some files or folders are in the way.

◆ getFile() [2/2]

int vrs::FileCache::getFile ( const string &  filename,
string &  outFilePath 
)

Look-up a file in the cache.

Parameters
filenamea filename for the object.
outFilePatha path to the object in the cache.
Returns
0 if the file exists, and outFilePath has been set. Returns FILE_NOT_FOUND if the file doesn't exist, and outFilePath has been set, for you to add the object in the cache at that location. Returns another error code and outFilePath isn't set, if some error occurred, and the object doesn't exist and can't be created, maybe because some files or folders are in the way.

◆ getFileCache()

FileCache * vrs::FileCache::getFileCache ( )
static

Get file cache, if one has been created.

Returns
The existing file cache, or nullptr if none was created.

◆ makeFileCache()

int vrs::FileCache::makeFileCache ( const string &  app,
const string &  parentFolder = {} 
)
static

Make the file cache. You need to create it to enable caching features. Note that there is only one of these file cache in any running app, but there could be multiple ones in the file system.

Parameters
appname for the app, to have its own space, maybe shared with other apps of the same team. VRS apps like VRStool & VRSplayer will use kDefaultVrsAppsCache.
parentFolderan optional cache folder location. If empty, the cache will be created in the home folder.
Returns
A status code, 0 meaning success.

The documentation for this class was generated from the following files: