1 /*******************************************************************************
2 * Copyright (c) 2009 Ericsson
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
10 * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation
11 *******************************************************************************/
12 package org
.eclipse
.linuxtools
.lttng
.ui
.views
.controlflow
.model
;
14 import java
.util
.Vector
;
16 import org
.eclipse
.linuxtools
.lttng
.ui
.model
.trange
.TimeRangeEventProcess
;
19 * Common location to allocate the processes in use by the Control flow view
24 public class FlowProcessContainer
{
25 // ========================================================================
27 // ========================================================================
28 private final Vector
<TimeRangeEventProcess
> processes
= new Vector
<TimeRangeEventProcess
>();
29 private int idgen
= 0;
31 // ========================================================================
33 // ========================================================================
36 * Package level constructor
38 FlowProcessContainer() {
42 // ========================================================================
44 // ========================================================================
46 * Interface to add processes.
50 public void addProcesse(TimeRangeEventProcess process
) {
51 if (process
!= null) {
52 processes
.add(process
);
57 * This method is intended for ready only purposes in order to keep the
58 * internal data structure in Synch
62 public Vector
<TimeRangeEventProcess
> readProcesses() {
67 * Clear the children information for processes related to a specific trace
68 * e.g. just before refreshing data with a new time range
72 public void clearChildren(String traceId
) {
74 for (TimeRangeEventProcess process
: processes
) {
75 procTraceId
= process
.getTraceID();
76 if (procTraceId
.equals(traceId
)) {
83 * remove the processes related to a specific trace e.g. during trace
88 public void removeProcesses(String traceId
) {
90 for (TimeRangeEventProcess process
: processes
) {
91 procTraceId
= process
.getTraceID();
92 if (procTraceId
.equals(traceId
)) {
93 // Children and traceEvent will get claimed by the garbage collector when process is unreferenced
94 // Therefore, we don't need to removed them
95 processes
.remove(process
);
101 * A match is returned if the three arguments received match an entry in the
102 * Map, otherwise null is returned
105 * @param creationtime
109 public TimeRangeEventProcess
findProcess(Long pid
, Long creationtime
,
111 TimeRangeEventProcess rprocess
= null;
113 // TODO: This needs a more efficient way to find, e.g. use class with
114 // hash code base on the keys trace, pid and creation time the class
115 // should also override the equals to valid the search via the hashcode
116 for (TimeRangeEventProcess process
: processes
) {
117 if (process
.getPid().equals(pid
)) {
118 if (process
.getCreationTime().equals(creationtime
)) {
119 if (process
.getTraceID().equals(traceID
)) {
130 * Generate a unique process id while building the process list
134 public int bookProcId() {