NAME
Config::Model::AnyThing - Base class for configuration tree item
VERSION
version 2.046
SYNOPSIS
# internal class
DESCRIPTION
This class must be inherited by all nodes or leaves of the configuration tree.
AnyThing provides some methods and no constructor.
Introspection methods
element_name()
Returns the element name that contain this object.
index_value()
For object stored in an array or hash element, returns the index (or key) containing this object.
parent()
Returns the node containing this object. May return undef if parent() is called on the root of the tree.
container_type()
Returns the type (e.g. list or hash or leaf or node or warped_node) of the element containing this object.
root()
Returns the root node of the configuration tree.
location()
Returns the node location in the configuration tree. This location conforms with the syntax defined by "grab()" method.
composite_name
Return the element name with its index (if any). I.e. returns foo:bar or foo.
Annotation
Annotation is a way to store miscellaneous information associated to each node. (Yeah... comments) These comments will be saved outside of the configuration file and restored the next time the command is run.
annotation( [ note1, [ note2 , ... ] ] )
Without argument, return a string containing the object's annotation (or an empty string).
With several arguments, join the arguments with "\n", store the annotations and return the resulting string.
load_pod_annotation ( pod_string )
Load annotations in configuration tree from a pod document. The pod must be in the form:
=over
=item path
Annotation text
=back
Information management
grab(...)
Grab an object from the configuration tree.
Parameters are:
step-
A string indicating the steps to follow in the tree to find the required item. (mandatory)
mode-
When set to
strict,grabwill throw an exception if no object is found using the passed string. When set toadaptative, the object found at last will be returned. For instance, for the stepgood_step wrong_step, only the object held bygood_stepwill be returned. When set toloose, grab will return undef in case of problem. (default isstrict) type-
Either
node,leaf,hashorlist. Returns only an object of requested type. Depending onstrictvalue,grabwill either throw an exception or return the last found object of requested type. (optional, default toundef, which means any type of object) autoadd-
When set to 1,
hashorlistconfiguration element are created when requested by the passed steps. (default is 1). - grab_non_available
-
When set to 1, grab will return an object even if this one is not available. I.e. even if this element was warped out. (default is 0).
The step parameters is made of the following items separated by spaces:
- -
-
Go up one node
- !
-
Go to the root node.
- !Foo
-
Go up the configuration tree until the
Fooconfiguration class is found. Raise an exception if noFooclass is found when root node is reached. - xxx
-
Go down using
xxxelement. - xxx:yy
-
Go down using
xxxelement and idyy(valid for hash or list elements) - ?xxx
-
Go up the tree until a node containing element
xxxis found. Then go down the tree like itemxxx.If
?xxx:yy, go up the tree the same way. But no check is done to see if idyyactually exists or not. Only the elementxxxis considered when going up the tree.
grab_value(...)
Like "grab(...)", but will return the value of a leaf or check_list object, not just the leaf object.
Will raise an exception if following the steps ends on anything but a leaf or a check_list.
grab_annotation(...)
Like "grab(...)", but will return the annotation of an object.
grab_root()
Returns the root of the configuration tree.
grab_ancestor( Foo )
Go up the configuration tree until the Foo configuration class is found. Returns the found node or undef.
model_searcher ()
Returns an object dedicated to search an element in the configuration model (respecting privilege level).
This method returns a Config::Model::SearchElement object. See Config::Model::Searcher for details on how to handle a search.
dump_as_data ( )
Dumps the configuration data of the node and its siblings into a perl data structure.
Returns a hash ref containing the data. See Config::Model::DumpAsData for details.
warp_error
Returns a string describing any issue with Config::Model::Warper object. Returns '' if invoked on a tree object without warp specification.
AUTHOR
Dominique Dumont, (ddumont at cpan dot org)
SEE ALSO
Config::Model, Config::Model::Instance, Config::Model::Node, Config::Model::Loader, Config::Model::Dumper
AUTHOR
Dominique Dumont
COPYRIGHT AND LICENSE
This software is Copyright (c) 2013 by Dominique Dumont.
This is free software, licensed under:
The GNU Lesser General Public License, Version 2.1, February 1999