From: Roland Haeder Date: Sat, 31 May 2014 11:58:57 +0000 (+0200) Subject: This getter needs also to be public and be called through iterator. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=202f8c1c1d46d1292918b7110547952446a53391;p=core.git This getter needs also to be public and be called through iterator. Signed-off-by: Roland Häder --- diff --git a/inc/classes/interfaces/block/class_Block.php b/inc/classes/interfaces/block/class_Block.php index 056785a9..f00e973c 100644 --- a/inc/classes/interfaces/block/class_Block.php +++ b/inc/classes/interfaces/block/class_Block.php @@ -106,6 +106,13 @@ interface Block extends FrameworkInterface { * @return void */ function updateSeekPosition (); + + /** + * Getter for total entries + * + * @return $totalEntries Total entries in this file + */ + function getCounter (); } // [EOF] diff --git a/inc/classes/interfaces/iterator/class_SeekableWritableFileIterator.php b/inc/classes/interfaces/iterator/class_SeekableWritableFileIterator.php index 7a642c7e..674fc626 100644 --- a/inc/classes/interfaces/iterator/class_SeekableWritableFileIterator.php +++ b/inc/classes/interfaces/iterator/class_SeekableWritableFileIterator.php @@ -132,6 +132,13 @@ interface SeekableWritableFileIterator extends SeekableIterator { * @return void */ function updateSeekPosition (); + + /** + * Getter for total entries + * + * @return $totalEntries Total entries in this file + */ + function getCounter (); } // [EOF] diff --git a/inc/classes/main/file_directories/class_BaseFile.php b/inc/classes/main/file_directories/class_BaseFile.php index 72e9dbac..cfefe498 100644 --- a/inc/classes/main/file_directories/class_BaseFile.php +++ b/inc/classes/main/file_directories/class_BaseFile.php @@ -174,7 +174,7 @@ y * @return void * * @return $totalEntries Total entries in this file */ - protected final function getCounter () { + public final function getCounter () { // Get it return $this->totalEntries; } diff --git a/inc/classes/main/index/class_BaseIndex.php b/inc/classes/main/index/class_BaseIndex.php index 016aa3f5..adbb7160 100644 --- a/inc/classes/main/index/class_BaseIndex.php +++ b/inc/classes/main/index/class_BaseIndex.php @@ -115,7 +115,7 @@ class BaseIndex extends BaseFrameworkSystem { chr(BaseFile::SEPARATOR_HEADER_DATA), // Total entries - str_pad($this->dec2hex($this->getCounter()), BaseFile::LENGTH_COUNT, '0', STR_PAD_LEFT), + str_pad($this->dec2hex($this->getIteratorInstance()->getCounter()), BaseFile::LENGTH_COUNT, '0', STR_PAD_LEFT), // Separator header<->entries chr(BaseFile::SEPARATOR_HEADER_ENTRIES) @@ -285,6 +285,17 @@ class BaseIndex extends BaseFrameworkSystem { public function updateSeekPosition () { throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); } + + /** + * Getter for total entries + * + * @return $totalEntries Total entries in this file + * @throws UnsupportedOperationException This method is not (and maybe never will be) supported + */ + public final function getCounter () { + throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); + } + } // [EOF] diff --git a/inc/classes/main/iterator/file/class_FileIterator.php b/inc/classes/main/iterator/file/class_FileIterator.php index 35ceedd7..b40ef6b4 100644 --- a/inc/classes/main/iterator/file/class_FileIterator.php +++ b/inc/classes/main/iterator/file/class_FileIterator.php @@ -258,6 +258,16 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator // Call block instance $this->getBlockInstance()->updateSeekPosition(); } + + /** + * Getter for total entries + * + * @return $totalEntries Total entries in this file + */ + public final function getCounter () { + // Call block instance + return $this->getBlockInstance()->getCounter(); + } } // [EOF] diff --git a/inc/classes/main/stacker/file/class_BaseFileStack.php b/inc/classes/main/stacker/file/class_BaseFileStack.php index 6379821f..6b50a6e0 100644 --- a/inc/classes/main/stacker/file/class_BaseFileStack.php +++ b/inc/classes/main/stacker/file/class_BaseFileStack.php @@ -120,7 +120,7 @@ class BaseFileStack extends BaseStacker { chr(BaseFile::SEPARATOR_HEADER_DATA), // Total entries (will be zero) and pad it to 20 chars - str_pad($this->dec2hex($this->getCounter()), BaseFile::LENGTH_COUNT, '0', STR_PAD_LEFT), + str_pad($this->dec2hex($this->getIteratorInstance()->getCounter()), BaseFile::LENGTH_COUNT, '0', STR_PAD_LEFT), // Separator count<->seek position chr(BaseFile::SEPARATOR_HEADER_DATA), @@ -400,7 +400,7 @@ class BaseFileStack extends BaseStacker { */ public function getStackCount ($stackerName) { // Now, simply return the found count value, this must be up-to-date then! - return $this->getCounter(); + return $this->getIteratorInstance()->getCounter(); } /** @@ -480,6 +480,17 @@ class BaseFileStack extends BaseStacker { public function updateSeekPosition () { throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); } + + /** + * Getter for total entries + * + * @return $totalEntries Total entries in this file + * @throws UnsupportedOperationException This method is not (and maybe never will be) supported + */ + public final function getCounter () { + throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); + } + } // [EOF]