CoinResources Namespace Reference

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)

## Detailed Description

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.

## Function Documentation

## get()

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.

Returns
  TRUE on success, and FALSE if there is no such resource.

## set()

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.

Returns
  TRUE if the resource was set, and FALSE if something went wrong. FALSE would most likely be returned because the resource already exists.

## freeLoadedExternals()

void CoinResources::freeLoadedExternals | ( | void |  | ) |

This function deallocates all the buffers that have been loaded from disk. Internal buffers will not be freed, as they are expected to be compiled into the Coin library data section.