Cfg tree between components


#1

Hi,

A quick question. How is the config tree organized between components in the same app ? Can different components in the same app access the same config tree, and is there an example of how to do this ? I know that different apps can share the same tree, but I’m not clear on the tree structure for different components within the same app (I assumed that the different components would have different nodes under the same tree, so navigating would be easy, but maybe it’s not like this. Maybe each component has it’s own tree).

For example, if component1 writes string bar = “hello” to the app cfg tree under directory foo, how would component2 read foo/bar ?

thanks


#2

Hello,

The configTree works on a per-app basis. So, both components within an app share the same tree.

So, if I have an app named, “foo,” with components, “bar,” and “baz.” By default, both bar and baz can read from the config tree named “foo.”

If you want to grant write permission for your app to it’s tree add the following to the app’s .adef file:

requires:
{
    configTree:
    {
        [w] .   // Grant write access to this app's configTree.
    }
}

Components within an app get unfettered access to the app’s whole tree. The configTree service itself does not assume any structure at all. So, components are not separated under sub-nodes at all. So conventions need to be used. Like each component looks for all of it’s config under “/bar/…” and “/baz/…”

So if component 1 wants to read a value component 2 writes, they simply just have to both agree on what the path to this value is. Say, as a constant in a shared header file, the path does not need to change based on which component is issuing the read or write.

-Kelly