1Config::Model::Node(3pmU)ser Contributed Perl DocumentatiCoonnfig::Model::Node(3pm)
2
3
4
6 Config::Model::Node - Class for configuration tree node
7
9 version 2.153
10
12 use Config::Model;
13
14 # define configuration tree object
15 my $model = Config::Model->new;
16 $model->create_config_class(
17 name => 'OneConfigClass',
18 class_description => "OneConfigClass detailed description",
19
20 element => [
21 [qw/X Y Z/] => {
22 type => 'leaf',
23 value_type => 'enum',
24 choice => [qw/Av Bv Cv/]
25 }
26 ],
27
28 status => [ X => 'deprecated' ],
29 description => [ X => 'X-ray description (can be long)' ],
30 summary => [ X => 'X-ray' ],
31
32 accept => [
33 'ip.*' => {
34 type => 'leaf',
35 value_type => 'uniline',
36 summary => 'ip address',
37 }
38 ]
39 );
40 my $instance = $model->instance (root_class_name => 'OneConfigClass');
41 my $root = $instance->config_root ;
42
43 # X is not shown below because of its deprecated status
44 print $root->describe,"\n" ;
45 # name value type comment
46 # Y [undef] enum choice: Av Bv Cv
47 # Z [undef] enum choice: Av Bv Cv
48
49 # add some data
50 $root->load( steps => 'Y=Av' );
51
52 # add some accepted element, ipA and ipB are created on the fly
53 $root->load( steps => q!ipA=192.168.1.0 ipB=192.168.1.1"! );
54
55 # show also ip* element created in the last "load" call
56 print $root->describe,"\n" ;
57 # name value type comment
58 # Y Av enum choice: Av Bv Cv
59 # Z [undef] enum choice: Av Bv Cv
60 # ipA 192.168.1.0 uniline
61 # ipB 192.168.1.1 uniline
62
64 This class provides the nodes of a configuration tree. When created, a
65 node object gets a set of rules that defines its properties within the
66 configuration tree.
67
68 Each node contain a set of elements. An element can contain:
69
70 • A leaf element implemented with Config::Model::Value. A leaf can be
71 plain (unconstrained value) or be strongly typed (values are
72 checked against a set of rules).
73
74 • Another node.
75
76 • A collection of items: a list element, implemented with
77 Config::Model::ListId. Each item can be another node or a leaf.
78
79 • A collection of identified items: a hash element, implemented with
80 Config::Model::HashId. Each item can be another node or a leaf.
81
83 A class declaration is made of the following parameters:
84
85 name
86 Mandatory "string" parameter. This config class name can be used by
87 a node element in another configuration class.
88
89 class_description
90 Optional "string" parameter. This description is used while
91 generating user interfaces.
92
93 class
94 Optional "string" to specify a Perl class to override the defaul