Code Examples
A repository of 155 code examples for BeepBeep
basic.GroupSimple Class Reference

Encapsulate a chain of processors into a Group. More...

Static Public Member Functions

static void main (String[] args)
 

Detailed Description

Encapsulate a chain of processors into a Group.

The chain of processors in this example can be represented graphically as:

Processor graph
See also
SumTwo
Author
Sylvain Hallé Easy GroupProcessor#associateInput(int, ca.uqac.lif.cep.Processor, int)

Definition at line 24 of file GroupSimple.java.

Member Function Documentation

◆ main()

static void basic.GroupSimple.main ( String []  args)
static

Create a source of arbitrary numbers

Definition at line 26 of file GroupSimple.java.

27  {
28  /// Create a source of arbitrary numbers
29  QueueSource source = new QueueSource().setEvents(1, 2, 3, 4, 5, 6);
30 
31  // Fork the stream in two and connect it to the source
32  GroupProcessor group = new GroupProcessor(1, 1);
33  {
34  Fork fork = new Fork(2);
35  ApplyFunction add = new ApplyFunction(Numbers.addition);
36  Connector.connect(fork, 0, add, 0);
37  Trim trim = new Trim(1);
38  Connector.connect(fork, 1, trim, 0);
39  Connector.connect(trim, 0, add, 1);
40  group.addProcessors(fork, trim, add);
41  group.associateInput(0, fork, 0);
42  group.associateOutput(0, add, 0);
43  }
44 
45  // Connect the source to the group
46  Connector.connect(source, group);
47 
48  /* Let us now print what we receive by pulling on the output of
49  * group. */
50  Pullable p = group.getPullableOutput();
51  for (int i = 0; i < 6; i++)
52  {
53  float x = (Float) p.pull();
54  System.out.println("The event is: " + x);
55  }
56  ///
57  }

The documentation for this class was generated from the following file: