sysperfana/perfinvestigator/com.nokia.carbide.cpp.pi/src/com/nokia/carbide/cpp/internal/pi/manager/TraceTypePreviewer.java
changeset 5 844b047e260d
parent 4 615035072f7e
child 6 f65f740e69f9
equal deleted inserted replaced
4:615035072f7e 5:844b047e260d
     1 /*
       
     2  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of the License "Eclipse Public License v1.0"
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Nokia Corporation - initial contribution.
       
    11  *
       
    12  * Contributors:
       
    13  *
       
    14  * Description: 
       
    15  *
       
    16  */
       
    17 
       
    18 /**
       
    19  * 
       
    20  */
       
    21 package com.nokia.carbide.cpp.internal.pi.manager;
       
    22 
       
    23 import java.io.File;
       
    24 import java.io.IOException;
       
    25 import java.util.Enumeration;
       
    26 import java.util.HashMap;
       
    27 import java.util.Map;
       
    28 import java.util.Set;
       
    29 
       
    30 import com.nokia.carbide.cpp.internal.pi.analyser.StreamFileParser;
       
    31 import com.nokia.carbide.cpp.internal.pi.plugin.model.AbstractPiPlugin;
       
    32 import com.nokia.carbide.cpp.internal.pi.plugin.model.ITrace;
       
    33 
       
    34 
       
    35 /**
       
    36  * 
       
    37  * Load a .dat file and preview all the traces available
       
    38  *
       
    39  */
       
    40 public class TraceTypePreviewer {
       
    41 	private HashMap<Integer, String> availableTraces = new HashMap<Integer, String>();
       
    42 	
       
    43 	public TraceTypePreviewer(File file) {
       
    44 		try {
       
    45 			StreamFileParser inputFile;
       
    46 			inputFile = new StreamFileParser(file);
       
    47 			Set<Integer> allTraceSet = inputFile.allTraceType();
       
    48 			// dispose it
       
    49 			inputFile = null;
       
    50 			
       
    51 			Enumeration<AbstractPiPlugin> e = PluginRegistry.getInstance().getRegistryEntries();
       
    52 			while(e.hasMoreElements()) {
       
    53 				AbstractPiPlugin plugin = e.nextElement();
       
    54 				if (plugin instanceof ITrace) {
       
    55 					ITrace tracePlugin = (ITrace) plugin;
       
    56 					if (allTraceSet.contains(tracePlugin.getTraceId())) {
       
    57 						availableTraces.put(tracePlugin.getTraceId(), tracePlugin.getTraceName());
       
    58 					}
       
    59 				}
       
    60 			}
       
    61 		} catch (IOException e) {
       
    62 			e.printStackTrace();
       
    63 		}	
       
    64 	}
       
    65 	
       
    66 	public Map<Integer, String> getAllAvailableTraces() {
       
    67 		return availableTraces;
       
    68 	}
       
    69 
       
    70 }