1Config::Model::InstanceU(s3e)r Contributed Perl DocumentaCtoinofnig::Model::Instance(3)
2
3
4
6 Config::Model::Instance - Instance of configuration tree
7
9 version 1.205
10
12 my $model = Config::Model->new() ;
13 $model ->create_config_class ( ... ) ;
14
15 my $inst = $model->instance (root_class_name => 'SomeRootClass',
16 instance_name => 'some_name');
17
19 This module provides an object that holds a configuration tree.
20
22 An instance object is created by calling instance method on an existing
23 model:
24
25 my $inst = $model->instance (root_class_name => 'SomeRootClass',
26 instance_name => 'test1');
27
28 The directory (or directories) holding configuration files is specified
29 within the configuration model. For test purpose you can change the
30 "root" directory with "root_dir" parameter:
31
32 root_dir
33 Pseudo root directory where to read and write configuration files
34
35 backend
36 Specify which backend to use. See "write_back ( ... )" for details
37
38 skip_read
39 When set, configuration files will not be read when creating
40 configuration tree.
41
42 Note that the root directory specified within the configuration model
43 will be overridden by "root_dir" parameter.
44
45 If you need to load configuration data that are not correct, you can
46 use "force_load => 1". Then, wrong data will be discarded.
47
49 name()
50 Returns the instance name.
51
52 config_root()
53 Returns the root object of the configuration tree.
54
55 reset_config
56 Destroy current configuration tree (with data) and returns a new tree
57 with data (and annotations) loaded from disk.
58
59 config_model()
60 Returns the model (Config::Model object) of the configuration tree.
61
62 annotation_saver()
63 Returns the object loading and saving annotations. See
64 Config::Model::Annotation for details.
65
66 preset_start ()
67 All values stored in preset mode are shown to the user as default
68 values. This feature is useful to enter configuration data entered by
69 an automatic process (like hardware scan)
70
71 preset_stop ()
72 Stop preset mode
73
74 preset ()
75 Get preset mode
76
77 push_no_value_check ( fetch | store | type , ... )
78 Tune "Config::Model::Value" to perform check on read (fetch) or write
79 (store) or verify the value according to its "value_type". The passed
80 parameters are stacked. Parameters are :
81
82 store Skip write check.
83
84 fetch Skip read check.
85
86 type Skip value_type check (See Config::Model::Value for details).
87 I.e Config::Model::Value will not enforce type checking.
88
89 Note that these values are stacked. They can be read by get_value_check
90 until the next push_no_value_check or pop_no_value_check call.
91
92 Example:
93
94 $i->push_no_value_check('fetch') ;
95 $i->push_no_value_check('fetch','type') ;
96
97 pop_no_value_check()
98 Pop off the check stack the last check set entered with
99 "push_no_value_check".
100
101 get_value_check ( fetch | store | type | fetch_or_store | fetch_and_store )
102 Read the check status. Returns 1 if a check is to be done. O if not.
103 When used with the "fetch_or_store" parameter, returns a logical "or"
104 or the check values, i.e. "read_check || write_check"
105
106 data( kind, [data] )
107 The data method provide a way to store some arbitrary data in the
108 instance object.
109
110 load( "..." )
111 Load configuration tree with configuration data. See
112 Config::Model::Loader for more details
113
114 searcher ( )
115 Returns an object dedicated to search an element in the configuration
116 model (respecting privilege level).
117
118 This method returns a Config::Model::Searcher object. See
119 Config::Model::Searcher for details on how to handle a search.
120
121 wizard_helper ( ... )
122 This method returns a Config::Model::WizardHelper object. See
123 Config::Model::WizardHelper for details on how to create a wizard
124 widget with this object.
125
126 wizard_helper arguments are explained in Config::Model::WizardHelper
127 constructor arguments.
128
130 Usually, a program based on config model must first create the
131 configuration model, then load all configuration data.
132
133 This feature enables you to declare with the model a way to load
134 configuration data (and to write it back). See Config::Model::AutoRead
135 for details.
136
137 read_root_dir()
138 Returns root directory where configuration data is read from.
139
140 backend()
141 Get the preferred backend method for this instance (as passed to the
142 constructor).
143
144 write_root_dir()
145 Returns root directory where configuration data is written to.
146
147 register_write_back ( backend_name, sub_ref )
148 Register a sub ref (with the backend name) that will be called with
149 "write_back" method.
150
151 write_back ( ... )
152 Try to run all subroutines registered with "register_write_back" to
153 write the configuration information until one succeeds (returns true).
154 (See Config::Model::AutoRead for details).
155
156 You can specify here a pseudo root dir or another config dir to write
157 configuration data back with "root" and "config_dir" parameters. This
158 will override the model specifications.
159
160 You can force to use a backend by specifying "backend => xxx". For
161 instance, "backend => 'augeas'" or "backend => 'custom'".
162
163 You can force to use all backend to write the files by specifying
164 "backend => 'all'".
165
166 "write_back" will croak if no write call-back are known.
167
169 Dominique Dumont, (ddumont at cpan dot org)
170
172 Config::Model, Config::Model::Node, Config::Model::Loader,
173 Config::Model::Searcher, Config::Model::Value,
174
175
176
177perl v5.12.1 2010-08-18 Config::Model::Instance(3)