Root

Gateway

Every method call on a tree is directed at the Root which holds a dictionary of its leafs and calls the appropriate object.

Type safety

Since objects are typed, the Root is responsible for verifying type compatibility before calling the object.

Notification

Once a Root has called an object, it notifies all the registered commands with the called path and the returned value so that the commands can notify all their observers.

Url router

When a Root’s “send” method is called with a remote unknown link. The Root is responsible for routing the message to the appropriate object or proxy object depending on the protocol.

For example, you might have an OscCommand registered for the “osc” protocol, an HTTPCommand for “http” and a PipeCommand for “whatever”. With these commands in place, Root can forward the messages depending on the protocol used to reach the remote object.

When a unknown link is sent to a remote object, it is actually sent to an ObjectProxy which is in turn responsible to asynchronously update the remote object.

osc://daisy.local/gain            ---> OscCommand  --> [daisy.local RootProxy]
http://"elphel1"/resolution       ---> HTTPCommand --> ["elphel1" RootProxy]
whatever://buz.local/schmok       ---> PipeCommand --> [buz.local RootProxy]
/blah/fox                         ---> same tree, no Command used

You can have a look at Url for details on url formats.

Memory management

When an object is inserted into an “execution” tree, it is adopted by it’s parent. This means that when a parent is deleted, all its children are also destroyed.

As the name implies, the Root has no parent and is the parent of all objects in the tree. This implies that destroying the root effectively destroys the tree.

Commands

A Root also adopts Commands (gates to the outside world). These are also destroyed with the Root.