Langue: en

Autres versions - même langue

Version: 2010-06-11 (ubuntu - 24/10/10)

Section: 3 (Bibliothèques de fonctions)


Config::Model::AnyThing - Base class for configuration tree item


version 1.205


  package Config::Model::Node ;
  use base qw/Config::Model::AnyThing/ ;


This class must be inherited by all nodes or leaves of the configuration tree.

AnyThing provides some methods and no constructor.

Introspection methods


Returns the element name that contain this object.


For object stored in an array or hash element, returns the index (or key) containing this object.


Returns the node containing this object. May return undef if "parent()" is called on the root of the tree.


Returns the type (e.g. "list" or "hash" or "leaf" or "node" or "warped_node") of the element containing this object.


Returns the root node of the configuration tree.


Returns the node location in the configuration tree. This location conforms with the syntax defined by ``grab()'' method.


Return the element name with its index (if any). I.e. returns "foo:bar" or "foo".


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.

Information management


Grab an object from the configuration tree.

Parameters are:

A string indicating the steps to follow in the tree to find the required item. (mandatory)
When set to 1, "grab" will throw an exception if no object is found using the passed string. When set to 0, the object found at last will be returned. For instance, for the step "good_step wrong_step", only the object held by "good_step" will be returned. (default is 1)
Either "node", "leaf", "hash" or "list". Returns only an object of requested type. Depending on "strict" value, "grab" will either throw an exception or return the last found object of requested type. (optional, default to "undef", which means any type of object)
When set to 1, "hash" or "list" configuration element are created when requested by the passed steps. (default is 1).
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.
Go down using "xxx" element.
Go down using "xxx" element and id "yy" (valid for hash or list elements)
Go up the tree until a node containing element "xxx" is found. Then go down the tree like item "xxx".

If "?xxx:yy", go up the tree the same way. But no check is done to see if id "yy" actually exists or not. Only the element "xxx" is considered when going up the tree.


Like ``grab(...)'', but will return the value of a leaf object, not just the leaf object.

Will raise an exception if following the steps ends on anything but a leaf.


Like ``grab(...)'', but will return the annotation of an object.


Returns the root of the configuration tree.

searcher ()

Returns an object dedicated to search an element in the configuration model (respecting privilege level).

This method returns a Config::Model::Searcher 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.


Dominique Dumont, (ddumont at cpan dot org)


Config::Model, Config::Model::Instance, Config::Model::Node, Config::Model::Loader, Config::Model::Dumper