The Allegro Wiki is migrating to github at https://github.com/liballeg/allegro_wiki/wiki

Proposed config system

From Allegro Wiki
Jump to: navigation, search

Global string based config with hooks

User:

<highlightSyntax language="c">al_get_config_int(config, "path", "key"); al_set_config_int(config, "path", "key", value);

</highlightSyntax>

Driver: <highlightSyntax language="c">al_get_config_int(config, "path", "key") to read settings on initialization al_set_config_hook(config, "path", "key", set_callback, get_callback);

</highlightSyntax>

The driver can specify callbacks to respond immediately to setting something, or to query something for the user.

Enum based per-sub-system functions

User:

<highlightSyntax language="c">al_sound_get(driver, AL_ENUM) al_sound_set(driver, AL_ENUM, value)

</highlightSyntax>

Settings would get stored into a list in the sound subsystem if driver is NULL.

Driver:

On initialization, would read from the internal list. Then on set/get, would directly handle it with a switch() based on the enum.