Introduced interface Pointer, valid() is now used.
authorRoland Haeder <roland@mxchange.org>
Thu, 22 May 2014 20:29:15 +0000 (22:29 +0200)
committerRoland Haeder <roland@mxchange.org>
Thu, 22 May 2014 20:29:15 +0000 (22:29 +0200)
Signed-off-by: Roland H├Ąder <roland@mxchange.org>
inc/classes/interfaces/io/class_Pointer.php [new file with mode: 0644]
inc/classes/interfaces/io/pointer/class_InputPointer.php
inc/classes/interfaces/io/pointer/class_OutputPointer.php
inc/classes/interfaces/io/pointer/io/class_InputOutputPointer.php
inc/classes/main/index/class_BaseIndex.php
inc/classes/main/iterator/io/class_FileIoIterator.php
inc/classes/main/stacker/file/class_BaseFileStack.php

diff --git a/inc/classes/interfaces/io/class_Pointer.php b/inc/classes/interfaces/io/class_Pointer.php
new file mode 100644 (file)
index 0000000..7b15826
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+/**
+ * An interface for pointers
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2013 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+interface Pointer extends FrameworkInterface {
+       /**
+        * Close a file source and set it's instance to null and the file name
+        * to empty.
+        *
+        * @return      void
+        * @throws      NullPointerException    If the file pointer instance is not set by setPointer()
+        * @throws      InvalidResourceException        If there is being set
+        */
+       function closeFile ();
+
+       /**
+        * Getter for the file pointer
+        *
+        * @return      $filePointer    The file pointer which shall be a valid file resource
+        */
+       function getPointer ();
+
+       /**
+        * Getter for file name
+        *
+        * @return      $fileName       The current file name
+        */
+       function getFileName ();
+}
+
+// [EOF]
+?>
index 0c15cc7..3a53fb1 100644 (file)
@@ -21,7 +21,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
-interface InputPointer extends StreamableInput {
+interface InputPointer extends StreamableInput, Pointer {
        /**
         * Read data a file pointer
         *
index 7d8300e..06c5835 100644 (file)
@@ -21,7 +21,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
-interface OutputPointer extends StreamableOutput {
+interface OutputPointer extends StreamableOutput, Pointer {
        /**
         * Write data to a file pointer
         *
index 8daa22c..93846ff 100644 (file)
@@ -25,7 +25,7 @@ interface InputOutputPointer extends InputPointer, OutputPointer {
        /**
         * Rewinds to the beginning of the file
         *
-        * @return      $status         Status of this operation
+        * @return      $status         Status of this operation
         */
        function rewind ();
 }
index d4a2c6b..bca12f4 100644 (file)
@@ -171,7 +171,10 @@ class BaseIndex extends BaseFrameworkSystem {
                $this->getIteratorInstance()->rewind();
 
                // Then try to load all entries
-               while ($this->getIteratorInstance()->next()) {
+               while ($this->getIteratorInstance()->valid()) {
+                       // Go to next entry
+                       $this->getIteratorInstance()->next();
+
                        // Get current entry
                        $current = $this->getIteratorInstance()->current();
 
index 171c677..3437d11 100644 (file)
@@ -100,8 +100,7 @@ class FileIoIterator extends BaseIterator implements SeekableWritableFileIterato
         * @return      void
         */
        public function valid () {
-               // Call pointer instance
-               return $this->getPointerInstance()->valid();
+               $this->partialStub('Please implement this method.');
        }
 
        /**
index 01193aa..56c3b99 100644 (file)
@@ -193,7 +193,10 @@ class BaseFileStack extends BaseStacker {
                $this->getIteratorInstance()->rewind();
 
                // Then try to load all entries
-               while ($this->getIteratorInstance()->next()) {
+               while ($this->getIteratorInstance()->valid()) {
+                       // Go to next entry
+                       $this->getIteratorInstance()->next();
+
                        // Get current entry
                        $current = $this->getIteratorInstance()->current();