Skip to content

Commit 9fe4441

Browse files
committed
tmf.core: Add data fetching capabilities to data providers
Introduce a new interface ITmfDataProviderConfigurationDataFetcher and model class TmfDataProviderConfigurationDataModel to allow data providers to fetch and return custom data based on provider configuration. [Added] Infrastructure of fetching a data provider configuration's data Signed-off-by: Kaveh Shahedi <kaveh.shahedi@ericsson.com>
1 parent 501e408 commit 9fe4441

File tree

3 files changed

+115
-1
lines changed

3 files changed

+115
-1
lines changed

tmf/org.eclipse.tracecompass.tmf.core/META-INF/MANIFEST.MF

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ Require-Bundle: org.eclipse.core.runtime,
1818
org.eclipse.tracecompass.tmf.filter.parser,
1919
org.eclipse.jdt.annotation;bundle-version="[2.0.0,3.0.0)";resolution:=optional,
2020
org.apache.commons.lang3
21-
Export-Package: org.eclipse.tracecompass.internal.provisional.tmf.core.model,
21+
Export-Package: org.eclipse.tracecompass.internal.provisional.tmf.core.dataprovider;x-internal:=true,
22+
org.eclipse.tracecompass.internal.provisional.tmf.core.model,
2223
org.eclipse.tracecompass.internal.provisional.tmf.core.model.events;x-friends:="org.eclipse.tracecompass.tmf.core.tests,org.eclipse.tracecompass.analysis.timing.core.tests",
2324
org.eclipse.tracecompass.internal.provisional.tmf.core.model.filter.parser;x-friends:="org.eclipse.tracecompass.tmf.ui,org.eclipse.tracecompass.tmf.core.tests",
2425
org.eclipse.tracecompass.internal.provisional.tmf.core.model.filters;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2025 Ericsson
3+
*
4+
* All rights reserved. This program and the accompanying materials are
5+
* made available under the terms of the Eclipse Public License 2.0 which
6+
* accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*******************************************************************************/
11+
package org.eclipse.tracecompass.internal.provisional.tmf.core.dataprovider;
12+
13+
import org.eclipse.tracecompass.tmf.core.dataprovider.IDataProviderDescriptor;
14+
import org.eclipse.tracecompass.tmf.core.response.TmfModelResponse;
15+
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
16+
17+
/**
18+
* Interface for data providers that can fetch custom data based on the provider.
19+
* Data providers that need to return specialized data types (images, reports, etc.)
20+
* can implement this interface and define the data fetching logic.
21+
*
22+
* @author Kaveh Shahedi
23+
* @since 10.3
24+
*/
25+
public interface ITmfDataProviderDataFetcher {
26+
27+
/**
28+
* Get the data for a specific trace and data provider.
29+
*
30+
* @param trace
31+
* The trace to get the data for
32+
* @param descriptor
33+
* The descriptor of the data provider
34+
* @return The report data
35+
* @throws Exception
36+
* If the data cannot be retrieved
37+
*/
38+
TmfModelResponse<TmfDataProviderDataModel<?>> getData(ITmfTrace trace, IDataProviderDescriptor descriptor) throws Exception;
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2025 Ericsson
3+
*
4+
* All rights reserved. This program and the accompanying materials are
5+
* made available under the terms of the Eclipse Public License 2.0 which
6+
* accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*******************************************************************************/
11+
package org.eclipse.tracecompass.internal.provisional.tmf.core.dataprovider;
12+
13+
/**
14+
* Data model for the data provider configuration data. This class is used to
15+
* hold the data that is returned by the data provider configuration.
16+
*
17+
* @author Kaveh Shahedi
18+
*
19+
* @param <T> Type of the content
20+
*/
21+
public class TmfDataProviderDataModel<T> {
22+
23+
private T fContent;
24+
private String fContentType;
25+
private String fContentName;
26+
27+
/**
28+
* Constructor
29+
*
30+
* @param content
31+
* The content of the data model
32+
* @param contentType
33+
* The type of the content
34+
* @param contentName
35+
* The name of the content
36+
*/
37+
public TmfDataProviderDataModel(T content, String contentType, String contentName) {
38+
fContent = content;
39+
fContentType = contentType;
40+
fContentName = contentName;
41+
}
42+
43+
/**
44+
* Get the content of the data model.
45+
* The content type is Object as it can be anything (e.g. image, report, etc.)
46+
*
47+
* @return The content of the data model
48+
*/
49+
public T getContent() {
50+
return fContent;
51+
}
52+
53+
/**
54+
* Get the type of the content.
55+
* This is used to identify the type of content that is returned by,
56+
* for instance, MIME type (e.g., application/octet-stream for binary data).
57+
*
58+
* @return The type of the content
59+
*/
60+
public String getContentType() {
61+
return fContentType;
62+
}
63+
64+
/**
65+
* Get the name of the content.
66+
* This is used to identify the name the content if required,
67+
* as it could be saved to a file.
68+
*
69+
* @return The name of the content
70+
*/
71+
public String getContentName() {
72+
return fContentName;
73+
}
74+
}

0 commit comments

Comments
 (0)