comparison LibModuleDBShare-1.0/LibModuleDBShare-1.0.lua @ 12:5947b9721b9c master

began implementation of NewGroup implemented GetGroup
author Thnan < >
date Sun, 10 Mar 2013 03:34:49 -0400
parents 35159f132552
children 1dd07f05ecac
comparison
equal deleted inserted replaced
11:35159f132552 12:5947b9721b9c
8 local MAJOR, MINOR = "LibModuleDBShare-1.0", 1 8 local MAJOR, MINOR = "LibModuleDBShare-1.0", 1
9 local LibModuleDBShare, oldminor = LibStub:NewLibrary(MAJOR, MINOR) 9 local LibModuleDBShare, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
10 10
11 if not LibModuleDBShare then return end -- No upgrade needed 11 if not LibModuleDBShare then return end -- No upgrade needed
12 12
13 local AceDB = LibStub("AceDB-3.0");
14
13 LibModuleDBShare.groups = LibModuleDBShare.groups or {}; 15 LibModuleDBShare.groups = LibModuleDBShare.groups or {};
14 16
15 local DBGroup = {}; 17 local DBGroup = {};
16 18
17 --- Creates a new DB group. 19 --- Creates a new DB group.
18 -- @param groupName The name of the new DB group. 20 -- @param groupName The name of the new DB group.
19 -- @param usesDualSpec True if this group should use LibDualSpec, false otherwise. 21 -- @param usesDualSpec True if this group should use LibDualSpec, false otherwise. (NYI)
20 -- @param initialProfile The name of the profile to start with. 22 -- @param initialProfile The name of the profile to start with.
21 -- @usage 23 -- @usage
22 -- local myAddonDBGroup = LibStub("LibModuleDBShare-1.0"):NewGroup("MyAddonGroupName", true) 24 -- local myAddonDBGroup = LibStub("LibModuleDBShare-1.0"):NewGroup("MyAddonGroupName", true)
23 -- @return the new DB group object 25 -- @return the new DB group object
24 function LibModuleDBShare:NewGroup(groupName, usesDualSpec, initialProfile) 26 function LibModuleDBShare:NewGroup(groupName, usesDualSpec, initialProfile)
25 27 -- param checks go here
28 local group = {}
29 group.name = groupName;
30 group.syncDBTable = {};
31 group.syncDB = AceDB:New(group.syncDBTable, nil, true);
32 for k, v in pairs(DBGroup) do
33 group[k] = v;
34 end
35 return group;
26 end 36 end
27 37
28 --- Retrieves an existing DB group. 38 --- Retrieves an existing DB group.
29 -- @param groupName The name of the DB group to retrieve. 39 -- @param groupName The name of the DB group to retrieve.
30 -- @usage 40 -- @usage
31 -- local myAddonDBGroup = LibStub("LibModuleDBShare-1.0"):GetGroup("MyAddonGroupName") 41 -- local myAddonDBGroup = LibStub("LibModuleDBShare-1.0"):GetGroup("MyAddonGroupName")
32 -- @return the DB group object, or nil if not found 42 -- @return the DB group object, or nil if not found
33 function LibModuleDBShare:GetGroup(groupName) 43 function LibModuleDBShare:GetGroup(groupName)
34 44 return LibModuleDBShare.groups[groupName];
35 end 45 end
36 46
37 --- Adds a database to the group. 47 --- Adds a database to the group.
38 -- @param db The name of the new DB group. 48 -- @param db The name of the new DB group.
39 -- @usage 49 -- @usage