module hconnect{
int+read _direction;
string+read _*offer_name;
string+read _*accept_name;
string+read _*offer;
string+read _*accept;
int+read _skip_levels;
int+read _order;
int+write _accepted;
};
The hconnect module allows connections to be made automatically as objects are instanced. The connections are made between subobjects of the instanced object and an existing instance of the hconnect that is an ancestor of the instanced object. For some networks, this can make network construction easier.
You use this module when an object's location in the object hierarchy is an indication that a particular connection is to be made. For example, you can define a macro that contains a user interface panel so that as you drop widgets into this macro, the widgets parent connections are connected to the panel.
With this module, connections can be made either from the parent to the child or from the child to the parent as specified by the direction parameter. For each connection, one hconnect module serves as the child to "offer" a connection and another hconnect module serves as the parent "accepting" the connection. An individual hconnect module can serve as a parent, child, or both.
The offer_name parameter specifies the pathname relative to the hconnect module of the subobject that should be connected. The accept_name parameter specifies the pathname relative to the parent module
A hierarchical class specification allows flexible classification of the offer and accept objects so that connections can be targeted to an appropriate parent. For example, you can define particular types of subobjects that are to connect to particular types of parents.
By default, as the child searches for a parent to connect to, it looks for hconnect modules that are direct ancestors of the child. This includes any immediate parent of the hconnect module and all peers of all parents. It is sometimes useful to define the parent hconnect module as a child of one of the peers of a parent. In this case, you can set the hconnect property to 2 on the peer of your parent so that the hconnect module can be found.
These strings are specified as a hierarchical list of classes. Each class is specified as a simple white-space delimited identifier with an optional set of sub-classes. Two class strings match if they have a single class that matches. If a class in both the offer and accept have a sub-class specification, one of the classes in the sub-class specification must also match. For example:
This example shows how to use hconnect to define both child and parent widgets that are to be connected when the child is instanced as a subobject of the parent. To use this example, load these objects into a library and instance the EXtest object.
UIslider+GMOD.hconnect EXslider {
direction = 0; // connection goes from child to parent
offer = "widget"; // connect to "widget" class
offer_name = "parent"; // connect parent subobject of EXslider
};
macro EXpanel {
UIshell+GMOD.hconnect parent_shell {
accept = "widget"; // accept all offer = "widget" children
accept_name = "."; // connect to parent_shell itself
};
};
application EXtest {
// Creates a shell that has a slider in it.
// The connection dynamically is:
//
// EXslider.parent => EXpanel;
//
EXpanel EXpanel {
EXslider EXslider;
};
};
This example shows how to define a menu bar macro and a set of children objects that install themselves into th
This example shows how to define a menu bar macro and a set of children objects that install themselves into the parent. To use this example, load these objects into a library and instance the EXmenu_bar object.
UIcmd+GMOD.hconnect EXcmd {
direction = 1; // connect from parent to child
offer = "cmd"; // connect to all cmds
offer_name = "."; // connect this object to the parent
};
UIcmdList+GMOD.hconnect EXcmdList {
direction = 1;
accept = "cmd cmdList";
// accepts either cmds or cmdLists
accept_name = "cmdList";
offer = "cmdList";
offer_name = ".";
};
macro EXmenu_bar {
// hconnect=2 causes us to search subobjects for
// hconnect modules
macro CmdLists<hconnect=2> {
UIshell shell {
_________menu => <-.menu_bar;
};
// menu_bar.cmdList => {CmdLists.File, CmdLists.Edit};
EXcmdList menu_bar {
_________direction = 1;
___// only accept cmdLists
___accept = "cmdList";
};
______EXcmdList File {
___accept = "cmd (File)";
};
EXcmdList Edit {
___accept = "cmd (Edit)";
};
};
// connection is made from File.cmdList => {New_File};
EXcmd New_File {
offer = "cmd (File)";
};
// connection is made from Edit.cmdList => {New_Edit};
EXcmd New_Edit {
offer = "cmd (Edit)";
};
};