]> git.mxchange.org Git - core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sat, 5 Dec 2020 22:24:29 +0000 (23:24 +0100)
committerRoland Häder <roland@mxchange.org>
Sat, 5 Dec 2020 22:24:29 +0000 (23:24 +0100)
- renamed some namespaces
- renamed BaseFileStack::ARRAY_INDEX_* to ARRAY_NAME_* as these constants
  contain names and not numbers
- also moved them to interface StackableFile

Signed-off-by: Roland Häder <roland@mxchange.org>
17 files changed:
application/tests/class_ApplicationHelper.php
framework/config-global.php
framework/main/classes/factories/index/class_FileStackIndexFactory.php
framework/main/classes/file_directories/binary/stack/class_StackFile.php
framework/main/classes/index/file_stack/class_FileStackIndex.php
framework/main/classes/stacker/class_BaseStacker.php
framework/main/classes/stacker/fifo/class_FiFoStacker.php
framework/main/classes/stacker/file/class_BaseFileStack.php
framework/main/classes/stacker/file/fifo/class_FiFoFileStack.php
framework/main/classes/stacker/filo/class_FiLoStacker.php
framework/main/classes/template/menu/class_MenuTemplateEngine.php
framework/main/classes/template/xml/class_BaseXmlTemplateEngine.php
framework/main/exceptions/stacker/class_InvalidMagicException.php
framework/main/interfaces/index/stack/class_IndexableStack.php
framework/main/interfaces/stacker/class_Stackable.php
framework/main/interfaces/stacker/file/class_StackableFile.php
framework/main/traits/stacker/class_StackableTrait.php

index 1a50658da674f3143b8cfe259b4dca0ba2d10f38..fc36f6ee808551670377bdecdac3839a2eca614a 100644 (file)
@@ -190,7 +190,7 @@ class ApplicationHelper extends BaseApplication implements ManageableApplication
        /**
         * Assigns extra application-depending data
         *
-        * @param       $templateInstance       An instance of a CompileableTemplate
+        * @param       $templateInstance       An instance of a CompileableTemplate class
         * @return      void
         * @todo        Nothing to add?
         */
index 12a608c1511fa23d0e52bf2e0805958a1ee8b9bc..d22cbf83af67ae82c57d22b915b90414223656c5 100644 (file)
@@ -317,7 +317,7 @@ $cfg->setConfigEntry('product_install_mode', 'debug');
 $cfg->setConfigEntry('decimals', 3);
 
 // CFG: MENU-STACKER-CLASS
-$cfg->setConfigEntry('menu_stacker_class', 'Org\Mxchange\CoreFramework\Stacker\FiLoStacker');
+$cfg->setConfigEntry('menu_stacker_class', 'Org\Mxchange\CoreFramework\Stack\FiLoStacker');
 
 // CFG: STACKER-GENERIC-MAX-SIZE
 $cfg->setConfigEntry('stacker_generic_max_size', 100);
@@ -395,7 +395,7 @@ $cfg->setConfigEntry('index_pre_allocate_enabled', 'Y');
 $cfg->setConfigEntry('index_pre_allocate_count', 10000);
 
 // CFG: STACK-FILE-CLASS
-$cfg->setConfigEntry('stack_file_class', 'Org\Mxchange\CoreFramework\Filesystem\Stack\StackFile');
+$cfg->setConfigEntry('stack_file_class', 'Org\Mxchange\CoreFramework\Stack\File\StackFile');
 
 // CFG: INDEX-FILE-CLASS
 $cfg->setConfigEntry('index_file_class', 'Org\Mxchange\CoreFramework\Filesystem\Index\IndexFile');
index 9f4df7f074be59ff5c1ea8096c1819f4fff0d56c..b24f28847d78e7c150f6f57d4f822d5efcf83ffa 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // Own namespace
-namespace Org\Mxchange\CoreFramework\Factory\Filesystem\Stack;
+namespace Org\Mxchange\CoreFramework\Factory\Stack\File;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
index d63af06daf8024a7a0ce1932d7e3e3be8acdc893..86c800a2e3ac4ce8071d798563938508f10f1088 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // Own namespace
-namespace Org\Mxchange\CoreFramework\Filesystem\Stack;
+namespace Org\Mxchange\CoreFramework\Stack\File;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Filesystem\Block;
index 218b9b74f4e8e8d44fdd9b9b8913ed211a747555..952f1afbf4eca5b6b834f18eb77a7d51671abd51 100644 (file)
@@ -6,8 +6,8 @@ namespace Org\Mxchange\CoreFramework\Index\Stack;
 use Org\Mxchange\CoreFramework\Index\BaseIndex;
 use Org\Mxchange\CoreFramework\Index\Indexable;
 use Org\Mxchange\CoreFramework\Registry\Registerable;
-use Org\Mxchange\CoreFramework\Stacker\Filesystem\BaseFileStack;
-use Org\Mxchange\CoreFramework\Stacker\Index\IndexableStack;
+use Org\Mxchange\CoreFramework\Stack\File\StackableFile;
+use Org\Mxchange\CoreFramework\Stack\Index\IndexableStack;
 
 // Import SPL stuff
 use \InvalidArgumentException;
@@ -74,19 +74,19 @@ class FileStackIndex extends BaseIndex implements IndexableStack, Registerable {
         */
        public function addHashToIndex (string $groupId, array $data) {
                // Raw data been written to the file
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-STACK-INDEX: groupId=%s,hash=%s,gap=%d,length=%d - CALLED!', $groupId, $data[BaseFileStack::ARRAY_INDEX_HASH], $data[BaseFileStack::ARRAY_INDEX_GAP_POSITION], $data[BaseFileStack::ARRAY_INDEX_DATA_LENGTH]));
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-STACK-INDEX: groupId=%s,hash=%s,gap=%d,length=%d - CALLED!', $groupId, $data[StackableFile::ARRAY_NAME_HASH], $data[StackableFile::ARRAY_NAME_GAP_POSITION], $data[StackableFile::ARRAY_NAME_DATA_LENGTH]));
                $rawData = sprintf('%s%s%s%s%s%s%s',
                        $groupId,
                        self::SEPARATOR_GROUP_HASH,
-                       hex2bin($data[BaseFileStack::ARRAY_INDEX_HASH]),
+                       hex2bin($data[StackableFile::ARRAY_NAME_HASH]),
                        self::SEPARATOR_HASH_GAP_POSITION,
-                       $data[BaseFileStack::ARRAY_INDEX_GAP_POSITION],
+                       $data[StackableFile::ARRAY_NAME_GAP_POSITION],
                        self::SEPARATOR_GAP_LENGTH,
-                       $data[BaseFileStack::ARRAY_INDEX_DATA_LENGTH]
+                       $data[StackableFile::ARRAY_NAME_DATA_LENGTH]
                );
 
                // Debug message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-STACK-INDEX: groupId=%s,hash=%s,rawData()=%d', $groupId, $data[BaseFileStack::ARRAY_INDEX_HASH], strlen($rawData)));
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-STACK-INDEX: groupId=%s,hash=%s,rawData()=%d', $groupId, $data[StackableFile::ARRAY_NAME_HASH], strlen($rawData)));
 
                // Search for next free gap
                $gapPosition = $this->getIteratorInstance()->searchNextGap(strlen($rawData));
@@ -95,11 +95,11 @@ class FileStackIndex extends BaseIndex implements IndexableStack, Registerable {
                assert($gapPosition > $this->getIteratorInstance()->getHeaderSize());
 
                // Then write the data at that gap
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-STACK-INDEX: groupId=%s,hash=%s,gapPosition=%s', $groupId, $data[BaseFileStack::ARRAY_INDEX_HASH], $gapPosition));
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-STACK-INDEX: groupId=%s,hash=%s,gapPosition=%s', $groupId, $data[StackableFile::ARRAY_NAME_HASH], $gapPosition));
                $this->getIteratorInstance()->writeData($gapPosition, $rawData);
 
                // Trace message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-STACK-INDEX: groupId=%s,hash=%s,rawData()=%d - EXIT!', $groupId, $data[BaseFileStack::ARRAY_INDEX_HASH], strlen($rawData)));
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-STACK-INDEX: groupId=%s,hash=%s,rawData()=%d - EXIT!', $groupId, $data[StackableFile::ARRAY_NAME_HASH], strlen($rawData)));
        }
 
        /**
index 98e52b39844c4d45010c8e4ddc860655e33a763a..9e44c9b47b4ea82dcf28998db5529f0495a4c49a 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // Own namespace
-namespace Org\Mxchange\CoreFramework\Stacker;
+namespace Org\Mxchange\CoreFramework\Stack;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
index 8e553e7fd7aa68eb78daa3d746bb68da89971248..1e4743f8390673cbf301bc9941d74527c08c64e8 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // Own namespace
-namespace Org\Mxchange\CoreFramework\Stacker;
+namespace Org\Mxchange\CoreFramework\Stack;
 
 /**
  * A FiFo Stacker class
index 7bf00c4f674866427423a5ebd6f6b8de838cb905..a5a2eaa69d76f30d7ff437ed9586919073a832d9 100644 (file)
@@ -1,16 +1,17 @@
 <?php
 // Own namespace
-namespace Org\Mxchange\CoreFramework\Stacker\Filesystem;
+namespace Org\Mxchange\CoreFramework\Stack\File;
 
 // Import framework stuff
-use Org\Mxchange\CoreFramework\Factory\Filesystem\Stack\FileStackIndexFactory;
+use Org\Mxchange\CoreFramework\Factory\Stack\File\FileStackIndexFactory;
 use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
-use Org\Mxchange\CoreFramework\FileStack\InvalidMagicException;
 use Org\Mxchange\CoreFramework\Filesystem\File\BaseBinaryFile;
 use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
 use Org\Mxchange\CoreFramework\Index\Indexable;
 use Org\Mxchange\CoreFramework\Iterator\Filesystem\SeekableWritableFileIterator;
-use Org\Mxchange\CoreFramework\Stacker\BaseStacker;
+use Org\Mxchange\CoreFramework\Stack\BaseStacker;
+use Org\Mxchange\CoreFramework\Stack\File\InvalidMagicException;
+use Org\Mxchange\CoreFramework\Stack\File\StackableFile;
 use Org\Mxchange\CoreFramework\Traits\Iterator\IteratorTrait;
 use Org\Mxchange\CoreFramework\Utils\String\StringUtils;
 
@@ -40,33 +41,13 @@ use \UnexpectedValueException;
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
-abstract class BaseFileStack extends BaseStacker {
+abstract class BaseFileStack extends BaseStacker implements StackableFile {
        // Load traits
        use IteratorTrait;
 
        // Exception codes
        const EXCEPTION_BAD_MAGIC = 0xe100;
 
-       /**
-        * Magic for this stack
-        */
-       const STACK_MAGIC = 'STACKv0.1';
-
-       /**
-        * Name of array index for gap position
-        */
-       const ARRAY_INDEX_GAP_POSITION = 'gap';
-
-       /**
-        * Name of array index for hash
-        */
-       const ARRAY_INDEX_HASH = 'hash';
-
-       /**
-        * Name of array index for length of raw data
-        */
-       const ARRAY_INDEX_DATA_LENGTH = 'length';
-
        /**
         * An instance of an Indexable class
         */
@@ -162,7 +143,7 @@ abstract class BaseFileStack extends BaseStacker {
                                $data,
                                count($header)
                        ));
-               } elseif ($header[0] != self::STACK_MAGIC) {
+               } elseif ($header[0] != StackableFile::STACK_MAGIC) {
                        // Bad magic
                        throw new InvalidMagicException($data, self::EXCEPTION_BAD_MAGIC);
                }
@@ -205,7 +186,7 @@ abstract class BaseFileStack extends BaseStacker {
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: CALLED!', __METHOD__, __LINE__));
                $header = sprintf('%s%s%s%s%s%s',
                        // Magic
-                       self::STACK_MAGIC,
+                       StackableFile::STACK_MAGIC,
 
                        // Separator magic<->count
                        chr(BaseBinaryFile::SEPARATOR_HEADER_DATA),
@@ -251,7 +232,7 @@ abstract class BaseFileStack extends BaseStacker {
 
                // Calculate header size
                $this->getIteratorInstance()->setHeaderSize(
-                       strlen(self::STACK_MAGIC) +
+                       strlen(StackableFile::STACK_MAGIC) +
                        strlen(chr(BaseBinaryFile::SEPARATOR_HEADER_DATA)) +
                        BaseBinaryFile::LENGTH_COUNT +
                        strlen(chr(BaseBinaryFile::SEPARATOR_HEADER_DATA)) +
@@ -668,9 +649,9 @@ abstract class BaseFileStack extends BaseStacker {
                // Return gap position, hash and length of raw data
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: groupId=%s,hash=%s,rawData()=%d - EXIT!', $groupId, $hash, strlen($rawData)));
                return [
-                       self::ARRAY_INDEX_GAP_POSITION => $gapPosition,
-                       self::ARRAY_INDEX_HASH         => $hash,
-                       self::ARRAY_INDEX_DATA_LENGTH  => strlen($rawData),
+                       self::ARRAY_NAME_GAP_POSITION => $gapPosition,
+                       self::ARRAY_NAME_HASH         => $hash,
+                       self::ARRAY_NAME_DATA_LENGTH  => strlen($rawData),
                ];
        }
 
index 466c7e1c8df645686cef4c6891bbb28a1d74f36e..5db1e2af0068fe64855161f58e1497d30b0cca02 100644 (file)
@@ -1,12 +1,12 @@
 <?php
 // Own namespace
-namespace Org\Mxchange\CoreFramework\Stacker\Filesystem;
+namespace Org\Mxchange\CoreFramework\Stack\File;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Filesystem\Block\CalculatableBlock;
-use Org\Mxchange\CoreFramework\Filesystem\Stack\StackableFile;
 use Org\Mxchange\CoreFramework\Registry\Registerable;
-use Org\Mxchange\CoreFramework\Stacker\Filesystem\BaseFileStack;
+use Org\Mxchange\CoreFramework\Stack\File\BaseFileStack;
+use Org\Mxchange\CoreFramework\Stack\File\StackableFile;
 
 // Import SPL stuff
 use \SplFileInfo;
index d48f0f5d091ed5b3de1758bcf3cf8bf01e1baefa..78c61013dd79e571e066182a968aaadb10e496d8 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // Own namespace
-namespace Org\Mxchange\CoreFramework\Stacker;
+namespace Org\Mxchange\CoreFramework\Stack;
 
 /**
  * A FiLo Stacker class
index 943b6a85c95f199e60254671337904145038001b..8d653dbdec7886448bd8f2605ad7ce0aec5f61bc 100644 (file)
@@ -11,7 +11,7 @@ use Org\Mxchange\CoreFramework\Parser\Parseable;
 use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
 use Org\Mxchange\CoreFramework\Template\Engine\BaseTemplateEngine;
 use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
-use Org\Mxchange\CoreFramework\Traits\Stacker\StackableTrait;
+use Org\Mxchange\CoreFramework\Traits\Stack\StackableTrait;
 use Org\Mxchange\CoreFramework\Utils\String\StringUtils;
 
 // Import SPL stuff
index 84680b8d5dee4dc5688cf194491c06c4d03cbcf6..6789a5629ebca79ed3a6efb48b4716a458f69178 100644 (file)
@@ -10,7 +10,7 @@ use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
 use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
 use Org\Mxchange\CoreFramework\Template\Engine\BaseTemplateEngine;
 use Org\Mxchange\CoreFramework\Template\Xml\CompileableXmlTemplate;
-use Org\Mxchange\CoreFramework\Traits\Stacker\StackableTrait;
+use Org\Mxchange\CoreFramework\Traits\Stack\StackableTrait;
 use Org\Mxchange\CoreFramework\Traits\Template\CompileableTemplateTrait;
 use Org\Mxchange\CoreFramework\Utils\String\StringUtils;
 
index ade8fe2f31a7391a60c1099ac8e98954a1a69c6d..54f3f697c4f9648f26dc1c6dc9e0701d2392162d 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // Own namespace
-namespace Org\Mxchange\CoreFramework\FileStack;
+namespace Org\Mxchange\CoreFramework\Stack\File;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Generic\FrameworkException;
@@ -40,7 +40,7 @@ class InvalidMagicException extends FrameworkException {
                $message = sprintf('data(%d)=%s has a bad magic, expected: %s',
                        strlen($data),
                        $data,
-                       BaseFileStack::STACK_MAGIC
+                       StackableFile::STACK_MAGIC
                );
 
                // Call parent exception constructor
index e00925e406d3f44e7750d032bbc3d76fb98a45c7..bcc39b660569af4380c6f8907d0e3ea29a564d86 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // Own namespace
-namespace Org\Mxchange\CoreFramework\Stacker\Index;
+namespace Org\Mxchange\CoreFramework\Stack\Index;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Filesystem\Block\CalculatableBlock;
index 402aed93201f8ff00ae85e0192e4933a539234a9..3a2ddb2cacff27a16afa06161c1a6d3163e65c4c 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // Own namespace
-namespace Org\Mxchange\CoreFramework\Stacker;
+namespace Org\Mxchange\CoreFramework\Stack;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
index edcdfe650b5c01b3e62c35ff49ce26a83dad33a7..0d35c82b36c09ee88d87c66288e645474a1da5b8 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 // Own namespace
-namespace Org\Mxchange\CoreFramework\Filesystem\Stack;
+namespace Org\Mxchange\CoreFramework\Stack\File;
 
 // Import framework stuff
-use Org\Mxchange\CoreFramework\Stacker\Stackable;
+use Org\Mxchange\CoreFramework\Stack\Stackable;
 
 /**
  * A Stackable file interface
@@ -28,13 +28,33 @@ use Org\Mxchange\CoreFramework\Stacker\Stackable;
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 interface StackableFile extends Stackable {
+       /**
+        * Magic for this stack
+        */
+       const STACK_MAGIC = 'STACKv0.1';
+
+       /**
+        * Name of array index for gap position
+        */
+       const ARRAY_NAME_GAP_POSITION = 'gap';
+
+       /**
+        * Name of array index for hash
+        */
+       const ARRAY_NAME_HASH = 'hash';
+
+       /**
+        * Name of array index for length of raw data
+        */
+       const ARRAY_NAME_DATA_LENGTH = 'length';
+
        /**
         * Seeks to given position
         *
         * @param       $seekPosition   Seek position in file
         * @return      $status                 Status of this operation
         */
-       function seek ($seekPosition);
+       function seek (int $seekPosition);
 
        /**
         * Size of file stack
index c693ac897d7218538bfb56237d7ad66d23781da4..e6ea1da9bbfbbab94b41f97f0e24d96e63c48433 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 // Own namespace
-namespace Org\Mxchange\CoreFramework\Traits\Stacker;
+namespace Org\Mxchange\CoreFramework\Traits\Stack;
 
 // Import framework stuff
-use Org\Mxchange\CoreFramework\Stacker\Stackable;
+use Org\Mxchange\CoreFramework\Stack\Stackable;
 
 /**
  * A trait for stacker
@@ -28,7 +28,6 @@ use Org\Mxchange\CoreFramework\Stacker\Stackable;
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 trait StackableTrait {
-
        /**
         * Instance of the stacker
         */