5fea94a78b565eb4b7c13f91398b6e190cd704f6
[deliverable/tracecompass.git] / analysis / org.eclipse.tracecompass.analysis.lami.core / src / org / eclipse / tracecompass / internal / provisional / analysis / lami / core / aspect / LamiProcessTIDAspect.java
1 /*******************************************************************************
2 * Copyright (c) 2016 EfficiOS Inc., Philippe Proulx
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.internal.provisional.analysis.lami.core.aspect;
11
12 import java.util.Comparator;
13
14 import org.eclipse.jdt.annotation.Nullable;
15 import org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiTableEntry;
16 import org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiData;
17 import org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiProcess;
18
19 /**
20 * Aspect for process TID
21 *
22 * @author Philippe Proulx
23 */
24 public class LamiProcessTIDAspect extends LamiTableEntryAspect {
25
26 private final int fColIndex;
27
28 /**
29 * Constructor
30 *
31 * @param colName
32 * Column name
33 * @param colIndex
34 * Column index
35 */
36 public LamiProcessTIDAspect(String colName, int colIndex) {
37 super(colName + " (TID)", null); //$NON-NLS-1$
38 fColIndex = colIndex;
39 }
40
41 @Override
42 public boolean isContinuous() {
43 return false;
44 }
45
46 @Override
47 public boolean isTimeStamp() {
48 return false;
49 }
50
51 @Override
52 public @Nullable String resolveString(LamiTableEntry entry) {
53 LamiData data = entry.getValue(fColIndex);
54 if (data instanceof LamiProcess) {
55 Long tid = ((LamiProcess) data).getTID();
56
57 if (tid == null) {
58 return null;
59 }
60
61 return tid.toString();
62 }
63 /* Could be null, unknown, etc. */
64 return data.toString();
65 }
66
67 @Override
68 public @Nullable Double resolveDouble(LamiTableEntry entry) {
69 LamiData data = entry.getValue(fColIndex);
70 if (data instanceof LamiProcess) {
71 Long tid = ((LamiProcess) data).getTID();
72
73 if (tid == null) {
74 return null;
75 }
76
77 return Double.valueOf(tid);
78 }
79
80 return null;
81 }
82
83 @Override
84 public Comparator<LamiTableEntry> getComparator() {
85 return (o1, o2) -> {
86 Double dO1 = resolveDouble(o1);
87 Double dO2 = resolveDouble(o2);
88 if (dO1 == null || dO2 == null) {
89 return 0;
90 }
91
92 return dO1.compareTo(dO2);
93 };
94 }
95 }
This page took 0.036296 seconds and 4 git commands to generate.