128bc5412cda3c25321661395aa7b0d919a292e6
[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
31 // ------------------------------------------------------------------------
32 // Constructors
33 // ------------------------------------------------------------------------
34
35 public TmfExperimentContext(ITmfTrace[] traces, TmfContext[] contexts) {
36 super();
37 fTraces = traces;
38 fContexts = contexts;
39 fEvents = new TmfEvent[fTraces.length];
40
41 ITmfLocation[] locations = new ITmfLocation[fTraces.length];
42 long rank = 0;
43 for (int i = 0; i < fTraces.length; i++) {
44 if (contexts[i] != null) {
45 locations[i] = contexts[i].getLocation();
46 rank += contexts[i].getRank();
47 }
48 }
49
50 setLocation(new TmfExperimentLocation(locations));
51 setRank(rank);
52 }
53
54 public TmfExperimentContext(ITmfTrace[] traces) {
55 this(traces, new TmfContext[traces.length]);
56 }
57
58 public TmfExperimentContext(TmfExperimentContext other) {
59 this(other.fTraces, other.cloneContexts());
60 fEvents = other.fEvents;
61 setLocation(other.getLocation());
62 setRank(other.getRank());
63 }
64
65 private TmfContext[] cloneContexts() {
66 TmfContext[] contexts = new TmfContext[fContexts.length];
67 for (int i = 0; i < fContexts.length; i++)
68 contexts[i] = fContexts[i].clone();
69 return contexts;
70 }
71
72 // ------------------------------------------------------------------------
73 // Accessors
74 // ------------------------------------------------------------------------
75
76 public ITmfTrace[] getTraces() {
77 return fTraces;
78 }
79
80 public TmfContext[] getContexts() {
81 return fContexts;
82 }
83
84 public TmfEvent[] getEvents() {
85 return fEvents;
86 }
87
88 }
This page took 0.0315260000000001 seconds and 4 git commands to generate.