NAME

Config::Model::Itself - Model editor for Config::Model

SYNOPSIS

my $meta_model = Config::Model -> new ( ) ;

# load Config::Model model
my $meta_inst = $model->instance (root_class_name => 'Itself::Model' ,
                                  instance_name   => 'meta_model' ,
                                 );

my $meta_root = $meta_inst -> config_root ;

# Itself constructor returns an object to read or write the data
# structure containing the model to be edited
my $rw_obj = Config::Model::Itself -> new(model_object => $meta_root ) ;

# now lead the model to be edited
$rw_obj -> read_all( conf_dir => '/path/to/model_files') ;

# For Curses UI prepare a call-back to write model
my $wr_back = sub { $rw_obj->write_all(conf_dir => '/path/to/model_files');

# create Curses user interface
my $dialog = Config::Model::CursesUI-> new
     (
      experience => 'advanced',
      store => $wr_back,
     ) ;

# start Curses dialog to edit the mode
$dialog->start( $meta_model )  ;

# that's it. When user quits curses interface, Curses will call
# $wr_back sub ref to write the modified model.

DESCRIPTION

The Config::Itself and its model files provide a model of Config:Model (hence the Itself name). If you install also Config::Model::TkUI, you get a graphical configuration model editor. In others words, you get a GUI to edit configuration models like Xorg model.

Let's step back a little to explain. Any configuration data is, in essence, structured data. This data could be stored in an XML file. A configuration model is a way to describe the structure and relation of all items of a configuration data set.

This configuration model is also expressed as structured data. This structure data is structured and follow a set of rules which are described for humans in Config::Model.

The structure and rules documented in Config::Model are also expressed in a model in the files provided with Config::Model::Itself.

Hence the possibity to verify, modify configuration data provided by Config::Model can also be applied on configuration models. Using the same user interface.

From a Perl point of view, Config::Model::Itself provides a class dedicated to read and write a set of model files.

Constructor

new ( model_object => ... )

Creates a new read/write handler. This handler is dedicated to the model_object passed with the constructor. This parameter must be a Config::Model::Node class.

Methods

read_all ( model_dir => ... , root_model => ... , [ force_load => 1 ] )

Load all the model files contained in model_dir and all its subdirectories. root_model is used to filter the classes read.

Use force_load if you are trying to load a model containing errors.

read_all returns a hash ref containing ( class_name => file_name , ...)

write_all ( model_dir => ... )

Will write back configuration model in the specified directory. The structure of the read directory is respected.

list_class_element

Returns a string listing all the class and elements. Useful for debugging your configuration model.

AUTHOR

Dominique Dumont, (ddumont at cpan dot org)

COPYRIGHT

Copyright (C) 2007-2009 by Dominique Dumont

LICENSE

This library is free software; you can redistribute it and/or modify it under the LGPL terms.

SEE ALSO

Config::Model, Config::Model::Node,