From: Roland Häder Date: Sat, 5 Dec 2020 22:24:29 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=c1841c5d8ad644456ea408caf315e858d89fc555;p=core.git Continued: - 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 --- diff --git a/application/tests/class_ApplicationHelper.php b/application/tests/class_ApplicationHelper.php index 1a50658d..fc36f6ee 100644 --- a/application/tests/class_ApplicationHelper.php +++ b/application/tests/class_ApplicationHelper.php @@ -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? */ diff --git a/framework/config-global.php b/framework/config-global.php index 12a608c1..d22cbf83 100644 --- a/framework/config-global.php +++ b/framework/config-global.php @@ -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'); diff --git a/framework/main/classes/factories/index/class_FileStackIndexFactory.php b/framework/main/classes/factories/index/class_FileStackIndexFactory.php index 9f4df7f0..b24f2884 100644 --- a/framework/main/classes/factories/index/class_FileStackIndexFactory.php +++ b/framework/main/classes/factories/index/class_FileStackIndexFactory.php @@ -1,6 +1,6 @@ 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))); } /** diff --git a/framework/main/classes/stacker/class_BaseStacker.php b/framework/main/classes/stacker/class_BaseStacker.php index 98e52b39..9e44c9b4 100644 --- a/framework/main/classes/stacker/class_BaseStacker.php +++ b/framework/main/classes/stacker/class_BaseStacker.php @@ -1,6 +1,6 @@ . */ -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), ]; } diff --git a/framework/main/classes/stacker/file/fifo/class_FiFoFileStack.php b/framework/main/classes/stacker/file/fifo/class_FiFoFileStack.php index 466c7e1c..5db1e2af 100644 --- a/framework/main/classes/stacker/file/fifo/class_FiFoFileStack.php +++ b/framework/main/classes/stacker/file/fifo/class_FiFoFileStack.php @@ -1,12 +1,12 @@ . */ 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 diff --git a/framework/main/traits/stacker/class_StackableTrait.php b/framework/main/traits/stacker/class_StackableTrait.php index c693ac89..e6ea1da9 100644 --- a/framework/main/traits/stacker/class_StackableTrait.php +++ b/framework/main/traits/stacker/class_StackableTrait.php @@ -1,9 +1,9 @@ . */ trait StackableTrait { - /** * Instance of the stacker */