PGRData/Script/matrix/xmanager/XTableManager.lua

69 lines
2.1 KiB
Lua
Raw Normal View History

XTableManager = XTableManager or {}
2024-09-01 20:49:41 +00:00
XTableManager.TableLoadType =
{
Tab = 1,
Bytes = 2
}
2024-09-01 20:49:41 +00:00
local router = require("XManager/XTableLoaders/XTableLoadRouter")
local tabLoader = require("XManager/XTableLoaders/XTableTabLoader")
local bytesLoader = require("XManager/XTableLoaders/XTableBytesLoader")
2024-09-01 20:49:41 +00:00
XTableManager.ForceRelease = false
2024-09-01 20:49:41 +00:00
--============= 外部函数 ============
--为了兼容已有的业务调用需求因此接口上无法做到统一所以两个loader接受的参数是不同的
function XTableManager.ReadAllByIntKey(path, xTable, identifier)
if router.GetLoadType(path) == XTableManager.TableLoadType.Tab then
return tabLoader.ReadAllByIntKey(path, xTable, identifier)
else
return bytesLoader.ReadAllByIntKey(path, xTable, identifier)
end
end
2024-09-01 20:49:41 +00:00
function XTableManager.ReadAllByStringKey(path, xTable, identifier)
if router.GetLoadType(path) == XTableManager.TableLoadType.Tab then
return tabLoader.ReadAllByStringKey(path, xTable, identifier)
else
return bytesLoader.ReadAllByStringKey(path, xTable, identifier)
end
end
2024-09-01 20:49:41 +00:00
function XTableManager.ReadByIntKey(path, xTable, identifier)
if router.GetLoadType(path) == XTableManager.TableLoadType.Tab then
return tabLoader.ReadByIntKey(path, xTable, identifier)
else
return bytesLoader.ReadByIntKey(path, xTable, identifier)
end
end
2024-09-01 20:49:41 +00:00
function XTableManager.ReadByStringKey(path, xTable, identifier)
if router.GetLoadType(path) == XTableManager.TableLoadType.Tab then
return tabLoader.ReadByStringKey(path, xTable, identifier)
else
2024-09-01 20:49:41 +00:00
return bytesLoader.ReadByStringKey(path, xTable, identifier)
end
end
2024-09-01 20:49:41 +00:00
function XTableManager.ReadArray(path, xTable, identifier)
return tabLoader.ReadArray(path, xTable, identifier)
end
2024-09-01 20:49:41 +00:00
function XTableManager.ReleaseAll(unload)
bytesLoader.ReleaseCache()
end
2024-09-01 20:49:41 +00:00
function XTableManager.CheckTableExist(path)
return CS.XTableManager.CheckTableExist(path)
end
2024-09-01 20:49:41 +00:00
function XTableManager.ReleaseTable(path)
--TODO 增加表格释放接口
if router.GetLoadType(path) == XTableManager.TableLoadType.Tab then
return
end
2024-09-01 20:49:41 +00:00
bytesLoader.ReleaseFull(path)
end