Call these methods from the iterator.
authorRoland Haeder <roland@mxchange.org>
Sat, 24 May 2014 13:49:09 +0000 (15:49 +0200)
committerRoland Haeder <roland@mxchange.org>
Sat, 24 May 2014 13:49:09 +0000 (15:49 +0200)
Signed-off-by: Roland H├Ąder <roland@mxchange.org>
inc/classes/main/file_directories/class_BaseFile.php
inc/classes/main/file_directories/index/class_IndexFile.php
inc/classes/main/file_directories/stack/class_StackFile.php
inc/classes/main/iterator/file/class_FileIterator.php
inc/classes/main/stacker/file/class_BaseFileStack.php

index cf36937..d65bbd3 100644 (file)
@@ -470,7 +470,7 @@ y    * @return      void
                } // END - if
 
                // Make sure the block instance is set
-               assert($this->getBlockInstance() instanceof CalculatableBlock);
+               assert($this->getBlockInstance() instanceof Block);
 
                // First calculate minimum block length
                $length = $this->getBlockInstance()->calculateMinimumBlockLength();
@@ -523,7 +523,7 @@ y    * @return      void
         */
        public function valid () {
                // Make sure the block instance is set
-               assert($this->getBlockInstance() instanceof CalculatableBlock);
+               assert($this->getBlockInstance() instanceof Block);
 
                // First calculate minimum block length
                $length = $this->getBlockInstance()->calculateMinimumBlockLength();
@@ -572,6 +572,9 @@ y    * @return      void
         * @return      void
         */
        public function readFileHeader () {
+               // Make sure the block instance is set
+               assert($this->getBlockInstance() instanceof Block);
+
                // Call block instance
                $this->getBlockInstance()->readFileHeader();
        }
@@ -582,6 +585,9 @@ y    * @return      void
         * @return      void
         */
        public function flushFileHeader () {
+               // Make sure the block instance is set
+               assert($this->getBlockInstance() instanceof Block);
+
                // Call block instance
                $this->getBlockInstance()->flushFileHeader();
        }
index 592c4fe..c3190a1 100644 (file)
@@ -36,10 +36,10 @@ class IndexFile extends BaseFile implements Block {
         * Creates an instance of this File class and prepares it for usage
         *
         * @param       $fileName               Name of the index file
-        * @param       $blockInstance  An instance of a CalculatableBlock class
+        * @param       $blockInstance  An instance of a Block class
         * @return      $fileInstance   An instance of this File class
         */
-       public final static function createIndexFile ($fileName, CalculatableBlock $blockInstance) {
+       public final static function createIndexFile ($fileName, Block $blockInstance) {
                // Get a new instance
                $fileInstance = new IndexFile();
 
index df0bec7..863362c 100644 (file)
@@ -36,10 +36,10 @@ class StackFile extends BaseFile implements Block {
         * Creates an instance of this File class and prepares it for usage
         *
         * @param       $fileName               Name of the stack file
-        * @param       $blockInstance  An instance of a CalculatableBlock class
+        * @param       $blockInstance  An instance of a Block class
         * @return      $fileInstance   An instance of this File class
         */
-       public final static function createStackFile ($fileName, CalculatableBlock $blockInstance) {
+       public final static function createStackFile ($fileName, Block $blockInstance) {
                // Get a new instance
                $fileInstance = new StackFile();
 
index 8d8e77f..712754a 100644 (file)
@@ -43,6 +43,7 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
                $iteratorInstance = new FileIterator();
 
                // Set the instance here
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d] Setting blockInstance=%s ...', __METHOD__, __LINE__, $blockInstance->__toString()));
                $iteratorInstance->setBlockInstance($blockInstance);
 
                // Return the prepared instance
index 2b2f53b..5d055bb 100644 (file)
@@ -173,12 +173,12 @@ class BaseFileStack extends BaseStacker {
                $this->setIteratorInstance($iteratorInstance);
 
                // Is the file's header initialized?
-               if (!$this->isFileHeaderInitialized()) {
+               if (!$this->getIteratorInstance()->isFileHeaderInitialized()) {
                        // No, then create it (which may pre-allocate the stack)
-                       $this->createFileHeader();
+                       $this->getIteratorInstance()->createFileHeader();
 
                        // And pre-allocate a bit
-                       $this->preAllocateFile('file_stack');
+                       $this->getIteratorInstance()->preAllocateFile('file_stack');
                } // END - if
 
                // Load the file header