1 /*******************************************************************************
2 * Copyright (c) 2016 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
8 *******************************************************************************/
10 package org
.eclipse
.tracecompass
.internal
.analysis
.timing
.core
.callgraph
;
12 import org
.eclipse
.jdt
.annotation
.Nullable
;
13 import org
.eclipse
.tracecompass
.statesystem
.core
.statevalue
.ITmfStateValue
;
16 * Factory to create {@link ICalledFunction}s.
18 * @author Matthew Khouzam
20 public final class CalledFunctionFactory
{
22 private static final String SEPARATOR
= ": "; //$NON-NLS-1$
23 private static final String ERROR_MSG
= "Cannot create a called function of type : "; //$NON-NLS-1$
25 private CalledFunctionFactory() {
30 * Factory Method for a state value mapped called function
41 * The process ID of the traced application
44 * @return an ICalledFunction with the specified properties
46 public static AbstractCalledFunction
create(long start
, long end
, int depth
, ITmfStateValue stateValue
, int processId
, @Nullable ICalledFunction parent
) {
47 switch (stateValue
.getType()) {
49 return create(start
, end
, depth
, stateValue
.unboxInt(), processId
, parent
);
51 return create(start
, end
, depth
, stateValue
.unboxLong(), processId
, parent
);
53 return create(start
, end
, depth
, stateValue
.unboxStr(), processId
, parent
);
61 throw new IllegalArgumentException(ERROR_MSG
+ stateValue
.getType() + SEPARATOR
+ stateValue
.toString());
66 * Factory method to create a called function with a symbol that is a long
78 * The process ID of the traced application
81 * @return an ICalledFunction with the specified propertiess
83 private static CalledFunction
create(long start
, long end
, int depth
, long value
, int processId
, @Nullable ICalledFunction parent
) {
85 throw new IllegalArgumentException(Messages
.TimeError
+ '[' + start
+ ',' + end
+ ']');
87 return new CalledFunction(start
, end
, value
, depth
, processId
, parent
);
91 * Factory method to create a called function with a symbol that is a
103 * The process ID of the traced application
106 * @return an ICalledFunction with the specified properties
108 public static CalledStringFunction
create(long start
, long end
, int depth
, String value
, int processId
, @Nullable ICalledFunction parent
) {
110 throw new IllegalArgumentException(Messages
.TimeError
+ '[' + start
+ ',' + end
+ ']');
112 return new CalledStringFunction(start
, end
, value
, depth
, processId
, parent
);