ModuleGeneralLayout

advertisement
NOTE: if you have ANY questions about this file, just put them in here and tell somebody(currently Ace)
so they can answer the question in this file for all to see.
This is an overview of the module section design. First I will describe the module class itself
Module:
Members:


List<InputTerminal> inputTerminals
OutputTerminal outputTerminal



new Module()//constructor
run()
main(….inputs here…)
Methods:
Each module will just create the necessary (and appropriately) typed input terminals and output
terminal in the new method. This new is just a constructor that is called whenever a new
module is created(essentially when the user drags a module off their pallet). All the connections
will be handled between the terminals(as described below), the modules never see this happen.
The run method essentially wraps up the main method. The run gets all of the data it needs
from the input terminals. Additionally, all of the type checking occurs in the run method.
The main method is really where the meat of the module is. The main(just like the run) is
different for each type of module, it takes in the appropriate inputs as parameter and returns
the output. A simple example here will be helpful:
The main method for an “addition module”
int main(int i, int j) {
int z = i + j;
return z;
}
In addition to these general modules, there are a few specific types of modules
Answer Module:
This is simply the module that is put at the bottom of the “program”, where we get out
result(our answer) out. This means that it has a special method getValue() so that the
GUI can get out the result. This getValue() will essentially work as the run button: the
value is requested and then the requests are sent up the tree until they are returned
and resolved where we will close up our recursive calls(if this is confusing, comment, we
might want to write up a little section on how we are currently conceptualizing the
actual running of our program.
Constant Module:
A constant module simply is a module that takes no input from other module, but just
returns a single constant value. This is similar to the answer module in that it too has a
getValue() method, the different here is that the constant module also has a setValue
method that sets the value to be returned.
Now, moving on past the actual modules, lets talk about the terminals. There are 2 different types of
terminals, input terminals and output terminals. As above we will lay out some basic class structure for
these
InputTerminal:
Members:


OutputTerminal outTerminal
Type type



Connect(OutputTerminal outTerminal)
new(Type type)//constructor
getDataFromOutputTerminal()
Methods
The input terminals handle starting up the connection between the input and output
terminals. When the module that contains the input terminal request the data, this
request is simply passed on to the getDataFromOutputTerminal method.
OutputTerminal:
Output terminals are very similar to input terminals except you replace the
getDataFromOutputTerminal method with a getDataFromModule method.
Additionally, you no longer have the connect method, this is all taken care of in input
terminals. Finally, the output terminal also has the module that contains it as a
member; output terminals must know about the module they are contained in so that
they may request data from it.
Download