# bdm::SettingResolver Class Reference

This class serves to expand links used within configuration files. More...

`#include <user_info.h>`

List of all members.

## Public Member Functions
| SettingResolver (const Setting &potential_link)
| If potential_link contains a link to some other setting, it is resolved here. Anyway, the Setting reference result is prepared for use.
| ~SettingResolver ()
| An opened UIFile file is closed here if necessary.
## Public Attributes
const Setting & | result
| Reference to a resolved link or to the original Setting in the case it does not contain a link.
## Private Member Functions
virtual string | to_string ()
| This method returns a basic info about the current instance.
virtual void | from_setting (const Setting &set)
| This method arrange instance properties according the data stored in the Setting structure.
virtual void | to_setting (Setting &set) const
| This method save all the instance properties into the Setting structure.
virtual void | validate ()
| This method TODO.

## Detailed Description

This class serves to expand links used within configuration files.

Value of any type but string can be linked to some other value of the same type defined elsewhere in the current configuration file or even in some different configuration file.

Link have three parts, <name> : <path> <@filename>. Field <name> contains the name of the new setting, <path> is the relative path to the referenced setting, which has to be taken from the root Setting element. The last part <@filename> is optional, it contains filename in the case the link should refer to a variable stored in a different file. From the previous part <path>, it has to be separated by '@'.

        ...
            jardovo :
            {
              class = "Car";
              year = 1992;
              manufacturer = "liaz";
              kilometers = 1555000;
            };
            ondrejovo :
            {
              class = "Bike";
              year = 1996;
              manufacturer = "author";
              electricLights = true;
              matr = ( 2, 2, [ 1.0, 0.0, 0.0, 1.0 ] );
            };

            #this is the example of local link to another mean of transport
            elisky = "jardovo";

            ...

            # And this link is external link pointing to the file "other_cars.cfg" stored in the
            # same directory. In that file, it refers to the local Setting "magic_cars.skubankovo".
            kati = "magic_cars.skubankovo@other_cars.cfg";

        ...

When you want to expand a possible linked setting "element" within your code, it has to be treated this way:

            ...

            const SettingResolver link( element );

            ...

            int len = link.result.getLength();

            ...

The whole point is that a resolved link (class member result, i.e., "link.result" in the previous example) could point into a different configuration file. In that case there has to be an UIFile instance managing reading from this file. As the libconfig::Config deletes all its Settings when dealocated, UIFile must not be dealocated until all the necessary operation on the linked Setting are finished (otherwise, the link result would be invalid just after the UIFile dealocation). And that is exactly the mechanism implemented within SettingResolver class. It assures, that the result Setting reference is valid within the scope of SettingResolver instance.

User Infos and their use

The documentation for this class was generated from the following files:

- user_info.h
- user_info.cpp