Search code examples
objectglibdbus

What is D-Bus Object Tree?


I have read lot of D-Bus documentation and understood various concepts such as:

1. Object
2. Interface
3. Method
4. Signal
5. Bus Connection
6. System vs Session Daemon

However while reading through ObjectManager::GetManagedObjects I came across this concept of "Object Tree". I know that I when I invoke the above method on a service object, it gives me all the interfaces in the tree with the service object as the root (Since the service object implements ObjectManager interface from D-Bus).

I would like someone to very clearly explain what does it mean exactly when one object comes "under" a root object in an "object tree"

  1. Are children object just properties of parent object?
  2. Do children object subclass the parent object (Just like OOP)

What is D-Bus Object Tree? Please!


Solution

  • The semantics of the object tree are determined by the particular service which is providing it. By convention, the location of objects in a tree is just determined by their object path. For example, /org/freedesktop/Accounts/User1000 is considered to be a ‘child object’ of /org/freedesktop/Accounts. However, there is no formal relationship beyond this.

    To answer your specific questions:

    • Are children object just properties of parent object? No, they are separate objects with their own set of properties. The only thing they have in common with the parent is a prefix on their object path.
    • Do children object subclass the parent object (Just like OOP)? No. They may implement the same interfaces, different interfaces, or anything inbetween. Typically, they will implement a different interface — it’s quite common to have a parent object implement a ‘manager’ interface, and the child objects implement an ‘item’ interface, for describing collections of items.