Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 431368
Collapse All | Expand All

(-)a/lttng/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/StateSystemTest.java (+19 lines)
Lines 422-425 public abstract class StateSystemTest { Link Here
422
            fail();
422
            fail();
423
        }
423
        }
424
    }
424
    }
425
426
    @Test
427
    public void testParentAttribute() {
428
        String[] path = { "CPUs/0/Current_thread",
429
                          "CPUs/0",
430
                          "CPUs" };
431
        try {
432
            int q = ssq.getQuarkAbsolute(Attributes.CPUS, "0", Attributes.CURRENT_THREAD);
433
            for (int i = 0; i < path.length; i++) {
434
                String name = ssq.getFullAttributePath(q);
435
                assertEquals(path[i], name);
436
                q = ssq.getParentAttributeQuark(q);
437
            }
438
            assertEquals(-1, q);
439
        } catch (AttributeNotFoundException e) {
440
            fail();
441
        }
442
    }
443
425
}
444
}
(-)a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/Attribute.java (+16 lines)
Lines 129-134 public abstract class Attribute { Link Here
129
        return targetNode.getQuark();
129
        return targetNode.getQuark();
130
    }
130
    }
131
131
132
    /**
133
     * Get the parent attribute of this attribute
134
     * @return The parent attribute
135
     */
136
    public Attribute getParentAttribute() {
137
        return this.parent;
138
    }
139
140
    /**
141
     * Get the parent quark of this attribute
142
     * @return The quark of the parent attribute
143
     */
144
    public int getParentAttributeQuark() {
145
        return this.parent.getQuark();
146
    }
147
132
    /* The methods how to access children are left to derived classes */
148
    /* The methods how to access children are left to derived classes */
133
149
134
    /**
150
    /**
(-)a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/AttributeTree.java (+11 lines)
Lines 357-362 public final class AttributeTree { Link Here
357
        return listOfChildren;
357
        return listOfChildren;
358
    }
358
    }
359
359
360
    /**
361
     * Returns the parent quark of the attribute. The root attribute
362
     * has no parent.
363
     *
364
     * @param attributeQuark The quark of the attribute
365
     * @return Quark of the parent attribute
366
     */
367
    public int getParentAttributeQuark(int quark) {
368
        return attributeList.get(quark).getParentAttributeQuark();
369
    }
370
360
    private void addSubAttributes(List<Integer> list, Attribute curAttribute,
371
    private void addSubAttributes(List<Integer> list, Attribute curAttribute,
361
            boolean recursive) {
372
            boolean recursive) {
362
        for (Attribute childNode : curAttribute.getSubAttributes()) {
373
        for (Attribute childNode : curAttribute.getSubAttributes()) {
(-)a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/StateSystem.java (+5 lines)
Lines 278-283 public class StateSystem implements ITmfStateSystemBuilder { Link Here
278
    }
278
    }
279
279
280
    @Override
280
    @Override
281
    public int getParentAttributeQuark(int quark) {
282
        return getAttributeTree().getParentAttributeQuark(quark);
283
    }
284
285
    @Override
281
    public List<Integer> getQuarks(String... pattern) {
286
    public List<Integer> getQuarks(String... pattern) {
282
        List<Integer> quarks = new LinkedList<>();
287
        List<Integer> quarks = new LinkedList<>();
283
        List<String> prefix = new LinkedList<>();
288
        List<String> prefix = new LinkedList<>();
(-)a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statesystem/ITmfStateSystem.java (-1 / +9 lines)
Lines 249-254 public interface ITmfStateSystem { Link Here
249
    String getFullAttributePath(int attributeQuark);
249
    String getFullAttributePath(int attributeQuark);
250
250
251
    /**
251
    /**
252
     * Returns the parent quark of the attribute. The root attribute
253
     * has no parent.
254
     *
255
     * @param attributeQuark The quark of the attribute
256
     * @return Quark of the parent attribute
257
     */
258
    int getParentAttributeQuark(int attributeQuark);
259
260
    /**
252
     * @name Query methods
261
     * @name Query methods
253
     */
262
     */
254
263
255
- 

Return to bug 431368