| 1 | /******************************************************************************* |
| 2 | * Copyright (c) 2010, 2016 Ericsson, École Polytechnique de Montréal, and others |
| 3 | * |
| 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 | *******************************************************************************/ |
| 9 | |
| 10 | package org.eclipse.tracecompass.internal.statesystem.core.backend.historytree; |
| 11 | |
| 12 | import java.util.Collection; |
| 13 | import org.eclipse.jdt.annotation.NonNull; |
| 14 | import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException; |
| 15 | |
| 16 | /** |
| 17 | * A Core node is a first-level node of a History Tree which is not a leaf node. |
| 18 | * |
| 19 | * It extends HTNode by adding support for child nodes, and also extensions. |
| 20 | * |
| 21 | * @author Alexandre Montplaisir |
| 22 | * @author Florian Wininger |
| 23 | */ |
| 24 | public abstract class ParentNode extends HTNode { |
| 25 | |
| 26 | /** |
| 27 | * Initial constructor. Use this to initialize a new EMPTY node. |
| 28 | * |
| 29 | * @param config |
| 30 | * Configuration of the History Tree |
| 31 | * @param seqNumber |
| 32 | * The (unique) sequence number assigned to this particular node |
| 33 | * @param parentSeqNumber |
| 34 | * The sequence number of this node's parent node |
| 35 | * @param start |
| 36 | * The earliest timestamp stored in this node |
| 37 | */ |
| 38 | public ParentNode(HTConfig config, int seqNumber, int parentSeqNumber, |
| 39 | long start) { |
| 40 | super(config, seqNumber, parentSeqNumber, start); |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * Return the number of child nodes this node has. |
| 45 | * |
| 46 | * @return The number of child nodes |
| 47 | */ |
| 48 | public abstract int getNbChildren(); |
| 49 | |
| 50 | /** |
| 51 | * Get the child node corresponding to the specified index |
| 52 | * |
| 53 | * @param index The index of the child to lookup |
| 54 | * @return The child node |
| 55 | */ |
| 56 | public abstract int getChild(int index); |
| 57 | |
| 58 | /** |
| 59 | * Get the latest (right-most) child node of this node. |
| 60 | * |
| 61 | * @return The latest child node |
| 62 | */ |
| 63 | public abstract int getLatestChild(); |
| 64 | |
| 65 | /** |
| 66 | * Get the start time of the specified child node. |
| 67 | * |
| 68 | * @param index |
| 69 | * The index of the child node |
| 70 | * @return The start time of the that child node. |
| 71 | */ |
| 72 | public abstract long getChildStart(int index); |
| 73 | |
| 74 | /** |
| 75 | * Tell this node that it has a new child (Congrats!) |
| 76 | * |
| 77 | * @param childNode |
| 78 | * The SHTNode object of the new child |
| 79 | */ |
| 80 | public abstract void linkNewChild(HTNode childNode); |
| 81 | |
| 82 | /** |
| 83 | * Inner method to select the sequence numbers for the children of the |
| 84 | * current node that intersect the given timestamp. Useful for moving down |
| 85 | * the tree. |
| 86 | * |
| 87 | * @param t |
| 88 | * The timestamp to choose which child is the next one |
| 89 | * @return Collection of sequence numbers of the child nodes that intersect |
| 90 | * t, non-null empty collection if this is a Leaf Node |
| 91 | * @throws TimeRangeException |
| 92 | * If t is out of the node's range |
| 93 | */ |
| 94 | public abstract @NonNull Collection<@NonNull Integer> selectNextChildren(long t); |
| 95 | |
| 96 | } |