temporary re-factoring project
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui / src / org / eclipse / linuxtools / lttng / ui / views / statistics / evProcessor / StatsTimeCountHandlerFactory.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 * Yann N. Dauphin (dhaemon@gmail.com) - Implementation for stats
11 * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation
12 *******************************************************************************/
13 package org.eclipse.linuxtools.lttng.ui.views.statistics.evProcessor;
14
15 import java.util.HashMap;
16 import java.util.Map;
17
18 import org.eclipse.linuxtools.lttng.state.StateStrings;
19 import org.eclipse.linuxtools.lttng.state.evProcessor.AbsEventProcessorFactory;
20 import org.eclipse.linuxtools.lttng.state.evProcessor.IEventProcessing;
21
22 /**
23 * Provide the handlers that will count the CPU Time, Cumulative CPU Time and
24 * Elapsed Time and update the appropriate tree.
25 *
26 * Builds a Map from string event name to a processing handler object, the
27 * processors implement the same interface to facilitate transparent methods
28 * call,
29 *
30 * The map key STring is the entry point of the raw events, using a hash speeds
31 * up the resolution of the appropriate processor
32 *
33 * @author alvaro
34 *
35 */
36 public class StatsTimeCountHandlerFactory extends AbsEventProcessorFactory{
37 // ========================================================================
38 // Data
39 // =======================================================================
40 private final Map<String, IEventProcessing> eventNametoBeforeProcessor = new HashMap<String, IEventProcessing>();
41 private final Map<String, IEventProcessing> eventNametoAfterProcessor = new HashMap<String, IEventProcessing>();
42 private static StatsTimeCountHandlerFactory instance = null;
43 private StatsTimeCountHandlers instantiateHandler = new StatsTimeCountHandlers();
44
45 // ========================================================================
46 // Constructors
47 // =======================================================================
48 private StatsTimeCountHandlerFactory() {
49 //create one instance of each individual event handler and add the instance to the map
50 eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_SYSCALL_ENTRY
51 .getInName(), instantiateHandler.getSyscallEntryBeforeHandler());
52
53 eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_SYSCALL_EXIT
54 .getInName(), instantiateHandler.getsySyscallExitBeforeHandler());
55
56 eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_TRAP_ENTRY
57 .getInName(), instantiateHandler.getTrapEntryBeforeHandler());
58
59 eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_TRAP_EXIT
60 .getInName(), instantiateHandler.getTrapExitBeforeHandler());
61
62 eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_PAGE_FAULT_ENTRY
63 .getInName(), instantiateHandler.getTrapEntryBeforeHandler());
64
65 eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_PAGE_FAULT_EXIT
66 .getInName(), instantiateHandler.getTrapExitBeforeHandler());
67
68 eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_PAGE_FAULT_NOSEM_ENTRY
69 .getInName(), instantiateHandler.getTrapEntryBeforeHandler());
70
71 eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_PAGE_FAULT_NOSEM_EXIT
72 .getInName(), instantiateHandler.getTrapExitBeforeHandler());
73
74 eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_IRQ_ENTRY
75 .getInName(), instantiateHandler.getIrqEntryBeforeHandler());
76
77 eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_IRQ_EXIT
78 .getInName(), instantiateHandler.getIrqExitBeforeHandler());
79
80 eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_SOFT_IRQ_ENTRY
81 .getInName(), instantiateHandler.getSoftIrqEntryBeforeHandler());
82
83 eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_SOFT_IRQ_EXIT
84 .getInName(), instantiateHandler.getSoftIrqExitBeforeHandler());
85
86 eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_FUNCTION_ENTRY
87 .getInName(), instantiateHandler.getFunctionEntryBeforeHandler());
88
89 eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_FUNCTION_EXIT
90 .getInName(), instantiateHandler.getFunctionExitBeforeHandler());
91
92 eventNametoBeforeProcessor.put(StateStrings.Events.LTT_EVENT_SCHED_SCHEDULE
93 .getInName(), instantiateHandler.getSchedChangeBeforeHandler());
94
95 eventNametoAfterProcessor.put(StateStrings.Events.LTT_EVENT_SCHED_SCHEDULE
96 .getInName(), instantiateHandler.getSchedChangeAfterHandler());
97
98 }
99
100 // ========================================================================
101 // Public methods
102 // =======================================================================
103 /**
104 * The event processors are common to all traces an multiple instances will
105 * use more memory unnecessarily
106 *
107 * @return
108 */
109 public static AbsEventProcessorFactory getInstance() {
110 if (instance == null) {
111 instance = new StatsTimeCountHandlerFactory();
112 }
113 return instance;
114 }
115
116
117 @Override
118 public IEventProcessing getAfterProcessor(String eventType) {
119 return eventNametoAfterProcessor.get(eventType);
120 }
121
122 @Override
123 public IEventProcessing getBeforeProcessor(String eventType) {
124 return eventNametoBeforeProcessor.get(eventType);
125 }
126
127 @Override
128 public IEventProcessing getfinishProcessor() {
129 // No finishing processor used
130 return null;
131 }
132 }
This page took 0.032796 seconds and 5 git commands to generate.