From: Roland Haeder Date: Thu, 22 May 2014 20:29:15 +0000 (+0200) Subject: Introduced interface Pointer, valid() is now used. X-Git-Url: https://git.mxchange.org/?p=core.git;a=commitdiff_plain;h=a863937b246c06e143d147fe4108543056971472 Introduced interface Pointer, valid() is now used. Signed-off-by: Roland Häder --- diff --git a/inc/classes/interfaces/io/class_Pointer.php b/inc/classes/interfaces/io/class_Pointer.php new file mode 100644 index 00000000..7b158263 --- /dev/null +++ b/inc/classes/interfaces/io/class_Pointer.php @@ -0,0 +1,51 @@ + + * @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 . + */ +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] +?> diff --git a/inc/classes/interfaces/io/pointer/class_InputPointer.php b/inc/classes/interfaces/io/pointer/class_InputPointer.php index 0c15cc7b..3a53fb18 100644 --- a/inc/classes/interfaces/io/pointer/class_InputPointer.php +++ b/inc/classes/interfaces/io/pointer/class_InputPointer.php @@ -21,7 +21,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -interface InputPointer extends StreamableInput { +interface InputPointer extends StreamableInput, Pointer { /** * Read data a file pointer * diff --git a/inc/classes/interfaces/io/pointer/class_OutputPointer.php b/inc/classes/interfaces/io/pointer/class_OutputPointer.php index 7d8300ee..06c5835f 100644 --- a/inc/classes/interfaces/io/pointer/class_OutputPointer.php +++ b/inc/classes/interfaces/io/pointer/class_OutputPointer.php @@ -21,7 +21,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -interface OutputPointer extends StreamableOutput { +interface OutputPointer extends StreamableOutput, Pointer { /** * Write data to a file pointer * diff --git a/inc/classes/interfaces/io/pointer/io/class_InputOutputPointer.php b/inc/classes/interfaces/io/pointer/io/class_InputOutputPointer.php index 8daa22c7..93846ff7 100644 --- a/inc/classes/interfaces/io/pointer/io/class_InputOutputPointer.php +++ b/inc/classes/interfaces/io/pointer/io/class_InputOutputPointer.php @@ -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 (); } diff --git a/inc/classes/main/index/class_BaseIndex.php b/inc/classes/main/index/class_BaseIndex.php index d4a2c6b6..bca12f4a 100644 --- a/inc/classes/main/index/class_BaseIndex.php +++ b/inc/classes/main/index/class_BaseIndex.php @@ -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(); diff --git a/inc/classes/main/iterator/io/class_FileIoIterator.php b/inc/classes/main/iterator/io/class_FileIoIterator.php index 171c6777..3437d116 100644 --- a/inc/classes/main/iterator/io/class_FileIoIterator.php +++ b/inc/classes/main/iterator/io/class_FileIoIterator.php @@ -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.'); } /** diff --git a/inc/classes/main/stacker/file/class_BaseFileStack.php b/inc/classes/main/stacker/file/class_BaseFileStack.php index 01193aab..56c3b99d 100644 --- a/inc/classes/main/stacker/file/class_BaseFileStack.php +++ b/inc/classes/main/stacker/file/class_BaseFileStack.php @@ -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();