* @param minimumBufferSizes A map from relation
* to the minimum possible buffer size of that relation.
*/
protected void _saveBufferSizes(final Map minimumBufferSizes) {
Director director = (Director) getContainer();
final CompositeActor container = (CompositeActor) director
.getContainer();
// FIXME: These buffer sizes should be properties of input ports,
// not properties of relations.
ChangeRequest request = new ChangeRequest(this, "Record buffer sizes") {
protected void _execute() throws KernelException {
Iterator relations = container.relationList().iterator();
while (relations.hasNext()) {
Relation relation = (Relation) relations.next();
Object bufferSizeObject = minimumBufferSizes.get(relation);
if (bufferSizeObject instanceof Integer) {
int bufferSize = ((Integer) bufferSizeObject)
.intValue();
DFUtilities.setOrCreate(relation, "bufferSize",
bufferSize);
if (_debugging) {
_debug("Adding bufferSize parameter to "
+ relation.getName() + " with value "
+ bufferSize);
}
} else if (bufferSizeObject instanceof String) {
String bufferSizeExpression = (String) bufferSizeObject;
DFUtilities.setOrCreate(relation, "bufferSize", "\""
+ bufferSizeExpression + "\"");
if (_debugging) {
_debug("Adding bufferSize parameter to "
+ relation.getName() + " with expression "
+ bufferSizeExpression);
}
} else if (bufferSizeObject == null) {
} else {
throw new InternalErrorException(
"Invalid value found "
+ "in buffer size map.\nValue is of type "
+ bufferSizeObject.getClass().getName()
+ ".\nIt should be of type Integer or String.\n");
}
}
}
};
// Indicate that the change is non-persistent, so that
// the UI doesn't prompt to save.
request.setPersistent(false);
container.requestChange(request);
}