1 /*******************************************************************************
2 * Copyright (c) 2011 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 * Mathieu Denis (mathieu.denis@polymtl.ca) - Initial API
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.ui
.views
.statistics
.model
;
15 import java
.util
.HashMap
;
18 public class TmfStatisticsTreeRootFactory
{
20 // -----------------------------------------------------------------------
22 // -----------------------------------------------------------------------
24 * Contains the experiment name as the key and the traces data
26 private static final Map
<String
, AbsTmfStatisticsTree
> fTreeInstances
= new HashMap
<String
, AbsTmfStatisticsTree
>();
28 // -----------------------------------------------------------------------
30 // -----------------------------------------------------------------------
33 * Provide a statisticsTree instance per trace
37 public static TmfStatisticsTreeNode
getStatTreeRoot(String traceUniqueId
) {
39 AbsTmfStatisticsTree tree
= getStatTree(traceUniqueId
);
43 return tree
.getOrCreate(AbsTmfStatisticsTree
.ROOT
);
48 * @param traceUniqueId
51 public static AbsTmfStatisticsTree
getStatTree(String traceUniqueId
) {
52 if (traceUniqueId
== null)
55 AbsTmfStatisticsTree tree
= fTreeInstances
.get(traceUniqueId
);
60 * Add the new trace statistics data in the tree. Can be used later on if the same traces is selected back.
62 * @param experimentName
63 * 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
64 * be overwritten which would trigger a reload of the same trace.
66 * the information about the trace
68 public static void addStatsTreeRoot(String traceUniqueId
, AbsTmfStatisticsTree statsData
) {
69 if (traceUniqueId
== null || statsData
== null)
72 fTreeInstances
.put(traceUniqueId
, statsData
);
73 // if called for the first time, create the root node
74 statsData
.getOrCreate(AbsTmfStatisticsTree
.ROOT
);
79 * @param traceUniqueId
82 public static boolean containsTreeRoot(String traceUniqueId
) {
83 return fTreeInstances
.containsKey(traceUniqueId
);
87 * Remove previously registered statistics tree.
89 * @param traceUniqueId
91 public static void removeStatTreeRoot(String traceUniqueId
) {
92 if (traceUniqueId
!= null && fTreeInstances
.containsKey(traceUniqueId
)) {
93 fTreeInstances
.remove(traceUniqueId
);
98 * Remove all tree and root instances
100 public static void removeAll() {
101 fTreeInstances
.clear();