1 /*******************************************************************************
2 * Copyright (c) 2009 Ericsson
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
10 * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation
11 *******************************************************************************/
12 package org
.eclipse
.linuxtools
.lttng
.ui
.views
.resources
.evProcessor
;
14 import java
.util
.HashMap
;
17 import org
.eclipse
.linuxtools
.lttng
.state
.StateStrings
;
18 import org
.eclipse
.linuxtools
.lttng
.state
.evProcessor
.AbsEventProcessorFactory
;
19 import org
.eclipse
.linuxtools
.lttng
.state
.evProcessor
.IEventProcessing
;
22 * Builds a Map from string event name to a processing handler object, the
23 * processors implement the same interface to facilitate transparent methods
26 * The map key String is the entry point of the raw events. Using a hash speeds
27 * up the resolution of the appropriate processor
32 public class ResourcesTRangeUpdateFactory
extends AbsEventProcessorFactory
{
33 // ========================================================================
35 // =======================================================================
36 private final Map
<String
, IEventProcessing
> eventNametoBeforeProcessor
= new HashMap
<String
, IEventProcessing
>();
37 private final Map
<String
, IEventProcessing
> eventNametoAfterProcessor
= new HashMap
<String
, IEventProcessing
>();
38 private ResourcesTRangeFinishUpdateHandler finishProcessor
= null;
39 private static ResourcesTRangeUpdateFactory instance
= null;
40 private ResourcesTRangeBeforeUpdateHandlers instantiateBeforeHandler
= new ResourcesTRangeBeforeUpdateHandlers();
41 private ResourcesTRangeAfterUpdateHandlers instantiateAfterHandler
= new ResourcesTRangeAfterUpdateHandlers();
44 private ResourcesTRangeUpdateFactory() {
45 // Create one instance of each individual event handler and add the instance to the map
47 // *** BEFORE HOOKS ***
48 eventNametoBeforeProcessor
.put(
49 StateStrings
.Events
.LTT_EVENT_SCHED_SCHEDULE
.getInName(),
50 instantiateBeforeHandler
.getBeforeSchedChangeHandler());
52 eventNametoBeforeProcessor
.put(StateStrings
.Events
.LTT_EVENT_TRAP_ENTRY
53 .getInName(), instantiateBeforeHandler
54 .getBeforeExecutionModeTrap());
55 eventNametoBeforeProcessor
.put(StateStrings
.Events
.LTT_EVENT_TRAP_EXIT
56 .getInName(), instantiateBeforeHandler
57 .getBeforeExecutionModeTrap());
58 eventNametoBeforeProcessor
.put(
59 StateStrings
.Events
.LTT_EVENT_PAGE_FAULT_ENTRY
.getInName(),
60 instantiateBeforeHandler
.getBeforeExecutionModeTrap());
61 eventNametoBeforeProcessor
.put(
62 StateStrings
.Events
.LTT_EVENT_PAGE_FAULT_EXIT
.getInName(),
63 instantiateBeforeHandler
.getBeforeExecutionModeTrap());
64 eventNametoBeforeProcessor
.put(
65 StateStrings
.Events
.LTT_EVENT_PAGE_FAULT_NOSEM_ENTRY
66 .getInName(), instantiateBeforeHandler
67 .getBeforeExecutionModeTrap());
68 eventNametoBeforeProcessor
69 .put(StateStrings
.Events
.LTT_EVENT_PAGE_FAULT_NOSEM_EXIT
70 .getInName(), instantiateBeforeHandler
71 .getBeforeExecutionModeTrap());
73 eventNametoBeforeProcessor
.put(StateStrings
.Events
.LTT_EVENT_IRQ_ENTRY
74 .getInName(), instantiateBeforeHandler
75 .getBeforeExecutionModeIrq());
76 eventNametoBeforeProcessor
.put(StateStrings
.Events
.LTT_EVENT_IRQ_EXIT
77 .getInName(), instantiateBeforeHandler
78 .getBeforeExecutionModeIrq());
80 eventNametoBeforeProcessor
.put(
81 StateStrings
.Events
.LTT_EVENT_SOFT_IRQ_RAISE
.getInName(),
82 instantiateBeforeHandler
.getBeforeExecutionModeSoftIrq());
83 eventNametoBeforeProcessor
.put(
84 StateStrings
.Events
.LTT_EVENT_SOFT_IRQ_ENTRY
.getInName(),
85 instantiateBeforeHandler
.getBeforeExecutionModeSoftIrq());
86 eventNametoBeforeProcessor
.put(
87 StateStrings
.Events
.LTT_EVENT_SOFT_IRQ_EXIT
.getInName(),
88 instantiateBeforeHandler
.getBeforeExecutionModeSoftIrq());
90 eventNametoBeforeProcessor
.put(
91 StateStrings
.Events
.LTT_EVENT_REQUEST_ISSUE
.getInName(),
92 instantiateBeforeHandler
.getBeforeBdevEvent());
93 eventNametoBeforeProcessor
.put(
94 StateStrings
.Events
.LTT_EVENT_REQUEST_COMPLETE
.getInName(),
95 instantiateBeforeHandler
.getBeforeBdevEvent());
99 // *** AFTER HOOKS ***
100 eventNametoBeforeProcessor
.put(
101 StateStrings
.Events
.LTT_EVENT_SCHED_SCHEDULE
.getInName(),
102 instantiateAfterHandler
.getAfterSchedChangeHandler());
104 finishProcessor
= new ResourcesTRangeFinishUpdateHandler();
111 public static AbsEventProcessorFactory
getInstance() {
112 if (instance
== null) {
113 instance
= new ResourcesTRangeUpdateFactory();
119 public IEventProcessing
getAfterProcessor(String eventType
) {
120 return eventNametoAfterProcessor
.get(eventType
);
124 public IEventProcessing
getBeforeProcessor(String eventType
) {
125 return eventNametoBeforeProcessor
.get(eventType
);
129 public IEventProcessing
getfinishProcessor() {
130 return finishProcessor
;