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 0c15cc7b07b7f0620e0c7003bd01bbf77c255263..3a53fb18dbb1a9cb0315b5db86171e88f047e1f6 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 7d8300eebf50f0385207e42e898c2771315e4bc4..06c5835fa836f49279d3d56e715b8f3adc0e16a6 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 8daa22c7409c0501fe8b117d96213788f2c2819d..93846ff7311813ecb80372d66a6b8c663b0c4256 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 d4a2c6b6023d0a5ce4532e573750eb53486f1e26..bca12f4a0093d24c92f8adcfbb70c1f8c389147c 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 171c6777f66f00b314b70c529af2753ca9c3b9fb..3437d1165902af54a1cc557527ec90cdd924844a 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 01193aab761de4e2eadbda4216d3100bafcbeede..56c3b99d4b7539cfce89f814448953fa90d6f68d 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();