~ubuntu-branches/ubuntu/trusty/eclipse-linuxtools/trusty

« back to all changes in this revision

Viewing changes to lttng/org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/views/resources/ResourcesEntry.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam
  • Date: 2012-06-29 12:07:30 UTC
  • Revision ID: package-import@ubuntu.com-20120629120730-bfri1xys1i71dpn6
Tags: upstream-1.0.0
ImportĀ upstreamĀ versionĀ 1.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*******************************************************************************
 
2
 * Copyright (c) 2012 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
 *   Patrick Tasse - Initial API and implementation
 
11
 *******************************************************************************/
 
12
 
 
13
package org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.resources;
 
14
 
 
15
import java.util.ArrayList;
 
16
import java.util.Iterator;
 
17
import java.util.List;
 
18
 
 
19
import org.eclipse.linuxtools.internal.lttng2.kernel.ui.views.common.EventIterator;
 
20
import org.eclipse.linuxtools.lttng2.kernel.core.trace.CtfKernelTrace;
 
21
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;
 
22
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;
 
23
 
 
24
public class ResourcesEntry implements ITimeGraphEntry {
 
25
    public static enum Type { NULL, CPU, IRQ, SOFT_IRQ };
 
26
 
 
27
    private int fQuark;
 
28
    private CtfKernelTrace fTrace;
 
29
    private ITimeGraphEntry fParent = null;
 
30
    private ITimeGraphEntry[] children = null;
 
31
    private String fName;
 
32
    private Type fType;
 
33
    private int fId;
 
34
    private long fStartTime;
 
35
    private long fEndTime;
 
36
    private List<ITimeEvent> fEventList = new ArrayList<ITimeEvent>();
 
37
    private List<ITimeEvent> fZoomedEventList = null;
 
38
 
 
39
    public ResourcesEntry(int quark, CtfKernelTrace trace, Type type, int id) {
 
40
        fQuark = quark;
 
41
        fTrace = trace;
 
42
        fType = type;
 
43
        fId = id;
 
44
        fName = type.toString() + ' ' + Integer.toString(id);
 
45
    }
 
46
 
 
47
    @Override
 
48
    public ITimeGraphEntry getParent() {
 
49
        return fParent;
 
50
    }
 
51
 
 
52
    @Override
 
53
    public boolean hasChildren() {
 
54
        return children != null && children.length > 0;
 
55
    }
 
56
 
 
57
    @Override
 
58
    public ITimeGraphEntry[] getChildren() {
 
59
        return children;
 
60
    }
 
61
 
 
62
    @Override
 
63
    public String getName() {
 
64
        return fName;
 
65
    }
 
66
 
 
67
    @Override
 
68
    public long getStartTime() {
 
69
        return fStartTime;
 
70
    }
 
71
 
 
72
    @Override
 
73
    public long getEndTime() {
 
74
        return fEndTime;
 
75
    }
 
76
 
 
77
    @Override
 
78
    public boolean hasTimeEvents() {
 
79
        return true;
 
80
    }
 
81
 
 
82
    @Override
 
83
    public Iterator<ITimeEvent> getTimeEventsIterator() {
 
84
        return new EventIterator(fEventList, fZoomedEventList);
 
85
    }
 
86
 
 
87
    @Override
 
88
    public Iterator<ITimeEvent> getTimeEventsIterator(long startTime, long stopTime, long visibleDuration) {
 
89
        return new EventIterator(fEventList, fZoomedEventList, startTime, stopTime);
 
90
    }
 
91
 
 
92
    public void setParent(ITimeGraphEntry parent) {
 
93
        fParent = parent;
 
94
    }
 
95
 
 
96
    public int getQuark() {
 
97
        return fQuark;
 
98
    }
 
99
 
 
100
    public CtfKernelTrace getTrace() {
 
101
        return fTrace;
 
102
    }
 
103
 
 
104
    public Type getType() {
 
105
        return fType;
 
106
    }
 
107
 
 
108
    public int getId() {
 
109
        return fId;
 
110
    }
 
111
 
 
112
    public void setEventList(List<ITimeEvent> eventList) {
 
113
        fEventList = eventList;
 
114
        if (eventList != null && eventList.size() > 0) {
 
115
            fStartTime = eventList.get(0).getTime();
 
116
            ITimeEvent lastEvent = eventList.get(eventList.size() - 1);
 
117
            fEndTime = lastEvent.getTime() + lastEvent.getDuration();
 
118
        }
 
119
    }
 
120
 
 
121
    public void setZoomedEventList(List<ITimeEvent> eventList) {
 
122
        fZoomedEventList = eventList;
 
123
    }
 
124
}