*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
*/
private $totalEntries = 0;
+ /**
+ * An instance of a file I/O pointer class (not handler)
+ */
+ private $pointerInstance = NULL;
+
/**
* Protected constructor
*
* @param $className Name of the class
* @return void
*/
- protected function __construct ($className) {
+ protected function __construct (string $className) {
// Call parent constructor
parent::__construct($className);
}
+ /**
+ * Setter for FilePointer instance
+ *
+ * @param $pointerInstance An instance of an FilePointer class
+ * @return void
+ */
+ protected final function setPointerInstance (FilePointer $pointerInstance = NULL) {
+ $this->pointerInstance = $pointerInstance;
+ }
+
+ /**
+ * Getter for FilePointer instance
+ *
+ * @return $pointerInstance An instance of an FilePointer class
+ */
+ public final function getPointerInstance () {
+ return $this->pointerInstance;
+ }
+
+ /**
+ * Unsets pointer instance which triggers a call of __destruct() if the
+ * instance is still there. This is surely not fatal on already "closed"
+ * file pointer instances.
+ *
+ * I don't want to mess around with above setter by giving it a default
+ * value NULL as setter should always explicitly only set (existing) object
+ * instances and NULL is NULL.
+ *
+ * @return void
+ */
+ protected final function unsetPointerInstance () {
+ // Simply invoke setter with no parameter
+ $this->setPointerInstance();
+ }
+
/**
* Destructor for cleaning purposes, etc
*
*/
public final function getCounter () {
// Get it
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-ABSTRACT-FILE: Getting this->totalEntries=%d ... - CALLED!', $this->totalEntries));
return $this->totalEntries;
}
* @param $totalEntries Total entries in this file
* @return void
*/
- protected final function setCounter ($counter) {
+ protected final function setCounter (int $counter) {
// Set it
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-ABSTRACT-FILE: Setting this->totalEntries=%d ... - CALLED!', $counter));
$this->totalEntries = $counter;
}
*/
protected final function incrementCounter () {
// Get it
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-ABSTRACT-FILE: CALLED!');
$this->totalEntries++;
+
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-ABSTRACT-FILE: EXIT!');
}
/**
return $this->getPointerInstance()->getFileObject();
}
+ /**
+ * Getter for file's name
+ */
+ public final function getFilename () {
+ // Invole file object's method
+ return $this->getFileObject()->getFilename();
+ }
+
/**
* Close a file source and set it's instance to null and the file name
* to empty
* @return void
*/
public function closeFile () {
- // Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d]: CALLED!', __METHOD__, __LINE__));
-
// Close down pointer instance as well by unsetting it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-ABSTRACT-FILE: CALLED!');
$this->unsetPointerInstance();
- // Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d]: EXIT!', __METHOD__, __LINE__));
+ // Trace message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-ABSTRACT-FILE: EXIT!');
}
/**
* @throws InvalidResourceException If there is being set
* an invalid file resource
*/
- public function writeToFile ($dataStream) {
+ public function writeToFile (string $dataStream) {
// Call pointer instance
return $this->getPointerInstance()->writeToFile($dataStream);
}