Re-structure LTTng sub-project as per the Linux Tools guidelines
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.core.tests / src / org / eclipse / linuxtools / lttng / core / tests / state / handlers / after / StateAfterUpdateFactory.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 package org.eclipse.linuxtools.lttng.core.tests.state.handlers.after;
13
14 import java.util.HashMap;
15 import java.util.Map;
16
17 import org.eclipse.linuxtools.lttng.core.state.StateStrings;
18 import org.eclipse.linuxtools.lttng.core.state.evProcessor.ILttngEventProcessor;
19
20 /**
21 * Builds a Map from string event name to a processing handler object, the
22 * processors implement the same interface to facilitate transparent methods
23 * call,
24 *
25 * The map key STring is the entry point of the raw events, using a hash speeds
26 * up the resolution of the appropriate processor
27 *
28 * @author alvaro
29 *
30 */
31 public class StateAfterUpdateFactory {
32 // ========================================================================
33 // Data
34 // =======================================================================
35 private final Map<String, ILttngEventProcessor> eventNametoProcessor = new HashMap<String, ILttngEventProcessor>();
36 private static StateAfterUpdateFactory instance = null;
37 private StateAfterUpdateHandlers instantiateHandler = new StateAfterUpdateHandlers();
38
39 // ========================================================================
40 // Constructors
41 // =======================================================================
42 private StateAfterUpdateFactory() {
43 //create one instance of each individual event handler and add the instance to the map
44 eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_SYSCALL_ENTRY
45 .getInName(), instantiateHandler.getSyscallEntryHandler());
46
47 eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_SYSCALL_EXIT
48 .getInName(), instantiateHandler.getsySyscallExitHandler());
49
50 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_TRAP_ENTRY
51 // .getInName(), instantiateHandler.getTrapEntryHandler());
52 //
53 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_TRAP_EXIT
54 // .getInName(), instantiateHandler.getTrapExitHandler());
55 //
56 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_PAGE_FAULT_ENTRY
57 // .getInName(), instantiateHandler.getTrapEntryHandler());
58 //
59 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_PAGE_FAULT_EXIT
60 // .getInName(), instantiateHandler.getTrapExitHandler());
61 //
62 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_PAGE_FAULT_NOSEM_ENTRY
63 // .getInName(), instantiateHandler.getTrapEntryHandler());
64 //
65 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_PAGE_FAULT_NOSEM_EXIT
66 // .getInName(), instantiateHandler.getTrapExitHandler());
67 //
68 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_IRQ_ENTRY
69 // .getInName(), instantiateHandler.getIrqEntryHandler());
70 //
71 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_IRQ_EXIT
72 // .getInName(), instantiateHandler.getIrqExitHandler());
73 //
74 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_SOFT_IRQ_RAISE
75 // .getInName(), instantiateHandler.getSoftIrqRaiseHandler());
76 //
77 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_SOFT_IRQ_ENTRY
78 // .getInName(), instantiateHandler.getSoftIrqEntryHandler());
79 //
80 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_SOFT_IRQ_EXIT
81 // .getInName(), instantiateHandler.getSoftIrqExitHandler());
82 //
83 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_LIST_INTERRUPT
84 // .getInName(), instantiateHandler.getEnumInterruptHandler());
85 //
86 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_REQUEST_ISSUE
87 // .getInName(), instantiateHandler.getBdevRequestIssueHandler());
88 //
89 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_REQUEST_COMPLETE
90 // .getInName(), instantiateHandler.getBdevRequestCompleteHandler());
91 //
92 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_FUNCTION_ENTRY
93 // .getInName(), instantiateHandler.getFunctionEntryHandler());
94 //
95 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_FUNCTION_EXIT
96 // .getInName(), instantiateHandler.getFunctionExitHandler());
97 //
98 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_SYS_CALL_TABLE
99 // .getInName(), instantiateHandler.getDumpSyscallHandler());
100 //
101 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_KPROBE_TABLE
102 // .getInName(), instantiateHandler.getDumpKprobeHandler());
103 //
104 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_SOFTIRQ_VEC
105 // .getInName(), instantiateHandler.getDumpSoftIrqHandler());
106 //
107 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_SCHED_SCHEDULE
108 // .getInName(), instantiateHandler.getSchedChangeHandler());
109 //
110 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_PROCESS_FORK
111 // .getInName(), instantiateHandler.getProcessForkHandler());
112 //
113 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_KTHREAD_CREATE
114 // .getInName(), instantiateHandler.getProcessKernelThreadHandler());
115 //
116 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_PROCESS_EXIT
117 // .getInName(), instantiateHandler.getProcessExitHandler());
118 //
119 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_PROCESS_FREE
120 // .getInName(), instantiateHandler.getProcessFreeHandler());
121 //
122 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_EXEC
123 // .getInName(), instantiateHandler.getProcessExecHandler());
124 //
125 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_THREAD_BRAND
126 // .getInName(), instantiateHandler.GetThreadBrandHandler());
127 //
128 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_STATEDUMP_END
129 // .getInName(), instantiateHandler.getStateDumpEndHandler());
130 //
131 // eventNametoProcessor.put(StateStrings.Events.LTT_EVENT_PROCESS_STATE
132 // .getInName(), instantiateHandler.getEnumProcessStateHandler());
133
134
135 }
136
137 // ========================================================================
138 // Public methods
139 // =======================================================================
140 /**
141 * The event processors are common to all traces an multiple instances will
142 * use more memory unnecessarily
143 *
144 * @return
145 */
146 public static StateAfterUpdateFactory getInstance() {
147 if (instance == null) {
148 instance = new StateAfterUpdateFactory();
149 }
150 return instance;
151 }
152
153 /**
154 *
155 * @return The Event Handler corresponding to the type of event
156 */
157 public ILttngEventProcessor getEventNametoProcessor(String eventType) {
158 return eventNametoProcessor.get(eventType);
159 }
160 }
This page took 0.034374 seconds and 5 git commands to generate.