tmf: Only keep the full constructor in TmfEventField
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.kernel.core / src / org / eclipse / linuxtools / lttng2 / kernel / core / trace / CtfKernelTrace.java
CommitLineData
11d6f468 1/*******************************************************************************
94cce698 2 * Copyright (c) 2012, 2013 Ericsson
11d6f468
AM
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 * Alexandre Montplaisir - Initial API and implementation
11 ******************************************************************************/
12
13package org.eclipse.linuxtools.lttng2.kernel.core.trace;
14
15import java.io.File;
11d6f468
AM
16
17import org.eclipse.core.resources.IProject;
5e4bf87d 18import org.eclipse.core.resources.IResource;
e12ecd30 19import org.eclipse.core.runtime.CoreException;
7c60c8b4
AM
20import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
21import org.eclipse.linuxtools.ctf.core.trace.CTFTrace;
dc0f7bfe 22import org.eclipse.linuxtools.internal.lttng2.kernel.core.stateprovider.CtfKernelStateInput;
e12ecd30 23import org.eclipse.linuxtools.tmf.core.TmfCommonConstants;
11d6f468
AM
24import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace;
25import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
18ab1d18 26import org.eclipse.linuxtools.tmf.core.statesystem.IStateChangeInput;
a51b2b9f 27import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystem;
6e71ce46 28import org.eclipse.linuxtools.tmf.core.statesystem.StateSystemManager;
11d6f468
AM
29
30/**
31 * This is the specification of CtfTmfTrace for use with LTTng 2.x kernel
32 * traces. It uses the CtfKernelStateInput to generate the state history.
d85d2a6d 33 *
2cb26548
AM
34 * @version 1.0
35 * @author Alexandre Montplaisir
11d6f468
AM
36 */
37public class CtfKernelTrace extends CtfTmfTrace {
38
e12ecd30
BH
39 /**
40 * The file name of the History Tree
41 */
42 public final static String HISTORY_TREE_FILE_NAME = "stateHistory.ht"; //$NON-NLS-1$
6752f420 43
a76f1067
AM
44 /**
45 * ID of the state system we will build
46 * @since 2.0
47 * */
48 public static final String STATE_ID = "org.eclipse.linuxtools.lttng2.kernel"; //$NON-NLS-1$
49
d85d2a6d
AM
50 /**
51 * Default constructor
52 */
11d6f468
AM
53 public CtfKernelTrace() {
54 super();
55 }
56
57 @Override
58 public boolean validate(final IProject project, final String path) {
7c60c8b4
AM
59 CTFTrace temp;
60 /*
61 * Make sure the trace is openable as a CTF trace. We do this here
62 * instead of calling super.validate() to keep the reference to "temp".
63 */
64 try {
65 temp = new CTFTrace(path);
66 } catch (CTFReaderException e) {
11d6f468
AM
67 return false;
68 }
7c60c8b4
AM
69
70 /* Make sure the domain is "kernel" in the trace's env vars */
71 String dom = temp.getEnvironment().get("domain"); //$NON-NLS-1$
81fe3479 72 temp.dispose();
7c60c8b4
AM
73 if (dom != null && dom.equals("\"kernel\"")) { //$NON-NLS-1$
74 return true;
75 }
76 return false;
11d6f468
AM
77 }
78
79 @Override
80 protected void buildStateSystem() throws TmfTraceException {
a51b2b9f
AM
81 super.buildStateSystem();
82
11d6f468 83 /* Set up the path to the history tree file we'll use */
6e71ce46 84 IResource resource = this.getResource();
d85d2a6d 85 String supplDirectory = null;
e12ecd30
BH
86
87 try {
88 // get the directory where the history file will be stored.
89 supplDirectory = resource.getPersistentProperty(TmfCommonConstants.TRACE_SUPPLEMENTARY_FOLDER);
90 } catch (CoreException e) {
9fa32496 91 throw new TmfTraceException(e.toString(), e);
e12ecd30
BH
92 }
93
94 final File htFile = new File(supplDirectory + File.separator + HISTORY_TREE_FILE_NAME);
6e71ce46 95 final IStateChangeInput htInput = new CtfKernelStateInput(this);
11d6f468 96
e45de797 97 ITmfStateSystem ss = StateSystemManager.loadStateHistory(htFile, htInput, false);
a51b2b9f 98 fStateSystems.put(STATE_ID, ss);
faa38350
PT
99 }
100
11d6f468 101}
This page took 0.035552 seconds and 5 git commands to generate.