/trunk/Who Framed Watcher Wabbit/libs/AceConfig-3.0/AceConfigRegistry-3.0
-- :IterateOptionsTables() (and :GetOptionsTable() if only given one argument) return a function reference that the requesting config handling addon must call with valid "uiType", "uiName". |
-- @class file |
-- @name AceConfigRegistry-3.0 |
-- @release $Id: AceConfigRegistry-3.0.lua 1045 2011-12-09 17:58:40Z nevcairiel $ |
local MAJOR, MINOR = "AceConfigRegistry-3.0", 14 |
-- @release $Id: AceConfigRegistry-3.0.lua 1105 2013-12-08 22:11:58Z nevcairiel $ |
local MAJOR, MINOR = "AceConfigRegistry-3.0", 15 |
local AceConfigRegistry = LibStub:NewLibrary(MAJOR, MINOR) |
if not AceConfigRegistry then return end |
-- @param appName The application name as given to `:RegisterOptionsTable()` |
-- @param options The options table, OR a function reference that generates it on demand. \\ |
-- See the top of the page for info on arguments passed to such functions. |
function AceConfigRegistry:RegisterOptionsTable(appName, options) |
-- @param skipValidation Skip options table validation (primarily useful for extremely huge options, with a noticeable slowdown) |
function AceConfigRegistry:RegisterOptionsTable(appName, options, skipValidation) |
if type(options)=="table" then |
if options.type~="group" then -- quick sanity checker |
error(MAJOR..": RegisterOptionsTable(appName, options): 'options' - missing type='group' member in root group", 2) |
AceConfigRegistry.tables[appName] = function(uiType, uiName, errlvl) |
errlvl=(errlvl or 0)+1 |
validateGetterArgs(uiType, uiName, errlvl) |
if not AceConfigRegistry.validated[uiType][appName] then |
if not AceConfigRegistry.validated[uiType][appName] and not skipValidation then |
AceConfigRegistry:ValidateOptionsTable(options, appName, errlvl) -- upgradable |
AceConfigRegistry.validated[uiType][appName] = true |
end |
errlvl=(errlvl or 0)+1 |
validateGetterArgs(uiType, uiName, errlvl) |
local tab = assert(options(uiType, uiName, appName)) |
if not AceConfigRegistry.validated[uiType][appName] then |
if not AceConfigRegistry.validated[uiType][appName] and not skipValidation then |
AceConfigRegistry:ValidateOptionsTable(tab, appName, errlvl) -- upgradable |
AceConfigRegistry.validated[uiType][appName] = true |
end |