Top Up Prev Next Bottom Contents Index Search

2.5 Modifying PortHoles and States in Derived Classes

When one star is derived from another, it inherits all the states of the base class star. Sometimes we want to modify some aspect of the behavior of a base class state in the derived class. This is done by placing calls to member functions of the state in the constructor of the derived star. Useful functions include setInitValue to change the default value, and setAttibututes and clearAttributes to modify attributes.

When creating new stars derived from stars already in the system, you will often also wish to customize them by adding new ports or states. In addition, you may wish to remove ports or states. Although, strictly speaking, you cannot do this, you can achieve the desired effect by simply hiding them from the user.

The following code will hide a particular state named statename from the user:

constructor {
statename. clearAttributes(A_SETTABLE);
}
This means that when the user invokes " edit-params" in pigi, statename will not appear as one of the parameters of the star. Of course, the state can still be set and used within the code defining the star.

The same effect can be achieved with outputs or inputs. For instance, given an output named output, you can use the following code:

constructor {
output. setAttributes(P_HIDDEN);
}
This means that when you create an icon for this star, no terminal will appear for this port. This is most useful when output is a multiporthole, because this means simply that there will be zero instances of the individual portholes.

This technique can also be used to hide individual portholes, however, the porthole will still be present, so it must be used with caution. Most domains do not allow disconnected portholes, and will flag an error. You can explicitly connect the port within the body of the star (see the kernel manual).



Top Up Prev Next Bottom Contents Index Search

Copyright © 1990-1997, University of California. All rights reserved.