tmf: Remove back-reference from HT-Node to HT-Tree
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / internal / tmf / core / statesystem / backends / historytree / HTNode.java
index f7b47e26bebcec091bee28c0cc7e0801304756c8..2a06d2d116800cf67f90ce632fb59aad2dd77169 100644 (file)
@@ -28,7 +28,7 @@ import org.eclipse.linuxtools.tmf.core.statevalue.TmfStateValue;
 /**
  * The base class for all the types of nodes that go in the History Tree.
  *
- * @author alexmont
+ * @author Alexandre Montplaisir
  */
 abstract class HTNode {
 
@@ -42,8 +42,8 @@ abstract class HTNode {
      */
     protected static final int DATA_ENTRY_SIZE = 25;
 
-    /* Reference to the History Tree to whom this node belongs */
-    private final HistoryTree ownerTree;
+    /* Configuration of the History Tree to which belongs this node */
+    private final HTConfig config;
 
     /* Time range of this node */
     private final long nodeStart;
@@ -62,13 +62,13 @@ abstract class HTNode {
     /* Vector containing all the intervals contained in this node */
     private final List<HTInterval> intervals;
 
-    HTNode(HistoryTree tree, int seqNumber, int parentSeqNumber, long start) {
-        this.ownerTree = tree;
+    HTNode(HTConfig config, int seqNumber, int parentSeqNumber, long start) {
+        this.config = config;
         this.nodeStart = start;
         this.sequenceNumber = seqNumber;
         this.parentSequenceNumber = parentSeqNumber;
 
-        this.stringSectionOffset = ownerTree.getConfig().getBlockSize();
+        this.stringSectionOffset = config.getBlockSize();
         this.isDone = false;
         this.intervals = new ArrayList<HTInterval>();
     }
@@ -77,23 +77,23 @@ abstract class HTNode {
      * Reader factory constructor. Build a Node object (of the right type) by
      * reading a block in the file.
      *
-     * @param tree
-     *            Reference to the HT which will own this node
+     * @param config
+     *            Configuration of the History Tree
      * @param fc
      *            FileChannel to the history file, ALREADY SEEKED at the start
      *            of the node.
      * @throws IOException
      */
-    static final HTNode readNode(HistoryTree tree, FileChannel fc)
+    static final HTNode readNode(HTConfig config, FileChannel fc)
             throws IOException {
         HTNode newNode = null;
         int res, i;
 
-        ByteBuffer buffer = ByteBuffer.allocate(tree.getConfig().getBlockSize());
+        ByteBuffer buffer = ByteBuffer.allocate(config.getBlockSize());
         buffer.order(ByteOrder.LITTLE_ENDIAN);
         buffer.clear();
         res = fc.read(buffer);
-        assert (res == tree.getConfig().getBlockSize());
+        assert (res == config.getBlockSize());
         buffer.flip();
 
         /* Read the common header part */
@@ -110,7 +110,7 @@ abstract class HTNode {
         switch (type) {
         case 1:
             /* Core nodes */
-            newNode = new CoreNode(tree, seqNb, parentSeqNb, start);
+            newNode = new CoreNode(config, seqNb, parentSeqNb, start);
             newNode.readSpecificHeader(buffer);
             break;
 
@@ -146,7 +146,7 @@ abstract class HTNode {
     }
 
     final void writeSelf(FileChannel fc) throws IOException {
-        final int blockSize = ownerTree.getConfig().getBlockSize();
+        final int blockSize = config.getBlockSize();
         int curStringsEntryEndPos = blockSize;
 
         ByteBuffer buffer = ByteBuffer.allocate(blockSize);
@@ -201,8 +201,8 @@ abstract class HTNode {
     // Accessors
     // ------------------------------------------------------------------------
 
-    protected HistoryTree getTree() {
-        return ownerTree;
+    HTConfig getConfig() {
+        return config;
     }
 
     long getNodeStart() {
@@ -413,7 +413,7 @@ abstract class HTNode {
      * (used space / total usable space, which excludes the header)
      */
     long getNodeUsagePRC() {
-        final int blockSize = ownerTree.getConfig().getBlockSize();
+        final int blockSize = config.getBlockSize();
         float freePercent = (float) this.getNodeFreeSpace()
                 / (float) (blockSize - this.getTotalHeaderSize())
                 * 100F;
This page took 0.068169 seconds and 5 git commands to generate.