NAME
Config::Model::WizardHelper - Helps to create wizard widget for config models
SYNOPSIS
use Config::Model ;
my $inst = $model -> instance ( root_class_name => 'Master',
instance_name => 'test1');
my $root = $inst -> config_root ;
my $wizard = $inst -> wizard_helper ( leaf_cb => sub { ... },
hash_cb => sub { ... } );
$wizard->start ;
DESCRIPTION
This module provides a class that is able to scan a configuration tree and will call back user defined subroutines on one of the following condition:
A configuration item contains an error (mostly undefined mandatory values)
A configuration item has a
important
level. See level parameter for details.
By default, the wizard will only scan element with an intermediate
permission.
The wizard helper supports going forward and backward during the scan (to support back
and next
buttons on a wizard widget).
CONSTRUCTOR
The constructor should be used only by Config::Model::Instance with the wizard_helper method.
Creating a wizard helper
A wizard helper will need at least to kind of call-back that must be provided by the user: a call-back for leaf elements and a call-back for hash elements (that will be also used for list elements).
These call-back must be passed when creating the wizard object (the parameters are named lead_cb
and hash_cb
)
Here are the the parameters accepted by wizard_helper
:
call_back_on_important
Whether to call back when an important element is found (default 1).
permission
Specifies the permission of the element scanned by the wizard (default 'intermediate').
leaf_cb
Subroutine called backed for leaf elements. See "Callback prototypes" in Config::Model::ObjTreeScanner for signature and details. (mandatory)
hash_cb
Subroutine called backed for hash elements. See "Callback prototypes" in Config::Model::ObjTreeScanner for signature and details. (mandatory)
Custom callbacks
By default, leaf_cb
will be called for all types of leaf elements (i.e enum. integer, strings, ...). But you can provide dedicated call-back for each type of leaf:
enum_value_cb, enum_integer_value_cb, integer_value_cb,
number_value_cb, boolean_value_cb, string_value_cb
Likewise, you can also provide a call-back dedicated to list elements with list_cb
Methods
start
Start the scan and perform call-back when needed. This function will return when the scan is completely done.
wiz_go_forward
Set wizard in forward (default) mode.
wiz_go_backward
Set wizard in backward mode.
AUTHOR
Dominique Dumont, domi@komarr.grenoble.hp.com
SEE ALSO
Config::Model, Config::Model::Instance, Config::Model::Node, Config::Model::ObjTreeScanner,