Skip to content

Commit 7ac254b

Browse files
committed
counter.core: Generalize the counterAnalysis to take ITmfCounterAspect
[Changed] Allowed ITmfCounterAspect populate counterAnalysis Signed-off-by: Reza Rouhghalandari <reza.rouhghalandari@ericsson.com>
1 parent c8509f5 commit 7ac254b

File tree

4 files changed

+53
-8
lines changed

4 files changed

+53
-8
lines changed

analysis/org.eclipse.tracecompass.analysis.counters.core/src/org/eclipse/tracecompass/analysis/counters/core/CounterStateProvider.java

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ public static CounterStateProvider create(ITmfTrace trace) {
7676
Iterable<ITmfEventAspect<?>> counterAspects = TmfTraceUtils.getEventAspects(trace, ITmfCounterAspect.class);
7777
for (ITmfEventAspect<?> counter : counterAspects) {
7878

79-
if (counter instanceof CounterAspect) {
80-
CounterAspect counterAspect = (CounterAspect) counter;
79+
if (counter instanceof ITmfCounterAspect) {
80+
ITmfCounterAspect counterAspect = (ITmfCounterAspect) counter;
8181
for (Class<? extends ITmfEventAspect<?>> parentAspectClass : counterAspect.getGroups()) {
8282

8383
// Avoid creating the same aggregated aspect multiple times
@@ -122,14 +122,14 @@ protected void eventHandle(@NonNull ITmfEvent event) {
122122
}
123123

124124
for (ITmfEventAspect<?> aspect : fCounterAspects) {
125-
if (aspect instanceof CounterAspect) {
126-
CounterAspect counterAspect = (CounterAspect) aspect;
125+
if (aspect instanceof ITmfCounterAspect) {
126+
ITmfCounterAspect counterAspect = (ITmfCounterAspect) aspect;
127127
if (counterAspect.getGroups().length > 0) {
128128
int rootQuark = ss.getQuarkAbsoluteAndAdd(CounterAnalysis.GROUPED_COUNTER_ASPECTS_ATTRIB);
129-
handleGroupedCounterAspect(event, ss, counterAspect, rootQuark);
129+
handleGroupedCounterAspect(event, ss, rootQuark, counterAspect);
130130
} else {
131131
int rootQuark = ss.getQuarkAbsoluteAndAdd(CounterAnalysis.UNGROUPED_COUNTER_ASPECTS_ATTRIB);
132-
handleCounterAspect(event, ss, counterAspect, rootQuark);
132+
handleCounterAspect(event, ss, rootQuark, counterAspect);
133133
}
134134
}
135135
}
@@ -147,8 +147,29 @@ protected void eventHandle(@NonNull ITmfEvent event) {
147147
* Grouped counter aspect
148148
* @param rootQuark
149149
* Key to a relative root of the state system
150+
* @deprecated use
151+
* {@link #handleGroupedCounterAspect(ITmfEvent, ITmfStateSystemBuilder, int, ITfmCounterAspect)}
150152
*/
153+
@Deprecated
151154
protected void handleGroupedCounterAspect(ITmfEvent event, ITmfStateSystemBuilder ss, CounterAspect aspect, int rootQuark) {
155+
handleGroupedCounterAspect(event, ss, rootQuark, aspect);
156+
}
157+
158+
/**
159+
* Add the field value of a grouped counter aspect to the state system
160+
* (override in specific implementations)
161+
*
162+
* @param event
163+
* Event to process
164+
* @param ss
165+
* State system object to fill
166+
* @param rootQuark
167+
* Key to a relative root of the state system
168+
* @param aspect
169+
* Grouped counter aspect
170+
* @since 2.2
171+
*/
172+
protected void handleGroupedCounterAspect(ITmfEvent event, ITmfStateSystemBuilder ss, int rootQuark, ITmfCounterAspect aspect) {
152173
/*
153174
* Retrieve the child quark of the counter aspect by going through its
154175
* attribute tree in the state system. The concatenation of the aspect's
@@ -170,10 +191,10 @@ protected void handleGroupedCounterAspect(ITmfEvent event, ITmfStateSystemBuilde
170191
}
171192
}
172193

173-
handleCounterAspect(event, ss, aspect, quark);
194+
handleCounterAspect(event, ss, quark, aspect);
174195
}
175196

176-
private static void handleCounterAspect(ITmfEvent event, ITmfStateSystemBuilder ss, CounterAspect aspect, int rootQuark) {
197+
private static void handleCounterAspect(ITmfEvent event, ITmfStateSystemBuilder ss, int rootQuark, ITmfCounterAspect aspect) {
177198
int quark = ss.getQuarkRelativeAndAdd(rootQuark, aspect.getName());
178199
Number eventContent = aspect.resolve(event);
179200
if (eventContent != null) {

analysis/org.eclipse.tracecompass.analysis.counters.core/src/org/eclipse/tracecompass/analysis/counters/core/aspects/AbstractCounterAspect.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ public boolean equals(@Nullable Object obj) {
130130
* @return the type of this counter
131131
* @since 2.1
132132
*/
133+
@Override
133134
public CounterType getType() {
134135
return fType;
135136
}

analysis/org.eclipse.tracecompass.analysis.counters.core/src/org/eclipse/tracecompass/analysis/counters/core/aspects/CounterAspect.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public CounterAspect(String fieldName, String label, CounterType type, Class<? e
8181
*
8282
* @return the groups
8383
*/
84+
@Override
8485
public Class<? extends ITmfEventAspect<?>>[] getGroups() {
8586
return fGroups;
8687
}

analysis/org.eclipse.tracecompass.analysis.counters.core/src/org/eclipse/tracecompass/analysis/counters/core/aspects/ITmfCounterAspect.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
package org.eclipse.tracecompass.analysis.counters.core.aspects;
1313

14+
import org.eclipse.tracecompass.analysis.counters.core.CounterType;
1415
import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
1516

1617
/**
@@ -52,4 +53,25 @@ default boolean isHiddenByDefault() {
5253
default boolean isCumulative() {
5354
return true;
5455
}
56+
57+
/**
58+
* Get the groups
59+
*
60+
* @return the groups
61+
* @since 2.2
62+
*/
63+
default Class<? extends ITmfEventAspect<?>>[] getGroups(){
64+
return new Class[0];
65+
}
66+
67+
/**
68+
* Gets the type of this counter
69+
*
70+
* @return the type of this counter
71+
* @since 2.2
72+
*/
73+
default CounterType getType() {
74+
return CounterType.LONG;
75+
}
76+
5577
}

0 commit comments

Comments
 (0)