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
)) {
77 process
.getTraceEvents().clear();
78 process
.getChildEventComposites().clear();
84 * remove the processes related to a specific trace e.g. during trace
89 public void removeProcesses(String traceId
) {
91 for (TimeRangeEventProcess process
: processes
) {
92 procTraceId
= process
.getTraceID();
93 if (procTraceId
.equals(traceId
)) {
94 // Children and traceEvent will get claimed by the garbage collector when process is unreferenced
95 // Therefore, we don't need to removed them
96 processes
.remove(process
);
102 * A match is returned if the three arguments received match an entry in the
103 * Map, otherwise null is returned
106 * @param creationtime
110 public TimeRangeEventProcess
findProcess(Long pid
, Long creationtime
,
112 TimeRangeEventProcess rprocess
= null;
114 for (TimeRangeEventProcess process
: processes
) {
115 if (process
.getPid().equals(pid
)) {
116 if (process
.getCreationTime().equals(creationtime
)) {
117 if (process
.getTraceID().equals(traceID
)) {
128 * Generate a unique process id while building the process list
132 public int bookProcId() {