CQCC::Parm - Class used to manage class parameters
This class manages all class parameters and facilitates setting them from configuration files, environment variables, command line options, and other sources.
The class methods are not invoked by callers directly but through a series of convenience functions which handle Parm objects through a set of hash lists.
DefineParm()
is called by the owning class to describe the parameter
and its limitations and sources.
SetConfigParm()
, SetCmdParm()
, and SetIntParm()
are functions which
will remember a ``preference'' for the parameter's value on their own
separate lists. This allows parameter settings to be made before the
parameter has been defined.
GetParm()
``evaluates'' the parameter by seeing if there is a source for
a non-default value that fits the boundary conditions (multiple
available sources are evaluated in priority order); if not it will
return the default value if one is defined. Once the parameter has
been evaluated its value is stored so that later accesses to it will
not require re-evaluation.
ForceParm()
can be used to force overrides by clearing the current
setting, storing an Internal parameter value (highest priority) and
reevaluating the parameter.
SUPPORT POLICY: See TriggerCQCC.pm for the Rational Support Policy.
ClassTest(@args)
DefineParm(keys)
EvalParms()
ForceParm($name,$value)
GetParm($name)
GetParmHandle($name)
GetParmNameList($src)
new CQCC::Parm()
A Parm can be preset from one or more sources including, in order of priority, environment variables (SRC_EV=>1), command line options (SRC_CMD=>1), configuration settings (SRC_CFG=>1) or internal calls (SRC_INT=>1). Which sources are valid depends on the definition of the parameter. This allows complete control over which sources are allowed for each parameter. An additional source (SRC_CACHE) is supported but the parameters must also have an additional source such as SRC_INT.
A Parm can have a DEFAULT value set when it is defined and can have rudimentary value checking done by setting RANGE_MIN, RANGE_MAX or RANGE_LIST which will apply their respective tests when the Parm is being evaluated for the first time by GetParm().
Each Parm is assumed to have a message catalog entry that describes its use in appropriate detail for end user consumption.
The new()
method is not called directly but is invoked by the
convenience function DefineParm().
Errors:
(1) Parm with same name already exists.
(2) Need to add error checks for complete enough information
ParmDefined($name, { $source })
The optional $source argument also checks if a given data source provides a value, i.e. if ``CONFIG'', the method will only return 1 if the parameter exists and SetConfigParm has already been called for the parameter to set a configuration value. Permitted values include ``CONFIG'', ``CMDLINE'', and ``ENV''.
ParmParse($string)
ParmString($name)
PrintParms( {source} )
If a list result is expected, it will return the list of printable values rather than printing them directly. =back
SetConfigParm($name,$value)
It stores a parameter value ``preference'' that will be used only if it
is higher priority than other sources. It may be called before
DefineParm()
has defined the parameter but must be called before
GetParm()
has a chance to evaluate other options.
SetCmdParm($name,$value)
It stores a parameter value ``preference'' that will be used only if it
is higher priority than other sources. It may be called before
DefineParm()
has defined the parameter but must be called before
GetParm()
has a chance to evaluate other options.
SetIntParm($name,$value)
It stores a parameter value ``preference'' that will be used only if it
is higher priority than other sources. It may be called before
DefineParm()
has defined the parameter but must be called before
GetParm()
has a chance to evaluate other options.
SetParmDefaults(keys)