]> git.mxchange.org Git - core.git/blobdiff - framework/main/classes/stacker/file/class_BaseFileStack.php
Some updates:
[core.git] / framework / main / classes / stacker / file / class_BaseFileStack.php
index b81d140d11e908b492883995b2e478e5e7cabf37..8bf35ac9aab88d04dcf03d01b8cddd5c1fb65701 100644 (file)
@@ -1,18 +1,28 @@
 <?php
 // Own namespace
-namespace CoreFramework\Stack\File;
+namespace Org\Mxchange\CoreFramework\Stacker\Filesystem;
 
 // Import framework stuff
-use CoreFramework\Factory\ObjectFactory;
-use CoreFramework\Filesystem\File\BaseBinaryFile;
-use CoreFramework\Iterator\Filesystem\SeekableWritableFileIterator;
+use Org\Mxchange\CoreFramework\Factory\Filesystem\Stack\FileStackIndexFactory;
+use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
+use Org\Mxchange\CoreFramework\Filesystem\File\BaseBinaryFile;
+use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
+use Org\Mxchange\CoreFramework\Iterator\Filesystem\SeekableWritableFileIterator;
+use Org\Mxchange\CoreFramework\Stacker\BaseStacker;
+
+// Import SPL stuff
+use \SplFileInfo;
 
 /**
  * A general file-based stack class
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
+<<<<<<< HEAD:framework/main/classes/stacker/file/class_BaseFileStack.php
  * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
+=======
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team
+>>>>>>> Some updates::inc/main/classes/stacker/file/class_BaseFileStack.php
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.ship-simu.org
  *
@@ -29,7 +39,7 @@ use CoreFramework\Iterator\Filesystem\SeekableWritableFileIterator;
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
-class BaseFileStack extends BaseStacker {
+abstract class BaseFileStack extends BaseStacker {
        /**
         * Magic for this stack
         */
@@ -105,7 +115,7 @@ class BaseFileStack extends BaseStacker {
                $this->getIteratorInstance()->setHeader($header);
 
                // Check if the array has only 3 elements
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d:] header(%d)=%s', __METHOD__, __LINE__, count($header), print_r($header, TRUE)));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d:] header(%d)=%s', __METHOD__, __LINE__, count($header), print_r($header, true)));
                assert(count($header) == 3);
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d:] Passed assert().', __METHOD__, __LINE__));
 
@@ -156,7 +166,7 @@ class BaseFileStack extends BaseStacker {
                );
 
                // Write it to disk (header is always at seek position 0)
-               $this->getIteratorInstance()->writeData(0, $header, FALSE);
+               $this->getIteratorInstance()->writeData(0, $header, false);
 
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d:] EXIT!', __METHOD__, __LINE__));
        }
@@ -164,14 +174,14 @@ class BaseFileStack extends BaseStacker {
        /**
         * Initializes this file-based stack.
         *
-        * @param       $fileName       File name of this stack
+        * @param       $fileInfoInstance       An instance of a SplFileInfo class
         * @param       $type           Type of this stack (e.g. url_source for URL sources)
         * @return      void
         * @todo        Currently the stack file is not cached, please implement a memory-handling class and if enough RAM is found, cache the whole stack file.
         */
-       protected function initFileStack ($fileName, $type) {
+       protected function initFileStack (SplFileInfo $fileInfoInstance, $type) {
                // Get a stack file instance
-               $fileInstance = ObjectFactory::createObjectByConfiguredName('stack_file_class', array($fileName, $this));
+               $fileInstance = ObjectFactory::createObjectByConfiguredName('stack_file_class', array($fileInfoInstance, $this));
 
                // Get iterator instance
                $iteratorInstance = ObjectFactory::createObjectByConfiguredName('file_iterator_class', array($fileInstance));
@@ -214,7 +224,7 @@ class BaseFileStack extends BaseStacker {
                 * Get stack index instance. This can be used for faster
                 * "defragmentation" and startup.
                 */
-               $indexInstance = FileStackIndexFactory::createFileStackIndexInstance($fileName, $type);
+               $indexInstance = FileStackIndexFactory::createFileStackIndexInstance($fileInfoInstance, $type);
 
                // And set it here
                $this->setIndexInstance($indexInstance);
@@ -236,7 +246,7 @@ class BaseFileStack extends BaseStacker {
                } // END - if
 
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] stackerName=' . $stackerName . ',value[' . gettype($value) . ']=' . print_r($value, TRUE));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] stackerName=' . $stackerName . ',value[' . gettype($value) . ']=' . print_r($value, true));
 
                // No objects/resources are allowed as their serialization takes to long
                assert(!is_object($value));
@@ -342,8 +352,8 @@ class BaseFileStack extends BaseStacker {
         */
        protected function isStackFull ($stackerName) {
                // File-based stacks will only run full if the disk space is low.
-               // @TODO Please implement this, returning FALSE
-               $isFull = FALSE;
+               // @TODO Please implement this, returning false
+               $isFull = false;
 
                // Return result
                return $isFull;
@@ -372,7 +382,7 @@ class BaseFileStack extends BaseStacker {
         * @return      void
         * @throws      UnsupportedOperationException   This method is not (and maybe never will be) supported
         */
-       public function initStack ($stackerName, $forceReInit = FALSE) {
+       public function initStack ($stackerName, $forceReInit = false) {
                throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION);
        }
 
@@ -382,7 +392,7 @@ class BaseFileStack extends BaseStacker {
         * @return      void
         * @throws      UnsupportedOperationException   This method is not (and maybe never will be) supported
         */
-       public function initStacks (array $stacks, $forceReInit = FALSE) {
+       public function initStacks (array $stacks, $forceReInit = false) {
                throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION);
        }
 
@@ -407,16 +417,6 @@ class BaseFileStack extends BaseStacker {
                throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION);
        }
 
-       /**
-        * Getter for file name
-        *
-        * @return      $fileName       The current file name
-        * @throws      UnsupportedOperationException   This method is not (and maybe never will be) supported
-        */
-       public function getFileName () {
-               throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION);
-       }
-
        /**
         * Getter for size of given stack (array count)
         *
@@ -531,7 +531,7 @@ class BaseFileStack extends BaseStacker {
         * @return      void
         * @throws      UnsupportedOperationException   This method is not (and maybe never will be) supported
         */
-       public function writeData ($seekPosition, $data, $flushHeader = TRUE) {
+       public function writeData ($seekPosition, $data, $flushHeader = true) {
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d:] seekPosition=%s,data[]=%s,flushHeader=%d', __METHOD__, __LINE__, $seekPosition, gettype($data), intval($flushHeader)));
                throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION);
        }
@@ -545,7 +545,7 @@ class BaseFileStack extends BaseStacker {
         * @throws      UnsupportedOperationException   This method is not (and maybe never will be) supported
         */
        public function writeValueToFile ($groupId, $value) {
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d:] groupId=%s,value[%s]=%s', __METHOD__, __LINE__, $groupId, gettype($value), print_r($value, TRUE)));
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d:] groupId=%s,value[%s]=%s', __METHOD__, __LINE__, $groupId, gettype($value), print_r($value, true)));
                throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION);
        }