Re-structure LTTng sub-project as per the Linux Tools guidelines
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.core / src / org / eclipse / linuxtools / lttng / core / control / LttngCoreProviderFactory.java
1 /*******************************************************************************
2 * Copyright (c) 2009,2010 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.control;
13
14 import java.util.HashMap;
15 import java.util.Map;
16
17 import org.eclipse.linuxtools.lttng.core.event.LttngSyntheticEvent;
18 import org.eclipse.linuxtools.lttng.core.model.LTTngTreeNode;
19
20 /**
21 * @author alvaro
22 *
23 */
24 public class LttngCoreProviderFactory {
25
26 // List of provider IDs
27 public static final int STATISTICS_LTTNG_SYTH_EVENT_PROVIDER = 0;
28 public static final int CONTROL_FLOW_LTTNG_SYTH_EVENT_PROVIDER = 1;
29 public static final int RESOURCE_LTTNG_SYTH_EVENT_PROVIDER = 2;
30
31 private static final Map<Integer, LttngSyntheticEventProvider> fSyntheticEventProviders = new HashMap<Integer, LttngSyntheticEventProvider>();
32
33 /**
34 * Pre-creates all known LTTng providers.
35 */
36 public static void initialize() {
37 getEventProvider(STATISTICS_LTTNG_SYTH_EVENT_PROVIDER);
38 getEventProvider(CONTROL_FLOW_LTTNG_SYTH_EVENT_PROVIDER);
39 getEventProvider(RESOURCE_LTTNG_SYTH_EVENT_PROVIDER);
40 }
41
42 /**
43 * Gets a SyntheticEventProvider for the given ID. It creates a new provider
44 * if necessary
45 *
46 * @param providerId
47 * @return
48 */
49 public static LttngSyntheticEventProvider getEventProvider(int providerId) {
50 if (!fSyntheticEventProviders.containsKey(Integer.valueOf(providerId))) {
51 LttngSyntheticEventProvider synEventProvider = new LttngSyntheticEventProvider(LttngSyntheticEvent.class);
52 fSyntheticEventProviders.put(Integer.valueOf(providerId), synEventProvider);
53 }
54 return fSyntheticEventProviders.get(Integer.valueOf(providerId));
55 }
56
57 /**
58 * Resets all LTTngSytheticEventProviders associated with the given
59 * Experiment
60 *
61 * @param experimentNode
62 */
63 public static void reset(LTTngTreeNode experimentNode) {
64 for (LttngSyntheticEventProvider provider : fSyntheticEventProviders.values()) {
65 provider.reset(experimentNode);
66 }
67 }
68 }
This page took 0.034506 seconds and 5 git commands to generate.