![]() |
Coin3D is Free Software, published under the BSD 3-clause license. |
https://coin3d.github.io https://www.kongsberg.com/en/kogt/ |
Static utility functions for managing data resources at the basic buffer level. More...
Enumerations | |
enum | ResourceFlags { NONE = 0 , COIN_RESOURCE_NOT_A_FILE =0x0001 } |
Functions | |
void | init (void) |
SbByteBuffer | get (const char *resloc) |
SbBool | set (const char *resloc, const SbByteBuffer &buffer, ResourceFlags flags=NONE) |
void | freeLoadedExternals (void) |
Static utility functions for managing data resources at the basic buffer level.
This class is just a static scope for some resource managing functions. With this, Coin can register built-in default resources that can later be retrieved through the same resource locator, either from disk (if present) and as a fallback the built-in (compiled in) buffer
The resource locators take the form of a URL with coin as its schema and empty host eg. "coin://path/to/resource.ext".
The "coin:" prefix is for Coin to differentiate a resource locator from a filename (for multipurpose function usage).
The path/to/resource.ext is for most platforms the path under the environment variable $COINDIR where the file should be present. For Mac OS X, the path is under the Inventor framework bundle Resources/ directory, if Coin was installed as a framework that is.
The file on disk can be an updated version, compared to the compiled-in buffer, which is why the externalized files are prioritized over the built-in buffers.
A resource does not need to have a corresponding external file. This is configured in the flags parameter when the resource is set. You can in other words also register built-in-only resources.
SbByteBuffer CoinResources::get | ( | const char * | resloc | ) |
Returns a resource if one exists. If the Coin installation permits, the resource will be loaded from file, but if the file cannot be located or loaded, built-in versions will be returned instead.
SbBool CoinResources::set | ( | const char * | resloc, |
const SbByteBuffer & | buffer, | ||
ResourceFlags | flags = NONE |
||
) |
This function registers a new resource. The resource locator (resloc) should take the form "coin:" followed by a relative file path that should lead to the file representation of the resource from where the COINDIR environment variable points. The relative path should use / for directory separation, and not \ if on Microsoft Windows.
If you put COIN_RESOURCE_NOT_A_FILE in the flags argument, then the automatic file searching will not be performed.