]> git.mxchange.org Git - core.git/commitdiff
Added new interfaces for file i/o classes.
authorRoland Haeder <roland@mxchange.org>
Fri, 16 May 2014 21:49:45 +0000 (23:49 +0200)
committerRoland Haeder <roland@mxchange.org>
Fri, 16 May 2014 21:49:45 +0000 (23:49 +0200)
Signed-off-by: Roland Häder <roland@mxchange.org>
15 files changed:
inc/classes/interfaces/io/class_IoHandler.php [deleted file]
inc/classes/interfaces/io/file/handler/.htaccess [new file with mode: 0644]
inc/classes/interfaces/io/file/handler/class_IoHandler.php [new file with mode: 0644]
inc/classes/interfaces/io/pointer/.htaccess [new file with mode: 0644]
inc/classes/interfaces/io/pointer/class_InputPointer.php [new file with mode: 0644]
inc/classes/interfaces/io/pointer/class_OutputPointer.php [new file with mode: 0644]
inc/classes/interfaces/io/pointer/io/.htaccess [new file with mode: 0644]
inc/classes/interfaces/io/pointer/io/class_InputOutputPointer.php [new file with mode: 0644]
inc/classes/main/class_BaseFrameworkSystem.php
inc/classes/main/file_directories/input/class_FrameworkFileInputPointer.php
inc/classes/main/file_directories/io/class_FrameworkFileInputOutputPointer.php
inc/classes/main/file_directories/io_handler/class_FileIoStream.php
inc/classes/main/file_directories/output/class_FrameworkFileOutputPointer.php
inc/classes/main/iterator/io/class_FileIoIterator.php
inc/classes/middleware/io/class_FileIoHandler.php

diff --git a/inc/classes/interfaces/io/class_IoHandler.php b/inc/classes/interfaces/io/class_IoHandler.php
deleted file mode 100644 (file)
index 55b5590..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-<?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]
-?>
diff --git a/inc/classes/interfaces/io/file/handler/.htaccess b/inc/classes/interfaces/io/file/handler/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/interfaces/io/file/handler/class_IoHandler.php b/inc/classes/interfaces/io/file/handler/class_IoHandler.php
new file mode 100644 (file)
index 0000000..0463b82
--- /dev/null
@@ -0,0 +1,57 @@
+<?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]
+?>
diff --git a/inc/classes/interfaces/io/pointer/.htaccess b/inc/classes/interfaces/io/pointer/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/interfaces/io/pointer/class_InputPointer.php b/inc/classes/interfaces/io/pointer/class_InputPointer.php
new file mode 100644 (file)
index 0000000..d312dc9
--- /dev/null
@@ -0,0 +1,37 @@
+<?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]
+?>
diff --git a/inc/classes/interfaces/io/pointer/class_OutputPointer.php b/inc/classes/interfaces/io/pointer/class_OutputPointer.php
new file mode 100644 (file)
index 0000000..8d367eb
--- /dev/null
@@ -0,0 +1,39 @@
+<?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]
+?>
diff --git a/inc/classes/interfaces/io/pointer/io/.htaccess b/inc/classes/interfaces/io/pointer/io/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/interfaces/io/pointer/io/class_InputOutputPointer.php b/inc/classes/interfaces/io/pointer/io/class_InputOutputPointer.php
new file mode 100644 (file)
index 0000000..6c2de09
--- /dev/null
@@ -0,0 +1,28 @@
+<?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]
+?>
index b13875fa7a71d1df7aca2103db2ada88d889d346..abcefc8c35f6b2aaed66eaa6e7fa31ed0e3c14c1 100644 (file)
@@ -1224,19 +1224,19 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
        }
 
        /**
-        * 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;
index f70ef5a12b90596adb19bef552f6e50326c1ff95..bd14d9dbb6fe7180073384cced28ba3b6dff8586 100644 (file)
@@ -21,7 +21,7 @@
  * 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
         *
index e548fe20887af11d5b93ce5dc83c40fa69dd9ff7..88c565cc20c8305c40ea4d83f98305f624254cdf 100644 (file)
@@ -21,7 +21,7 @@
  * 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
         *
index 35bc0c8b36de4d4156b774bfb69d4126aebe1227..27ceab32a4e7a3a0d981af5efee1e9f8e564989f 100644 (file)
@@ -134,7 +134,7 @@ class FileIoStream extends BaseFrameworkSystem implements FileInputStreamer, Fil
        /**
         * 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
         */
index 1af2697b22d7c15fe3b20826de0ce0952ce08af1..a3da18563a2fb3ec4d3d1c71a045a677e87fd206 100644 (file)
@@ -21,7 +21,7 @@
  * 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
         *
index 61045519510c6b2df2a7fc3196ceb2976af05df4..03c0c25b2f81747e00e17c6c4f422af2a8e58cd5 100644 (file)
@@ -45,10 +45,10 @@ class FileIoIterator extends BaseIterator implements SeekableWritableFileIterato
        /**
         * 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();
 
index 55f98f8e636f580bb5870b1c0f8c843c1c99f9c6..81be505619114f92fca24ee1237d1a2f8f30ef25 100644 (file)
@@ -125,9 +125,6 @@ class FileIoHandler extends BaseMiddleware implements IoHandler {
         * @return      void
         */
        public function saveFile ($fileName, $dataStream, FrameworkInterface $objectInstance = NULL) {
-               // Get output stream
-               $outInstance = $this->getOutputStream();
-
                // Default is this array
                $className = $this->__toString();
 
@@ -144,7 +141,7 @@ class FileIoHandler extends BaseMiddleware implements IoHandler {
                );
 
                // 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
@@ -153,11 +150,8 @@ class FileIoHandler extends BaseMiddleware implements IoHandler {
         * @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);
        }
 }