Dokumentation [visa] [redigera] [historik] [rensa sidcachen]
|
This page documents the development version of the Adapt module. Since it is intended for an international audience, it is written in English, even as the development currently takes place on Swedish Wikipedia. |
Introduction redigera
The Adapt module provides utilities to simplify development and testing of other modules.
Basic concepts redigera
Simulated mode redigera
To allow testing a Lua module together with an operational systems while causing zero or minimal impact on the latter, one or more of the software interfaces may be placed in simulated mode, thereby interacting with alternative data sources or sinks. The alternative functions are provided by the calling module.
For each interface, normal operation is indicated by mode 0 (the default), while a non-zero mode indicates which alternative function is used for simulation. There can be any number of alternative functions available, but only one function may be selected per interface at the same time.
Technical reference redigera
Exported functions redigera
call redigera
def redigera
sim redigera
Code samples redigera
See also redigera
License redigera
-- The Adapt module (adaptation layer)
local interface = {}
-- Exported functions and variables follow
local adapt = {}
adapt.def = function(ift)
interface = {}
local k, v
local i = 0
for k, v in pairs(ift) do
interface[i] = v
i = i + 1
end
return nil
end
adapt.call = function(cif, par)
return interface[cif](par)
end
adapt.sim = function(sim)
local k, v
local i = 0
for k, v in pairs(sim) do
interface[i] = v
end
return sim
end
return adapt