>@5: --- **LibModuleDBShare-1.0**\\ >@5: -- A description will eventually be here. >@5: -- >@5: -- @usage >@5: -- Also coming soon. >@5: -- @class file >@5: -- @name LibModuleDBShare-1.0.lua >@3: local MAJOR, MINOR = "LibModuleDBShare-1.0", 1 >@3: local LibModuleDBShare, oldminor = LibStub:NewLibrary(MAJOR, MINOR) >@3: >@4: if not LibModuleDBShare then return end -- No upgrade needed >@4: andrewtknoll@15: -- Lua APIs andrewtknoll@15: local assert = assert; andrewtknoll@15: @12: local AceDB = LibStub("AceDB-3.0"); @12: >@4: LibModuleDBShare.groups = LibModuleDBShare.groups or {}; >@4: >@5: local DBGroup = {}; >@5: >@5: --- Creates a new DB group. >@5: -- @param groupName The name of the new DB group. @12: -- @param usesDualSpec True if this group should use LibDualSpec, false otherwise. (NYI) andrewtknoll@11: -- @param initialProfile The name of the profile to start with. >@5: -- @usage >@5: -- local myAddonDBGroup = LibStub("LibModuleDBShare-1.0"):NewGroup("MyAddonGroupName", true) >@5: -- @return the new DB group object andrewtknoll@11: function LibModuleDBShare:NewGroup(groupName, usesDualSpec, initialProfile) andrewtknoll@15: assert(type(groupName) == "string", "Usage: LibModuleDBShare:NewGroup(groupName, usesDualSpec, initialProfile): 'groupName' is not a string."); andrewtknoll@15: assert(type(LibModuleDBShare.groups[groupName]) == "nil", "LibModuleDBShare:NewGroup(groupName, usesDualSpec, initialProfile): 'groupName' already exists"); @12: local group = {} @12: group.name = groupName; @12: group.syncDBTable = {}; @12: group.syncDB = AceDB:New(group.syncDBTable, nil, true); @12: for k, v in pairs(DBGroup) do @12: group[k] = v; @12: end @12: return group; >@4: end >@4: >@5: --- Retrieves an existing DB group. >@5: -- @param groupName The name of the DB group to retrieve. >@5: -- @usage >@5: -- local myAddonDBGroup = LibStub("LibModuleDBShare-1.0"):GetGroup("MyAddonGroupName") >@5: -- @return the DB group object, or nil if not found >@5: function LibModuleDBShare:GetGroup(groupName) @12: return LibModuleDBShare.groups[groupName]; >@4: end >@5: >@5: --- Adds a database to the group. >@5: -- @param db The name of the new DB group. >@5: -- @usage >@5: -- myAddonDBGroup:AddDB(MyAddon.db) >@5: function DBGroup:AddDB(db) >@5: >@5: end