import java.io.File;
import java.io.FileInputStream;
-import java.io.PrintWriter;
+import java.io.IOException;
import java.nio.channels.ClosedChannelException;
-
import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException;
/**
* high-level data relevant to the tree.
*
* @author Alexandre Montplaisir
+ * @author Geneviève Bastien
*/
public interface IHistoryTree {
+ /**
+ * Interface for history to create the various HTNodes
+ */
+ interface IHTNodeFactory {
+
+ /**
+ * Creates a new core node for the specific history tree
+ *
+ * @param config
+ * Configuration of the History Tree
+ * @param seqNumber
+ * The (unique) sequence number assigned to this particular
+ * node
+ * @param parentSeqNumber
+ * The sequence number of this node's parent node
+ * @param start
+ * The earliest timestamp stored in this node
+ * @return The new core node
+ * @throws IOException
+ * any exception occurring while trying to read/create the
+ * node
+ */
+ HTNode createCoreNode(HTConfig config, int seqNumber, int parentSeqNumber, long start) throws IOException;
+
+ /**
+ * Creates a new core node for the specific history tree
+ *
+ * @param config
+ * Configuration of the History Tree
+ * @param seqNumber
+ * The (unique) sequence number assigned to this particular
+ * node
+ * @param parentSeqNumber
+ * The sequence number of this node's parent node
+ * @param start
+ * The earliest timestamp stored in this node
+ * @return The new core node
+ * @throws IOException
+ * any exception occurring while trying to read/create the
+ * node
+ */
+ HTNode createLeafNode(HTConfig config, int seqNumber, int parentSeqNumber, long start) throws IOException;
+ }
+
/**
* Size of the "tree header" in the tree-file The nodes will use this offset
* to know where they should be in the file. This should always be a
*/
void insertInterval(HTInterval interval) throws TimeRangeException;
- /**
- * Inner method to select the next child of the current node intersecting
- * the given timestamp. Useful for moving down the tree following one
- * branch.
- *
- * @param currentNode
- * The node on which the request is made
- * @param t
- * The timestamp to choose which child is the next one
- * @return The child node intersecting t
- * @throws ClosedChannelException
- * If the file channel was closed while we were reading the tree
- */
- HTNode selectNextChild(CoreNode currentNode, long t) throws ClosedChannelException;
-
/**
* Get the current size of the history file.
*
*/
long getFileSize();
- /**
- * Print out the full tree for debugging purposes
- *
- * @param writer
- * PrintWriter in which to write the output
- * @param printIntervals
- * Flag to enable full output of the interval information
- * @param ts
- * The timestamp that nodes have to intersect for intervals to be
- * printed. A negative value will print intervals for all nodes.
- * The timestamp only applies if printIntervals is true.
- */
- void debugPrintFullTree(PrintWriter writer, boolean printIntervals, long ts);
-
}