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