(no commit message)
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng / src / org / eclipse / linuxtools / lttng / state / evProcessor / EventProcessorProxy.java
1 /*******************************************************************************
2 * Copyright (c) 2009 Ericsson
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.linuxtools.lttng.state.evProcessor;
14
15 import java.util.HashSet;
16 import java.util.Set;
17
18 import org.eclipse.linuxtools.lttng.TraceDebug;
19 import org.eclipse.linuxtools.lttng.state.evProcessor.state.StateEventToHandlerFactory;
20
21 /**
22 * @author alvaro
23 *
24 */
25 public class EventProcessorProxy {
26 // ========================================================================
27 // Data
28 // =======================================================================
29 private static EventProcessorProxy instance = null;
30 private final Set<AbsEventToHandlerResolver> processingFactories = new HashSet<AbsEventToHandlerResolver>();
31
32
33 // ========================================================================
34 // Constructors
35 // =======================================================================
36 public EventProcessorProxy() {
37 // Manual creation of State update factory
38 addEventProcessorFactory(StateEventToHandlerFactory.getInstance());
39 }
40
41 // ========================================================================
42 // Methods
43 // =======================================================================
44 /**
45 * @return the processingFactories
46 */
47 public Set<AbsEventToHandlerResolver> getProcessingFactories() {
48 return processingFactories;
49 }
50
51 /**
52 * Returns this singleton
53 *
54 * @return
55 */
56 public static EventProcessorProxy getInstance() {
57 if (instance == null) {
58 instance = new EventProcessorProxy();
59 }
60
61 return instance;
62 }
63
64 /**
65 * Register a factory of event handler methods, each factory provides a map
66 * to Before and After state update handlers
67 *
68 * @param handlersFactory
69 */
70 public void addEventProcessorFactory(
71 AbsEventToHandlerResolver handlersFactory) {
72 if (handlersFactory != null) {
73 //only add the listener if not already included
74 if (!processingFactories.contains(handlersFactory)) {
75 processingFactories.add(handlersFactory);
76 }
77 } else {
78 TraceDebug
79 .debug("An attempt to register a null factory has been detected");
80 }
81 }
82
83 /**
84 * Remove a factory previously added with addEventProcessorFactory
85 *
86 * @param handlersFactory
87 */
88 public void removeEventProcessorFactory(
89 IEventToHandlerResolver handlersFactory) {
90 if (handlersFactory != null) {
91 processingFactories.remove(handlersFactory);
92 }
93 }
94
95 }
This page took 0.034031 seconds and 5 git commands to generate.