[Bug309042] Some improvements on TmfExperiment and its context. Also fixed a number...
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf / src / org / eclipse / linuxtools / tmf / experiment / TmfExperimentContext.java
CommitLineData
8c8bf09f
ASL
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 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
12
13package org.eclipse.linuxtools.tmf.experiment;
14
15import org.eclipse.linuxtools.tmf.event.TmfEvent;
9f584e4c 16import org.eclipse.linuxtools.tmf.trace.ITmfLocation;
8c8bf09f 17import org.eclipse.linuxtools.tmf.trace.ITmfTrace;
9f584e4c 18import org.eclipse.linuxtools.tmf.trace.TmfContext;
8c8bf09f
ASL
19
20/**
21 * <b><u>TmfExperimentContext</u></b>
22 * <p>
e31e01e8 23 * Implement me. Please.
8c8bf09f 24 */
9f584e4c
FC
25public class TmfExperimentContext extends TmfContext {
26
27 private ITmfTrace[] fTraces = new ITmfTrace[0];
28 private TmfContext[] fContexts;
29 private TmfEvent[] fEvents;
7f407ead 30 private int lastIndex;
8c8bf09f 31
9f584e4c
FC
32 // ------------------------------------------------------------------------
33 // Constructors
34 // ------------------------------------------------------------------------
8c8bf09f 35
9f584e4c
FC
36 public TmfExperimentContext(ITmfTrace[] traces, TmfContext[] contexts) {
37 super();
38 fTraces = traces;
39 fContexts = contexts;
8c8bf09f
ASL
40 fEvents = new TmfEvent[fTraces.length];
41
452ad365 42 ITmfLocation<?>[] locations = new ITmfLocation[fTraces.length];
9f584e4c
FC
43 long rank = 0;
44 for (int i = 0; i < fTraces.length; i++) {
45 if (contexts[i] != null) {
46 locations[i] = contexts[i].getLocation();
47 rank += contexts[i].getRank();
48 }
8c8bf09f 49 }
9f584e4c
FC
50
51 setLocation(new TmfExperimentLocation(locations));
52 setRank(rank);
7f407ead 53 lastIndex = -1;
8c8bf09f
ASL
54 }
55
9f584e4c
FC
56 public TmfExperimentContext(ITmfTrace[] traces) {
57 this(traces, new TmfContext[traces.length]);
8c8bf09f
ASL
58 }
59
9f584e4c
FC
60 public TmfExperimentContext(TmfExperimentContext other) {
61 this(other.fTraces, other.cloneContexts());
62 fEvents = other.fEvents;
54d55ced 63 setLocation(other.getLocation().clone());
9f584e4c 64 setRank(other.getRank());
54d55ced 65 setLastTrace(other.lastIndex);
8c8bf09f
ASL
66 }
67
9f584e4c
FC
68 private TmfContext[] cloneContexts() {
69 TmfContext[] contexts = new TmfContext[fContexts.length];
8c8bf09f
ASL
70 for (int i = 0; i < fContexts.length; i++)
71 contexts[i] = fContexts[i].clone();
72 return contexts;
73 }
74
9f584e4c
FC
75 // ------------------------------------------------------------------------
76 // Accessors
77 // ------------------------------------------------------------------------
78
79 public ITmfTrace[] getTraces() {
80 return fTraces;
81 }
82
83 public TmfContext[] getContexts() {
84 return fContexts;
85 }
86
8c8bf09f
ASL
87 public TmfEvent[] getEvents() {
88 return fEvents;
89 }
90
7f407ead
FC
91 public int getLastTrace() {
92 return lastIndex;
93 }
94
95 public void setLastTrace(int newIndex) {
96 lastIndex = newIndex;
97 }
98
8c8bf09f 99}
This page took 0.029405 seconds and 5 git commands to generate.