1Config::Model::CheckLisUts(e3r)Contributed Perl DocumentCaotnifoing::Model::CheckList(3)
2
3
4
6 Config::Model::CheckList - Handle check list element
7
9 version 1.205
10
12 $model ->create_config_class
13 (
14 ...
15 element
16 => [
17 check_list
18 => { type => 'check_list',
19 choice => [ 'A', 'B', 'C', 'D' ],
20 help => { A => 'A effect is this',
21 D => 'D does that',
22 }
23 },
24 check_list_refering_to_another_hash
25 => { type => 'check_list',
26 refer_to => '- foobar'
27 },
28
29 ]
30 ) ;
31
33 This class provides a check list element for a Config::Model::Node. In
34 other words, this class provides a list of booleans items. Each item
35 can be set to 1 or 0.
36
37 The available items in the check list can be :
38
39 · A fixed list (with the "choice" parameter)
40
41 · A dynamic list where the available choise are the keys of another
42 hash of the configuration tree. See "Choice reference" for details.
43
45 CheckList object should not be created directly.
46
48 A check list element must be declared with the following parameters:
49
50 type
51 Always "checklist".
52
53 choice
54 A list ref containing the check list items (optional)
55
56 refer_to
57 This parameter is used when the keys of a hash are used to specify
58 the possible choices of the check list. "refer_to" point to a hash
59 or list element in the configuration tree. See "Choice reference"
60 for details. (optional)
61
62 computed_refer_to
63 Like "refer_to", but use a computed value to find the hash or list
64 element in the configuration tree. See "Choice reference" for
65 details. (optional)
66
67 default_list
68 List ref to specify the check list items which are "on" by default.
69 (optional)
70
71 ordered
72 Specify whether the order of checked items must be preserved.
73
74 help
75 Hash ref to provide information on the check list items.
76
77 warp
78 Used to provide dynamic modifications of the check list properties
79 See Config::Model::WarpedThing for details
80
81 For example:
82
83 · A simple check list with help:
84
85 choice_list
86 => { type => 'check_list',
87 choice => ['A' .. 'Z'],
88 help => { A => 'A help', E => 'E help' } ,
89 },
90
91 · A check list with default values:
92
93 choice_list_with_default
94 => { type => 'check_list',
95 choice => ['A' .. 'Z'],
96 default_list => [ 'A', 'D' ],
97 },
98
99 · A check list whose available choice and default change depending on
100 the value of the "macro" parameter:
101
102 'warped_choice_list'
103 => { type => 'check_list',
104 warp => { follow => '- macro',
105 rules => { AD => { choice => [ 'A' .. 'D' ],
106 default_list => ['A', 'B' ] },
107 AH => { choice => [ 'A' .. 'H' ] },
108 }
109 }
110 },
111
113 The following methods returns the checklist parameter :
114
115 refer_to
116 computed_refer_to
117
119 The choice items of a check_list can be given by another configuration
120 element. This other element can be:
121
122 · The keys of a hash
123
124 · Another checklist. In this case only the checked items of the other
125 checklist will be available.
126
127 This other hash or other checklist is indicated by the "refer_to" or
128 "computed_refer_to" parameter. "refer_to" uses the syntax of the "step"
129 parameter of grab(...)
130
131 See refer_to parameter.
132
133 Reference examples
134 · A check list where the available choices are the keys of "my_hash"
135 configuration parameter:
136
137 refer_to_list
138 => { type => 'check_list',
139 refer_to => '- my_hash'
140 },
141
142 · A check list where the available choices are the checked items of
143 "other_check_list" configuration parameter:
144
145 other_check_list => { type => 'check_list',
146 choice => [qw/A B C/]
147 },
148 refer_to_list
149 => { type => 'check_list',
150 refer_to => '- other_check_list'
151 },
152
153 · A check list where the available choices are the keys of "my_hash"
154 and "my_hash2" and "my_hash3" configuration parameter:
155
156 refer_to_3_lists
157 => { type => 'check_list',
158 refer_to => '- my_hash + - my_hash2 + - my_hash3'
159 },
160
161 · A check list where the available choices are the specified choice
162 and the choice of "refer_to_3_lists" and a hash whose name is
163 specified by the value of the "indirection" configuration parameter
164 (this example is admitedly convoluted):
165
166 refer_to_check_list_and_choice
167 => { type => 'check_list',
168 computed_refer_to => { formula => '- refer_to_2_list + - $var',
169 variables { 'var' => '- indirection ' }
170 },
171 choice => [qw/A1 A2 A3/],
172 },
173
175 get_type
176 Returns "check_list".
177
178 cargo_type()
179 Returns 'leaf'.
180
181 check ( $choice )
182 Set choice.
183
184 uncheck ( choice )
185 Unset choice
186
187 is_checked( choice )
188 Return 1 if the given "choice" was set. Returns 0 otherwise.
189
190 get_choice
191 Returns an array of all items names that can be checked (i.e. that can
192 have value 0 or 1).
193
194 get_help (choice_value)
195 Return the help string on this choice value
196
197 clear
198 Reset the check list (all items are set to 0) (can also be called as
199 "clear_values")
200
201 get_checked_list_as_hash ( [ custom | preset | standard | default ] )
202 Returns a hash (or a hash ref) of all items. The boolean value is the
203 value of the hash.
204
205 Example:
206
207 { A => 0, B => 1, C => 0 , D => 1}
208
209 By default, this method will return all items set by the user, or items
210 set in preset mode or checked by default.
211
212 With a parameter, this method will return either:
213
214 custom
215 The list entered by the user
216
217 preset
218 The list entered in preset mode
219
220 standard
221 The list set in preset mode or checked by default.
222
223 default
224 The default list (defined by the configuration model)
225
226 upstream_default
227 The list implemented by upstream project (defined in the
228 configuration model)
229
230 get_checked_list ( [ custom | preset | standard | default ] )
231 Returns a list (or a list ref) of all checked items (i.e. all items set
232 to 1).
233
234 fetch ( [ custom | preset | standard | default ] )
235 Returns a string listing the checked items (i.e. "A,B,C")
236
237 get( path [, custom | preset | standard | default ])
238 Get a value from a directory like path.
239
240 set( path , values )
241 Set a checklist with a directory like path. Since a checklist is a
242 leaf, the path should be empty. The values are a comma separated list
243 of checked items.
244
245 Example : "$leaf->set('','A,C,Z') ;"
246
247 set_checked_list ( item1, item2, ..)
248 Set all passed items to checked (1). All other available items in the
249 check list are set to 0.
250
251 Example:
252
253 # set cl to A=0 B=1 C=0 D=1
254 $cl->set_checked_list('B','D')
255
256 set_checked_list_as_hash ( A => 1, B => 1 )
257 Set check_list items. Missing items in the given list of parameters are
258 set to 0.
259
260 The example ( A => 1, B => 1 ) above will give :
261
262 A = 1 , B = 1, C = 0 , D = 0
263
264 load_data ( list_ref )
265 Load check_list as an array ref. Data is simply forwarded to
266 set_checked_list.
267
269 All the methods below are valid only for ordered checklists.
270
272 Swap the 2 given choice in the list. Both choice must be already set.
273
275 Move the choice up in the checklist.
276
278 Move the choice down in the checklist.
279
281 Dominique Dumont, (ddumont at cpan dot org)
282
284 Config::Model, Config::Model::Instance, Config::Model::Node,
285 Config::Model::AnyId, Config::Model::ListId, Config::Model::HashId,
286 Config::Model::Value
287
288
289
290perl v5.12.1 2010-08-18 Config::Model::CheckList(3)