|
>@5
|
1 --- **LibModuleDBShare-1.0**\\
|
|
>@5
|
2 -- A description will eventually be here.
|
|
>@5
|
3 --
|
|
>@5
|
4 -- @usage
|
|
>@5
|
5 -- Also coming soon.
|
|
>@5
|
6 -- @class file
|
|
>@5
|
7 -- @name LibModuleDBShare-1.0.lua
|
|
>@3
|
8 local MAJOR, MINOR = "LibModuleDBShare-1.0", 1
|
|
>@3
|
9 local LibModuleDBShare, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
|
|
>@3
|
10
|
|
>@4
|
11 if not LibModuleDBShare then return end -- No upgrade needed
|
|
>@4
|
12
|
|
@12
|
13 local AceDB = LibStub("AceDB-3.0");
|
|
@12
|
14
|
|
>@4
|
15 LibModuleDBShare.groups = LibModuleDBShare.groups or {};
|
|
>@4
|
16
|
|
>@5
|
17 local DBGroup = {};
|
|
>@5
|
18
|
|
>@5
|
19 --- Creates a new DB group.
|
|
>@5
|
20 -- @param groupName The name of the new DB group.
|
|
@12
|
21 -- @param usesDualSpec True if this group should use LibDualSpec, false otherwise. (NYI)
|
|
andrewtknoll@11
|
22 -- @param initialProfile The name of the profile to start with.
|
|
>@5
|
23 -- @usage
|
|
>@5
|
24 -- local myAddonDBGroup = LibStub("LibModuleDBShare-1.0"):NewGroup("MyAddonGroupName", true)
|
|
>@5
|
25 -- @return the new DB group object
|
|
andrewtknoll@11
|
26 function LibModuleDBShare:NewGroup(groupName, usesDualSpec, initialProfile)
|
|
@12
|
27 -- param checks go here
|
|
@12
|
28 local group = {}
|
|
@12
|
29 group.name = groupName;
|
|
@12
|
30 group.syncDBTable = {};
|
|
@12
|
31 group.syncDB = AceDB:New(group.syncDBTable, nil, true);
|
|
@12
|
32 for k, v in pairs(DBGroup) do
|
|
@12
|
33 group[k] = v;
|
|
@12
|
34 end
|
|
@12
|
35 return group;
|
|
>@4
|
36 end
|
|
>@4
|
37
|
|
>@5
|
38 --- Retrieves an existing DB group.
|
|
>@5
|
39 -- @param groupName The name of the DB group to retrieve.
|
|
>@5
|
40 -- @usage
|
|
>@5
|
41 -- local myAddonDBGroup = LibStub("LibModuleDBShare-1.0"):GetGroup("MyAddonGroupName")
|
|
>@5
|
42 -- @return the DB group object, or nil if not found
|
|
>@5
|
43 function LibModuleDBShare:GetGroup(groupName)
|
|
@12
|
44 return LibModuleDBShare.groups[groupName];
|
|
>@4
|
45 end
|
|
>@5
|
46
|
|
>@5
|
47 --- Adds a database to the group.
|
|
>@5
|
48 -- @param db The name of the new DB group.
|
|
>@5
|
49 -- @usage
|
|
>@5
|
50 -- myAddonDBGroup:AddDB(MyAddon.db)
|
|
>@5
|
51 function DBGroup:AddDB(db)
|
|
>@5
|
52
|
|
>@5
|
53 end
|