Skip to content

Commit e444a3c

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 e444a3c

4 files changed

Lines changed: 29 additions & 7 deletions

File tree

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import java.util.logging.Logger;
1919

2020
import org.eclipse.jdt.annotation.NonNull;
21-
import org.eclipse.tracecompass.analysis.counters.core.aspects.CounterAspect;
2221
import org.eclipse.tracecompass.analysis.counters.core.aspects.ITmfCounterAspect;
2322
import org.eclipse.tracecompass.common.core.log.TraceCompassLog;
2423
import org.eclipse.tracecompass.common.core.log.TraceCompassLogUtils;
@@ -76,8 +75,8 @@ public static CounterStateProvider create(ITmfTrace trace) {
7675
Iterable<ITmfEventAspect<?>> counterAspects = TmfTraceUtils.getEventAspects(trace, ITmfCounterAspect.class);
7776
for (ITmfEventAspect<?> counter : counterAspects) {
7877

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

8382
// Avoid creating the same aggregated aspect multiple times
@@ -122,8 +121,8 @@ protected void eventHandle(@NonNull ITmfEvent event) {
122121
}
123122

124123
for (ITmfEventAspect<?> aspect : fCounterAspects) {
125-
if (aspect instanceof CounterAspect) {
126-
CounterAspect counterAspect = (CounterAspect) aspect;
124+
if (aspect instanceof ITmfCounterAspect) {
125+
ITmfCounterAspect counterAspect = (ITmfCounterAspect) aspect;
127126
if (counterAspect.getGroups().length > 0) {
128127
int rootQuark = ss.getQuarkAbsoluteAndAdd(CounterAnalysis.GROUPED_COUNTER_ASPECTS_ATTRIB);
129128
handleGroupedCounterAspect(event, ss, counterAspect, rootQuark);
@@ -147,8 +146,9 @@ protected void eventHandle(@NonNull ITmfEvent event) {
147146
* Grouped counter aspect
148147
* @param rootQuark
149148
* Key to a relative root of the state system
149+
* @since 3.0
150150
*/
151-
protected void handleGroupedCounterAspect(ITmfEvent event, ITmfStateSystemBuilder ss, CounterAspect aspect, int rootQuark) {
151+
protected void handleGroupedCounterAspect(ITmfEvent event, ITmfStateSystemBuilder ss, ITmfCounterAspect aspect, int rootQuark) {
152152
/*
153153
* Retrieve the child quark of the counter aspect by going through its
154154
* attribute tree in the state system. The concatenation of the aspect's
@@ -173,7 +173,7 @@ protected void handleGroupedCounterAspect(ITmfEvent event, ITmfStateSystemBuilde
173173
handleCounterAspect(event, ss, aspect, quark);
174174
}
175175

176-
private static void handleCounterAspect(ITmfEvent event, ITmfStateSystemBuilder ss, CounterAspect aspect, int rootQuark) {
176+
private static void handleCounterAspect(ITmfEvent event, ITmfStateSystemBuilder ss, ITmfCounterAspect aspect, int rootQuark) {
177177
int quark = ss.getQuarkRelativeAndAdd(rootQuark, aspect.getName());
178178
Number eventContent = aspect.resolve(event);
179179
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: 20 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,23 @@ default boolean isHiddenByDefault() {
5253
default boolean isCumulative() {
5354
return true;
5455
}
56+
/**
57+
* Get the groups
58+
*
59+
* @return the groups
60+
* @since 2.2
61+
*/
62+
default Class<? extends ITmfEventAspect<?>>[] getGroups(){
63+
return new Class[0];
64+
}
65+
/**
66+
* Gets the type of this counter
67+
*
68+
* @return the type of this counter
69+
* @since 2.2
70+
*/
71+
default CounterType getType() {
72+
return CounterType.LONG;
73+
}
74+
5575
}

0 commit comments

Comments
 (0)