20 import ca.uqac.lif.cep.Connector;
21 import ca.uqac.lif.cep.GroupProcessor;
22 import ca.uqac.lif.cep.Pullable;
23 import ca.uqac.lif.cep.functions.ApplyFunction;
24 import ca.uqac.lif.cep.tmf.Fork;
25 import ca.uqac.lif.cep.tmf.QueueSource;
26 import ca.uqac.lif.cep.tmf.Trim;
42 public static void main(String[] args)
45 QueueSource source =
new QueueSource().setEvents(1, 2, 3, 4, 5, 6);
48 GroupProcessor group =
new GroupProcessor(1, 2);
51 Fork fork =
new Fork(2);
52 ApplyFunction div =
new ApplyFunction(IntegerDivision.instance);
53 Connector.connect(fork, 0, div, 0);
54 Trim trim =
new Trim(1);
55 Connector.connect(fork, 1, trim, 0);
56 Connector.connect(trim, 0, div, 1);
57 group.addProcessors(fork, trim, div);
58 group.associateInput(0, fork, 0);
59 group.associateOutput(0, div, 0);
60 group.associateOutput(1, div, 1);
65 Connector.connect(source, group);
69 Pullable p0 = group.getPullableOutput(1);
70 Pullable p1 = group.getPullableOutput(1);
71 for (
int i = 0; i < 6; i++)
73 int q = (Integer) p0.pull();
74 int r = (Integer) p1.pull();
75 System.out.println(q +
" remainder " + r);
Create custom Function objects, directly or by combining existing functions.
A function that computes integer division.
Show the basic usage of Function objects.
Encapsulate a chain of processors into a Group, with an output arity of 2.