Config::Model::Searcher(3pm)

Config::Model::Searcher3pm

Search an element in a configuration model

Usage

 use Config::Model ;
 # create your config model
 my $model = Config::Model -> new ;
 $model->create_config_class( ... ) ;
 # create instance
 my $inst = $model->instance (root_class_name => 'FooBar', 
                              instance_name => 'test1');
 # create root of config
 my $root = $inst -> config_root ;
 # create searcher for manual search
 my $searcher = $root->searcher();
 $searcher -> prepare (element => 'X') ;
 my $step1 = $searcher->next_step() ; # return possibilities
 my $obj1 = $searcher->choose($step1->[0]) ;
 my $step2 = $searcher->next_step() ; # return possibilities
 my $target = $searcher->choose($step2->[1]) ;
 # automatic search
 my $element_call_back = sub { ... ; return 'foo' ;} ;
 my $id_call_back      = sub { ... ; return 'bar' ;} ;
 $searcher->reset ;
 my $target = $searcher->auto_choose($element_call_back, $id_call_back) ;

Version

version 1.205

Overview

This modules provides a way to search for a configuration element in a configuration tree.

For instance, suppose that you have a xorg.conf model and you know that you need to tune the "MergedXinerama" parameter, but you don't remember where is this parameter in the configuration tree. This module will guide you through the tree to the(s) node(s) that contain this parameter.

This class should be invaluable to construct interactive GUIs.

This module provides 2 search modes:

•

A manual search where you are guided step by step to the element you're looking for. At each step, the module will return you the possible paths to choose from. The user will have to choose the correct path from the available paths. Most of the time, only one possibility will be returned, so the user choice should be straightforward. In other case (more that one choice), the user will have to decide the next step.

•

An automatic search where you provide call-back that will resolve the ambiguities in case of multiple paths.

Constructor

The constructor should be used only by Config::Model::Node.

Methods

get_searchable_elements

Return the list of elements found in model that can be searched in the configuration tree.

prepare(element => ...)

Prepare the searcher to look for the element passed in the argument. Returns the searcher object (i.e. $self).

reset

Re-initialise the search engine to redo the search from start

searched

Returns the searched element name.

Author

Dominique Dumont, (ddumont at cpan dot org)

From libconfig-model-perl 1.205-1 in Debian 6.0 (Squeeze). Parsed by carta from the page's man source.