*
* Contributors:
* Alvaro Sanchez-Leon - Initial API and implementation
+ * Michel Dagenais (michel.dagenais@polymtl.ca) - Reference C implementation, used with permission
*******************************************************************************/
package org.eclipse.linuxtools.lttng.ui.views.controlflow.model;
import java.util.HashMap;
import java.util.Iterator;
-import org.eclipse.linuxtools.lttng.TraceDebug;
+import org.eclipse.linuxtools.lttng.core.TraceDebug;
+import org.eclipse.linuxtools.lttng.ui.model.trange.ItemContainer;
import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeEventProcess;
/**
* @author alvaro
*
*/
-public class FlowProcessContainer {
+public class FlowProcessContainer implements ItemContainer<TimeRangeEventProcess> {
// ========================================================================
// Data
// ========================================================================
*
* @param newProcess The process to add
*/
- public void addProcess(TimeRangeEventProcess newProcess) {
- if (newProcess != null) {
- allProcesses.put(new ProcessKey(newProcess), newProcess);
+ @Override
+ public void addItem(TimeRangeEventProcess newItem) {
+ if (newItem != null) {
+ allProcesses.put(new ProcessKey(newItem), newItem);
}
}
*
* @return Integer
*/
- public Integer getUniqueId() {
+ @Override
+ public Integer getUniqueId() {
return uniqueId++;
}
*
* @return TimeRangeEventProcess[]
*/
- public TimeRangeEventProcess[] readProcesses() {
+ @Override
+ public TimeRangeEventProcess[] readItems() {
// This allow us to return an Array of the correct type of the exact correct dimension, without looping
return allProcesses.values().toArray(new TimeRangeEventProcess[allProcesses.size()]);
}
/**
- * Clear the children information for processes related to a specific trace
- * e.g. just before refreshing data with a new time range
- *
- * @param traceId The trace unique id (trace name?) on which we need to eliminate children.
- */
- public void clearChildren(String traceId) {
+ * Clear the children information for processes e.g. just before refreshing
+ * data with a new time range
+ */
+ @Override
+ public void clearChildren() {
TimeRangeEventProcess process = null;
Iterator<ProcessKey> iterator = allProcesses.keySet().iterator();
while (iterator.hasNext()) {
process = allProcesses.get(iterator.next());
-
- if (process.getTraceID().equals(traceId)) {
- // Reset clear childEventComposites() and traceEvents()
- // Also restore the nextGoodTime to the insertionTime for the drawing
- process.reset();
- }
+ process.reset();
}
}
/**
* Clear all process items
*/
- public void clearProcesses() {
+ @Override
+ public void clearItems() {
allProcesses.clear();
}
*
* @param traceId The trace unique id (trace name?) on which we want to remove process
*/
- public void removeProcesses(String traceId) {
+ @Override
+ public void removeItems(String traceId) {
ProcessKey iterKey = null;
Iterator<ProcessKey> iterator = allProcesses.keySet().iterator();
if ( obj instanceof ProcessKey ) {
ProcessKey procKey = (ProcessKey) obj;
- if ( valueRef != null ) {
- if ( (procKey.getPid().equals(valueRef.getPid()) ) &&
- (procKey.getTraceId().equals(valueRef.getTraceID()) ) &&
- (procKey.getCpuId().equals(valueRef.getCpu()) ) &&
- (procKey.getCreationtime().equals(valueRef.getCreationTime()) ) )
- {
- isSame = true;
- }
- }
- else {
- if ( (procKey.getPid().equals(this.pid ) ) &&
- (procKey.getTraceId().equals(this.traceId ) ) &&
- (procKey.getCpuId().equals(this.cpuId ) ) &&
- (procKey.getCreationtime().equals(this.creationtime ) ) )
- {
- isSame = true;
- }
- }
+ if (valueRef != null) {
+ if ((procKey.getPid().equals(valueRef.getPid()))
+ && (procKey.getTraceId().equals(valueRef.getTraceID()))
+ && (procKey.getCreationtime().equals(valueRef.getCreationTime()))) {
+ // use the cpu value to validate pid 0
+ if (valueRef.getPid().longValue() == 0L && !procKey.getCpuId().equals(valueRef.getCpu())) {
+ isSame = false;
+ } else {
+ isSame = true;
+ }
+ }
+ } else {
+ if ((procKey.getPid().equals(this.pid)) && (procKey.getTraceId().equals(this.traceId))
+ && (procKey.getCreationtime().equals(this.creationtime))) {
+ // use the cpu value to validate pid 0
+ if (this.pid.longValue() == 0L && !procKey.getCpuId().equals(this.cpuId)) {
+ isSame = false;
+ } else {
+ isSame = true;
+ }
+ }
+ }
}
else {
- TraceDebug.debug("ERROR : The given key is not of the type ProcessKey!" + obj.getClass().toString());
+ TraceDebug.debug("ERROR : The given key is not of the type ProcessKey!" + obj.getClass().toString()); //$NON-NLS-1$
}
return isSame;
}
- @Override
+ @Override
+ @SuppressWarnings("nls")
public String toString() {
if ( valueRef != null ) {
- return (valueRef.getPid().toString() + ":" + valueRef.getCpu().toString() + ":" + valueRef.getTraceID().toString() + ":" + valueRef.getCreationTime().toString());
+ // return (valueRef.getPid().toString() + ":" +
+ // valueRef.getCpu().toString() + ":"
+ // + valueRef.getTraceID().toString() + ":" +
+ // valueRef.getCreationTime().toString());
+ return (valueRef.getPid().toString() + ":" + valueRef.getTraceID().toString() + ":" + valueRef
+ .getCreationTime().toString());
}
- return (pid.toString() + ":" + cpuId.toString() + ":" + traceId.toString() + ":" + creationtime.toString());
+ // return (pid.toString() + ":" + cpuId.toString() + ":" +
+ // traceId.toString() + ":" + creationtime.toString());
+
+ return (pid.toString() + ":" + traceId.toString() + ":" + creationtime.toString());
}
}