/
FunctionUnitBase.xtend
48 lines (39 loc) · 1.64 KB
/
FunctionUnitBase.xtend
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*******************************************************************************
* Copyright (c) 2014 Denis Kuniss (http://www.grammarcraft.de).
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
package de.grammarcraft.xtend.flow
class FunctionUnitBase {
val String name
new(String name) {
this.name = name
}
override toString() { this.name }
public val integrationError = new OutputPort<Exception>('integrationError',
[
ex | println('FATAL ERROR: ' + ex.message)
]
)
protected def forwardIntegrationError(Exception ex) {
integrationError.forward(ex)
}
/**
* Must be overridden by the derived function unit iff it has exactly one input port, not more.
* <br>
* By default it forwards an integration error and returns an doing-nothing method object.
* <br>
* This method is used for connecting this function unit (if it has only one input port) as
* flow target with another function unit without specifying the one and only input port.
*/
def <T> (T)=>void getTheOneAndOnlyInputPort() {
forwardIntegrationError(
new UnsupportedOperationException(
"The function unit has more than one input port or, " +
"getTheOneAndOnlyInputPort() is not implemented.")
)
return [];
}
}