+
+
+--- Object representation of a scheme/config section.
+-- @class module
+-- @cstyle instance
+-- @name luci.uvl.section
+
+--- Section instance constructor.
+-- @class function
+-- @name section
+-- @param scheme Scheme instance
+-- @param co Configuration data
+-- @param st Section type
+-- @param c Configuration name
+-- @param s Section name
+-- @return Section instance
+section = luci.util.class()
+
+function section.__init__(self, scheme, co, st, c, s)
+ self.csection = co[s]
+ self.ssection = scheme.packages[c].sections[st]
+ self.cref = { c, s }
+ self.sref = { c, st }
+ self.scheme = scheme
+ self.config = co
+ self.type = luci.uvl.TYPE_SECTION
+end
+
+--- Get the config path of this section.
+-- @return String containing the identifier
+function section.cid(self)
+ return ( self.cref[1] or '?' ) .. '.' .. ( self.cref[2] or '?' )
+end
+
+--- Get the scheme path of this section.
+-- @return String containing the identifier
+function section.sid(self)
+ return ( self.sref[1] or '?' ) .. '.' .. ( self.sref[2] or '?' )
+end
+
+--- Get all configuration values within this section.
+-- @return Table containing the values
+function section.values(self)
+ return self.csection
+end
+
+--- Get the associated section information in scheme.
+-- @return Table containing the scheme properties
+function section.section(self)
+ return self.ssection
+end
+
+--- Get all option objects associated with this section.
+-- @return Table containing all associated luci.uvl.option instances
+function section.variables(self)
+ local v = { }
+ if self.scheme.packages[self.sref[1]].variables[self.sref[2]] then
+ for o, _ in pairs(
+ self.scheme.packages[self.sref[1]].variables[self.sref[2]]
+ ) do
+ table.insert( v, luci.uvl.option(
+ self.scheme, self.config, self.sref[2],
+ self.cref[1], self.cref[2], o
+ ) )
+ end
+ end
+ return v
+end
+
+
+--- Object representation of a scheme/config option.
+-- @class module
+-- @cstyle instance
+-- @name luci.uvl.option
+
+--- Section instance constructor.
+-- @class function
+-- @name option
+-- @param scheme Scheme instance
+-- @param co Configuration data
+-- @param st Section type
+-- @param c Configuration name
+-- @param s Section name
+-- @param o Option name
+-- @return Option instance
+option = luci.util.class()
+
+function option.__init__(self, scheme, co, st, c, s, o)
+ self.coption = co[s] and co[s][o] or nil
+ self.soption = scheme.packages[c].variables[st][o]
+ self.cref = { c, s, o }
+ self.sref = { c, st, o }
+ self.scheme = scheme
+ self.config = co
+ self.type = luci.uvl.TYPE_OPTION
+end
+
+--- Get the config path of this option.
+-- @return String containing the identifier
+function option.cid(self)
+ return ( self.cref[1] or '?' ) .. '.' ..
+ ( self.cref[2] or '?' ) .. '.' ..
+ ( self.cref[3] or '?' )
+end
+
+--- Get the scheme path of this option.
+-- @return String containing the identifier
+function option.sid(self)
+ return ( self.sref[1] or '?' ) .. '.' ..
+ ( self.sref[2] or '?' ) .. '.' ..
+ ( self.sref[3] or '?' )
+end
+
+--- Get the value of this option.
+-- @return The associated configuration value
+function option.value(self)
+ return self.coption
+end
+
+--- Get the associated option information in scheme.
+-- @return Table containing the scheme properties
+function option.option(self)
+ return self.soption
+end
+
+--- Get the associated section information in scheme.
+-- @return Table containing the scheme properties
+function option.section(self)
+ return self.scheme.packages[self.sref[1]].sections[self.sref[2]]
+end