]> git.mxchange.org Git - core.git/blobdiff - inc/classes/main/stacker/file/fifo/class_FiFoFileStack.php
Opps, forgot this.
[core.git] / inc / classes / main / stacker / file / fifo / class_FiFoFileStack.php
index 1a81058cd4924602f5c5c62f188375b78845b33d..fc7edf43ace684ec400ab5b70525094b952de304 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2014 Core Developer Team
+ * @copyright  Copyright (c) 2015 Core Developer Team
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.ship-simu.org
  *
@@ -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 FiFoFileStack extends BaseFileStack implements StackableFile {
+class FiFoFileStack extends BaseFileStack implements StackableFile, CalculatableBlock, Registerable {
        /**
         * Protected constructor
         *
@@ -36,14 +36,15 @@ class FiFoFileStack extends BaseFileStack implements StackableFile {
         * Creates an instance of this class
         *
         * @param       $fileName               Absolute Name of stack file
+        * @param       $type                   Type of this stack (e.g. url_source for URL sources)
         * @return      $stackInstance  An instance of a Stackable class
         */
-       public final static function createFiFoFileStack ($fileName) {
+       public final static function createFiFoFileStack ($fileName, $type) {
                // Get new instance
                $stackInstance = new FiFoFileStack();
 
                // Init this stack
-               $stackInstance->initFileStack($fileName);
+               $stackInstance->initFileStack($fileName, $type);
 
                // Return the prepared instance
                return $stackInstance;
@@ -58,19 +59,27 @@ class FiFoFileStack extends BaseFileStack implements StackableFile {
         * @throws      StackerFullException    If the stack is full
         */
        public function pushNamed ($stackerName, $value) {
-               $this->partialStub('stackerName=' . $stackerName . ',value[' . gettype($value) . ']=' . $value);
+               // Call the protected method
+               parent::addValue($stackerName, $value);
        }
 
        /**
-        * 'Pops' a value from a named stacker
+        * 'Pops' a value from a named stacker and returns it's value
         *
         * @param       $stackerName    Name of the stack
-        * @return      void
+        * @return      $value                  Value of the current stack entry
         * @throws      NoStackerException      If the named stacker was not found
         * @throws      EmptyStackerException   If the named stacker is empty
         */
        public function popNamed ($stackerName) {
-               $this->partialStub('stackerName=' . $stackerName);
+               // Get the value
+               $value = $this->getNamed($stackerName);
+
+               // Call the protected method
+               parent::popFirst($stackerName);
+
+               // Return the value
+               return $value;
        }
 
        /**
@@ -82,7 +91,8 @@ class FiFoFileStack extends BaseFileStack implements StackableFile {
         * @throws      EmptyStackerException   If the named stacker is empty
         */
        public function getNamed ($stackerName) {
-               $this->partialStub('stackerName=' . $stackerName);
+               // Call the protected method
+               return parent::getFirstValue($stackerName);
        }
 
        /**
@@ -101,7 +111,8 @@ class FiFoFileStack extends BaseFileStack implements StackableFile {
         * @return      $size   Size (in bytes) of file
         */
        public function size () {
-               $this->partialStub();
+               // Call the iterator instance
+               return $this->getIteratorInstance()->size();
        }
 }