+++ /dev/null
-<?php
-/**
- * An interface for streams
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2013 Core Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-interface IoHandler extends FrameworkInterface {
- /**
- * Setter for the *real* file input instance
- *
- * @param $inputStream The *real* file-input class
- * @return void
- */
- function setInputStream (FileInputStreamer $inputStream);
-
- /**
- * Getter for the *real* file input instance
- *
- * @return $inputStream The *real* file-input class
- */
- function getInputStream ();
-
- /**
- * Setter for the *real* file output instance
- *
- * @param $outputStream The *real* file-output class
- * @return void
- */
- function setOutputStream (FileOutputStreamer $outputStream);
-
- /**
- * Getter for the *real* file output instance
- *
- * @return $outputStream The *real* file-output class
- */
- function getOutputStream ();
-
- /**
- * Saves a file with data by using the current output stream
- *
- * @param $fileName Name of the file
- * @param $dataStream File data stream
- * @param $objectInstance An instance of a FrameworkInterface class (default: NULL)
- * @return void
- */
- function saveFile ($fileName, $dataStream, FrameworkInterface $objectInstance = NULL);
-
- /** Loads data from a file over the input handler
- *
- * @param $fqfn Given full-qualified file name (FQFN) to load
- * @return $array Array with the file contents
- */
- function loadFileContents ($fqfn);
-}
-
-// [EOF]
-?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * An interface for I/O handlers
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2013 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+interface IoHandler extends FileInputStreamer, FileOutputStreamer {
+ /**
+ * Setter for the *real* file input instance
+ *
+ * @param $inputStream The *real* file-input class
+ * @return void
+ */
+ function setInputStream (FileInputStreamer $inputStream);
+
+ /**
+ * Getter for the *real* file input instance
+ *
+ * @return $inputStream The *real* file-input class
+ */
+ function getInputStream ();
+
+ /**
+ * Setter for the *real* file output instance
+ *
+ * @param $outputStream The *real* file-output class
+ * @return void
+ */
+ function setOutputStream (FileOutputStreamer $outputStream);
+
+ /**
+ * Getter for the *real* file output instance
+ *
+ * @return $outputStream The *real* file-output class
+ */
+ function getOutputStream ();
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * An interface for (mostly) file input pointers.
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2013 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+interface InputPointer extends Streamable {
+ /**
+ * Read data a file pointer
+ *
+ * @return mixed The result of fread()
+ * @throws NullPointerException If the file pointer instance
+ * is not set by setPointer()
+ * @throws InvalidResourceException If there is being set
+ */
+ function readFromFile ();
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * An interface for (mostly) file output pointers.
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2013 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+interface OutputPointer extends Streamable {
+ /**
+ * Write data to a file pointer
+ *
+ * @param $dataStream The data stream we shall write to the file
+ * @return mixed Number of writes bytes or FALSE on error
+ * @throws NullPointerException If the file pointer instance
+ * is not set by setPointer()
+ * @throws InvalidResourceException If there is being set
+ * an invalid file resource
+ */
+ function writeToFile ($dataStream);
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * An interface for (mostly) file input/output pointers.
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2013 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+interface InputOutputPointer extends InputPointer, OutputPointer {
+}
+
+// [EOF]
+?>
}
/**
- * Setter for FrameworkFileInputOutputPointer instance
+ * Setter for InputOutputPointer instance
*
- * @param $pointerInstance An instance of an FrameworkFileInputOutputPointer
+ * @param $pointerInstance An instance of an InputOutputPointer
* @return void
*/
- protected final function setPointerInstance (FrameworkFileInputOutputPointer $pointerInstance) {
+ protected final function setPointerInstance (InputOutputPointer $pointerInstance) {
$this->pointerInstance = $pointerInstance;
}
/**
- * Getter for FrameworkFileInputOutputPointer instance
+ * Getter for InputOutputPointer instance
*
- * @return $pointerInstance An instance of an FrameworkFileInputOutputPointer
+ * @return $pointerInstance An instance of an InputOutputPointer
*/
public final function getPointerInstance () {
return $this->pointerInstance;
* 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 FrameworkFileInputPointer extends BaseFileIo {
+class FrameworkFileInputPointer extends BaseFileIo implements InputPointer {
/**
* Protected constructor
*
* 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 FrameworkFileInputOutputPointer extends BaseFileIo {
+class FrameworkFileInputOutputPointer extends BaseFileIo implements InputOutputPointer {
/**
* Protected constructor
*
/**
* Reads from a local file
*
- * @param $fqfn The full-qualified file-name which we shall load
+ * @param $fqfn The full-qualified file-name which we shall load
* @return $array An array with the element 'header' and 'data'
* @see FileInputStreamer
*/
* 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 FrameworkFileOutputPointer extends BaseFileIo {
+class FrameworkFileOutputPointer extends BaseFileIo implements OutputPointer {
/**
* Protected constructor
*
/**
* Creates an instance of this class
*
- * @param $pointerInstance An instance of a FrameworkFileInputOutputPointer class
+ * @param $pointerInstance An instance of a InputOutputPointer class
* @return $iteratorInstance An instance of a Iterator class
*/
- public final static function createFileIoIterator (FrameworkFileInputOutputPointer $pointerInstance) {
+ public final static function createFileIoIterator (InputOutputPointer $pointerInstance) {
// Get new instance
$iteratorInstance = new FileIoIterator();
* @return void
*/
public function saveFile ($fileName, $dataStream, FrameworkInterface $objectInstance = NULL) {
- // Get output stream
- $outInstance = $this->getOutputStream();
-
// Default is this array
$className = $this->__toString();
);
// Send the fileName and dataArray to the output handler
- $outInstance->saveFile($fileName, $dataArray);
+ $this->getOutputStream()->saveFile($fileName, $dataArray);
}
/** Loads data from a file over the input handler
* @return $array Array with the file contents
*/
public function loadFileContents ($fqfn) {
- // Get output stream
- $inInstance = $this->getInputStream();
-
// Read from the input handler
- return $inInstance->loadFileContents($fqfn);
+ return $this->getInputStream()->loadFileContents($fqfn);
}
}