Added missing test files + a few fixes
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf / src / org / eclipse / linuxtools / tmf / experiment / TmfExperimentContext.java
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
13 package org.eclipse.linuxtools.tmf.experiment;
14
15 import org.eclipse.linuxtools.tmf.event.TmfEvent;
16 import org.eclipse.linuxtools.tmf.trace.ITmfLocation;
17 import org.eclipse.linuxtools.tmf.trace.ITmfTrace;
18 import org.eclipse.linuxtools.tmf.trace.TmfContext;
19
20 /**
21 * <b><u>TmfExperimentContext</u></b>
22 * <p>
23 * Implement me. Please.
24 */
25 public class TmfExperimentContext extends TmfContext {
26
27 private ITmfTrace[] fTraces = new ITmfTrace[0];
28 private TmfContext[] fContexts;
29 private TmfEvent[] fEvents;
30 private int lastIndex;
31
32 // ------------------------------------------------------------------------
33 // Constructors
34 // ------------------------------------------------------------------------
35
36 public TmfExperimentContext(ITmfTrace[] traces, TmfContext[] contexts) {
37 super();
38 fTraces = traces;
39 fContexts = contexts;
40 fEvents = new TmfEvent[fTraces.length];
41
42 ITmfLocation<?>[] locations = new ITmfLocation[fTraces.length];
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 }
49 }
50
51 setLocation(new TmfExperimentLocation(locations));
52 setRank(rank);
53 lastIndex = -1;
54 }
55
56 public TmfExperimentContext(ITmfTrace[] traces) {
57 this(traces, new TmfContext[traces.length]);
58 }
59
60 public TmfExperimentContext(TmfExperimentContext other) {
61 this(other.fTraces, other.cloneContexts());
62 fEvents = other.fEvents;
63 setLocation(other.getLocation());
64 setRank(other.getRank());
65 }
66
67 private TmfContext[] cloneContexts() {
68 TmfContext[] contexts = new TmfContext[fContexts.length];
69 for (int i = 0; i < fContexts.length; i++)
70 contexts[i] = fContexts[i].clone();
71 return contexts;
72 }
73
74 // ------------------------------------------------------------------------
75 // Accessors
76 // ------------------------------------------------------------------------
77
78 public ITmfTrace[] getTraces() {
79 return fTraces;
80 }
81
82 public TmfContext[] getContexts() {
83 return fContexts;
84 }
85
86 public TmfEvent[] getEvents() {
87 return fEvents;
88 }
89
90 public int getLastTrace() {
91 return lastIndex;
92 }
93
94 public void setLastTrace(int newIndex) {
95 lastIndex = newIndex;
96 }
97
98 }
This page took 0.032868 seconds and 6 git commands to generate.