os.linux: Rename the "kernelanalysis" package to just "kernel"
[deliverable/tracecompass.git] / analysis / org.eclipse.tracecompass.analysis.os.linux.ui / src / org / eclipse / tracecompass / analysis / os / linux / ui / views / resources / AggregateResourcesEntry.java
1 /*******************************************************************************
2 * Copyright (c) 2016 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
10 package org.eclipse.tracecompass.analysis.os.linux.ui.views.resources;
11
12 import java.util.ArrayList;
13 import java.util.Comparator;
14 import java.util.Iterator;
15 import java.util.List;
16
17 import org.eclipse.jdt.annotation.NonNull;
18 import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
19 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
20 import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeEvent;
21 import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;
22 import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeEvent;
23
24 /**
25 * Internal entry of the aggregate kind, it is one without a state system value,
26 * it uses other entries and aggregates their values.
27 *
28 * @author Matthew Khouzam
29 */
30 class AggregateResourcesEntry extends ResourcesEntry {
31
32 private final @NonNull List<ITimeGraphEntry> fContributors = new ArrayList<>();
33
34 private static final Comparator<ITimeEvent> COMPARATOR = new Comparator<ITimeEvent>() {
35 @Override
36 public int compare(ITimeEvent o1, ITimeEvent o2) {
37 // largest value
38 return Integer.compare(getValue(o2), getValue(o1));
39 }
40
41 private int getValue(ITimeEvent element) {
42 return (element instanceof TimeEvent) ? ((TimeEvent) element).getValue() : Integer.MIN_VALUE;
43 }
44 };
45
46 /**
47 * AggregateResourcesEntry Constructor
48 *
49 * @param trace
50 * the parent trace
51 * @param startTime
52 * the start time
53 * @param endTime
54 * the end time
55 * @param type
56 * the type
57 * @param id
58 * the id
59 */
60 public AggregateResourcesEntry(@NonNull ITmfTrace trace,
61 long startTime, long endTime, Type type, int id) {
62 super(ITmfStateSystem.INVALID_ATTRIBUTE, trace, startTime, endTime, type, id);
63 }
64
65 /**
66 * Constructor
67 *
68 * @param trace
69 * The trace on which we are working
70 * @param name
71 * The exec_name of this entry
72 * @param startTime
73 * The start time of this entry lifetime
74 * @param endTime
75 * The end time of this entry
76 * @param type
77 * The type of this entry
78 * @param id
79 * The id of this entry
80 */
81 public AggregateResourcesEntry(@NonNull ITmfTrace trace, String name, long startTime, long endTime, Type type, int id) {
82 super(ITmfStateSystem.INVALID_ATTRIBUTE, trace, name, startTime, endTime, type, id);
83 }
84
85 @Override
86 public void addEvent(ITimeEvent event) {
87 }
88
89 @Override
90 public void addZoomedEvent(ITimeEvent event) {
91 }
92
93 @Override
94 public Iterator<@NonNull ITimeEvent> getTimeEventsIterator() {
95 return new AggregateEventIterator(fContributors, COMPARATOR);
96 }
97
98 @Override
99 public Iterator<@NonNull ITimeEvent> getTimeEventsIterator(long startTime, long stopTime, long visibleDuration) {
100 return new AggregateEventIterator(fContributors, startTime, stopTime, visibleDuration, COMPARATOR);
101 }
102
103 public void addContributor(ITimeGraphEntry entry) {
104 fContributors.add(entry);
105 }
106 }
This page took 0.033387 seconds and 5 git commands to generate.