lttng: Javadoc udpate for the lttng2.kernel.ui package
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / statistics / model / TmfStatisticsTreeRootFactory.java
CommitLineData
79e08fd0
BH
1/*******************************************************************************
2 * Copyright (c) 2011 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 * Mathieu Denis (mathieu.denis@polymtl.ca) - Initial API
11 *******************************************************************************/
12
13package org.eclipse.linuxtools.tmf.ui.views.statistics.model;
14
15import java.util.HashMap;
16import java.util.Map;
17
b544077e
BH
18/**
19 * Factory class to create and store TMF statistic trees.
20 *
21 * Based on a given tree node ID a TMF statistic tree is stored internally.
22 * A root node is created for each tree. Using the tree node ID the statistics
23 * tree can be retrieved.
24 *
25 * @version 1.0
26 * @author Mathieu Denis
27 *
28 */
79e08fd0
BH
29public class TmfStatisticsTreeRootFactory {
30
31 // -----------------------------------------------------------------------
32 // Data
33 // -----------------------------------------------------------------------
34 /**
35 * Contains the experiment name as the key and the traces data
36 */
37 private static final Map<String, AbsTmfStatisticsTree> fTreeInstances = new HashMap<String, AbsTmfStatisticsTree>();
38
39 // -----------------------------------------------------------------------
40 // Methods
41 // -----------------------------------------------------------------------
42
43 /**
44 * Provide a statisticsTree instance per trace
45 *
0d9a6d76 46 * @return the corresponding trace statistics tree
79e08fd0
BH
47 */
48 public static TmfStatisticsTreeNode getStatTreeRoot(String traceUniqueId) {
49
50 AbsTmfStatisticsTree tree = getStatTree(traceUniqueId);
51 if (tree == null) {
52 return null;
53 }
54 return tree.getOrCreate(AbsTmfStatisticsTree.ROOT);
55 }
56
57 /**
58 *
59 * @param traceUniqueId
0d9a6d76 60 * @return the corresponding trace statistics tree
79e08fd0
BH
61 */
62 public static AbsTmfStatisticsTree getStatTree(String traceUniqueId) {
63 if (traceUniqueId == null)
64 return null;
65
66 AbsTmfStatisticsTree tree = fTreeInstances.get(traceUniqueId);
67 return tree;
68 }
69
70 /**
71 * Add the new trace statistics data in the tree. Can be used later on if the same traces is selected back.
72 *
0d9a6d76 73 * @param traceUniqueId
79e08fd0
BH
74 * the name of the trace which will be used as a key to store the data. Must be different for each traces, otherwise the traces might
75 * be overwritten which would trigger a reload of the same trace.
0d9a6d76 76 * @param statsData
79e08fd0
BH
77 * the information about the trace
78 */
79 public static void addStatsTreeRoot(String traceUniqueId, AbsTmfStatisticsTree statsData) {
80 if (traceUniqueId == null || statsData == null)
81 return;
82
83 fTreeInstances.put(traceUniqueId, statsData);
84 // if called for the first time, create the root node
85 statsData.getOrCreate(AbsTmfStatisticsTree.ROOT);
86 }
87
88 /**
89 *
90 * @param traceUniqueId
0d9a6d76 91 * @return true if the trace id is known
79e08fd0
BH
92 */
93 public static boolean containsTreeRoot(String traceUniqueId) {
94 return fTreeInstances.containsKey(traceUniqueId);
95 }
96
97 /**
98 * Remove previously registered statistics tree.
99 *
100 * @param traceUniqueId
101 */
102 public static void removeStatTreeRoot(String traceUniqueId) {
103 if (traceUniqueId != null && fTreeInstances.containsKey(traceUniqueId)) {
104 fTreeInstances.remove(traceUniqueId);
105 }
106 }
107
108 /**
109 * Remove all tree and root instances
110 */
111 public static void removeAll() {
112 fTreeInstances.clear();
113 }
114}
This page took 0.033761 seconds and 5 git commands to generate.