Mercurial > wow > libmoduledbshare-1-0
comparison LibModuleDBShare-1.0/LibModuleDBShare-1.0.lua @ 19:ec910729e073
Completed basic implementation of LMDBS:NewGroup()
| author | Andrew Knoll <andrewtknoll@gmail.com> |
|---|---|
| date | Thu, 14 Mar 2013 22:23:48 -0400 |
| parents | dacd01bf164f |
| children | 647cb45f5864 |
comparison
equal
deleted
inserted
replaced
| 18:dacd01bf164f | 19:ec910729e073 |
|---|---|
| 51 group.syncDB = AceDB:New(group.syncDBTable, nil, initialProfile); | 51 group.syncDB = AceDB:New(group.syncDBTable, nil, initialProfile); |
| 52 group.profileOptionsTable = AceDBOptions:GetOptionsTable(group.syncDB, false); | 52 group.profileOptionsTable = AceDBOptions:GetOptionsTable(group.syncDB, false); |
| 53 AceConfigRegistry:RegisterOptionsTable(groupName.."Profiles", group.profileOptionsTable); | 53 AceConfigRegistry:RegisterOptionsTable(groupName.."Profiles", group.profileOptionsTable); |
| 54 AceConfigDialog:AddToBlizOptions(groupName.."Profiles", group.profileOptionsTable.name, groupName); | 54 AceConfigDialog:AddToBlizOptions(groupName.."Profiles", group.profileOptionsTable.name, groupName); |
| 55 group.members = {}; | 55 group.members = {}; |
| 56 group.syncDB:RegisterCallback(group, "OnNewProfile", "OnNewProfile"); | |
| 57 group.syncDB:RegisterCallback(group, "OnProfileChanged", "OnProfileChanged"); | |
| 58 group.syncDB:RegisterCallback(group, "OnProfileDeleted", "OnProfileDeleted"); | |
| 59 group.syncDB:RegisterCallback(group, "OnProfileCopied", "OnProfileCopied"); | |
| 60 group.syncDB:RegisterCallback(group, "OnProfileReset", "OnProfileReset"); | |
| 61 for k, v in pairs(DBGroup) do | 56 for k, v in pairs(DBGroup) do |
| 62 group[k] = v; | 57 group[k] = v; |
| 63 end | 58 end |
| 59 group.syncDB.RegisterCallback(group, "OnProfileChanged", "OnProfileChanged"); | |
| 60 group.syncDB.RegisterCallback(group, "OnProfileDeleted", "OnProfileDeleted"); | |
| 61 group.syncDB.RegisterCallback(group, "OnProfileCopied", "OnProfileCopied"); | |
| 62 group.syncDB.RegisterCallback(group, "OnProfileReset", "OnProfileReset"); | |
| 63 LibModuleDBShare.groups[groupName] = group; | |
| 64 return group; | 64 return group; |
| 65 end | 65 end |
| 66 | 66 |
| 67 --- Retrieves an existing DB group. | 67 --- Retrieves an existing DB group. |
| 68 -- @param groupName The name of the DB group to retrieve. | 68 -- @param groupName The name of the DB group to retrieve. |
| 80 -- myAddonDBGroup:AddDB(MyAddon.db) | 80 -- myAddonDBGroup:AddDB(MyAddon.db) |
| 81 function DBGroup:AddDB(db) | 81 function DBGroup:AddDB(db) |
| 82 | 82 |
| 83 end | 83 end |
| 84 | 84 |
| 85 function DBGroup:OnNewProfile(db, profile) | 85 -- callback handlers (new profiles are handled by OnProfileChanged) |
| 86 print("New Profile"); | 86 |
| 87 function DBGroup:OnProfileChanged(callback, db, profile) | |
| 88 print("Profile Changed"); | |
| 89 print(self.name); | |
| 87 print(type(profile)); | 90 print(type(profile)); |
| 88 print(tostring(profile)); | 91 print(tostring(profile)); |
| 89 end | 92 end |
| 90 | 93 |
| 91 function DBGroup:OnProfileChanged(db, profile) | 94 function DBGroup:OnProfileDeleted(callback, db, profile) |
| 92 print("Profile Changed"); | 95 print("Profile Deleted"); |
| 96 print(self.name); | |
| 93 print(type(profile)); | 97 print(type(profile)); |
| 94 print(tostring(profile)); | 98 print(tostring(profile)); |
| 95 end | 99 end |
| 96 | 100 |
| 97 function DBGroup:OnProfileDeleted(db, profile) | 101 function DBGroup:OnProfileCopied(callback, db, profile) |
| 98 print("Profile Deleted"); | 102 print("Profile Copied"); |
| 103 print(self.name); | |
| 99 print(type(profile)); | 104 print(type(profile)); |
| 100 print(tostring(profile)); | 105 print(tostring(profile)); |
| 101 end | 106 end |
| 102 | 107 |
| 103 function DBGroup:OnProfileCopied(db, profile) | 108 function DBGroup:OnProfileReset(callback, db) |
| 104 print("Profile Copied"); | 109 print("Profile Reset"); |
| 105 print(type(profile)); | 110 print(self.name); |
| 106 print(tostring(profile)); | |
| 107 end | 111 end |
| 108 | |
| 109 function DBGroup:OnProfileReset(db) | |
| 110 print("Profile Reset"); | |
| 111 end |
