Code Examples
A repository of 155 code examples for BeepBeep
ProcessorIdGroup.java
1 /*
2  BeepBeep, an event stream processor
3  Copyright (C) 2008-2018 Sylvain HallĂ©
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published
7  by the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 package basic;
19 
20 import ca.uqac.lif.cep.GroupProcessor;
21 import ca.uqac.lif.cep.tmf.Passthrough;
22 
23 /**
24  * Example showing how the IDs of processors behave when multiple
25  * instances are created.
26  *
27  * @author Sylvain HallĂ©
28  * @difficulty Easy
29  */
30 public class ProcessorIdGroup
31 {
32  public static void main(String[] args)
33  {
34  /// We create a first group and look at the processor IDs
35  MyGroup g1 = new MyGroup();
36  System.out.println("ID of g1: " + g1.getId());
37  System.out.println("ID inside g1: " + g1.getInstance().getId());
38  ///
39  //* We create a second group and look at the IDs. Note that they
40  // are all different from the first instance.
41  MyGroup g2 = new MyGroup();
42  System.out.println("ID of g2: " + g2.getId());
43  System.out.println("ID inside g2: " + g2.getInstance().getId());
44  //*
45  }
46 
47  //!
48  public static class MyGroup extends GroupProcessor
49  {
50  /* Member field used to keep a reference to the instance of
51  * Passthrough created for this group. */
52  protected Passthrough pt;
53 
54  /* This processor simply encapsulates a single Passthrough
55  * processor inside. */
56  public MyGroup()
57  {
58  super(1, 1);
59  pt = new Passthrough();
60  addProcessor(pt);
61  associateInput(0, pt, 0);
62  associateOutput(0, pt, 0);
63  }
64 
65  /* This method returns the instance of Passthrough that has
66  * been created for this instance of MyGroup. */
67  public Passthrough getInstance()
68  {
69  return pt;
70  }
71  }
72  //!
73 }
static void main(String[] args)
Example showing how the IDs of processors behave when multiple instances are created.