/**
* 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?
*/
$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);
$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');
<?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;
<?php
// Own namespace
-namespace Org\Mxchange\CoreFramework\Filesystem\Stack;
+namespace Org\Mxchange\CoreFramework\Stack\File;
// Import framework stuff
use Org\Mxchange\CoreFramework\Filesystem\Block;
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;
*/
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));
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)));
}
/**
<?php
// Own namespace
-namespace Org\Mxchange\CoreFramework\Stacker;
+namespace Org\Mxchange\CoreFramework\Stack;
// Import framework stuff
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
<?php
// Own namespace
-namespace Org\Mxchange\CoreFramework\Stacker;
+namespace Org\Mxchange\CoreFramework\Stack;
/**
* A FiFo Stacker class
<?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;
* 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
*/
$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);
}
/* 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),
// 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)) +
// 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),
];
}
<?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;
<?php
// Own namespace
-namespace Org\Mxchange\CoreFramework\Stacker;
+namespace Org\Mxchange\CoreFramework\Stack;
/**
* A FiLo Stacker class
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
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;
<?php
// Own namespace
-namespace Org\Mxchange\CoreFramework\FileStack;
+namespace Org\Mxchange\CoreFramework\Stack\File;
// Import framework stuff
use Org\Mxchange\CoreFramework\Generic\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
<?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;
<?php
// Own namespace
-namespace Org\Mxchange\CoreFramework\Stacker;
+namespace Org\Mxchange\CoreFramework\Stack;
// Import framework stuff
use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
<?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
* 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
<?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
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
trait StackableTrait {
-
/**
* Instance of the stacker
*/