]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/pools/class_BasePool.php
Continued with refacturing:
[hub.git] / application / hub / main / pools / class_BasePool.php
index c65f8266b65d1fbcd11e9a69674b0bf782ee74a2..a6befaa75949b9bb9b998a35d06899a708c98a9c 100644 (file)
@@ -2,11 +2,11 @@
 /**
  * A general pool class
  *
- * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @author             Roland Haeder <webmaster@shipsimu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
  * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.ship-simu.org
+ * @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
@@ -71,12 +71,18 @@ class BasePool extends BaseHubSystem implements Visitable {
        /**
         * Adds an instance to a pool segment
         *
-        * @param       $group                  Name of the pool group
-        * @param       $poolSegment    Name of the pool segment
-        * @param       $instance               An instance of a class that should bed added to the pool
+        * @param       $group                          Name of the pool group
+        * @param       $poolSegment            Name of the pool segment
+        * @param       $visitableInstance      An instance of a class that should bed added to the pool
         * @return      void
         */
-       protected final function addInstance ($group, $poolName, Visitable $instance) {
+       protected final function addInstance ($group, $poolName, Visitable $visitableInstance) {
+               // Debug message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: group=' . $group . ',poolName=' . $poolName . ',visitableInstance=' . $visitableInstance->__toString() . ' - CALLED!');
+
+               // Make sure the group is not 'invalid'
+               assert($group != 'invalid');
+
                // Is the pool group there?
                if (!$this->getPoolEntriesInstance()->isGroupSet($group)) {
                        // Create the missing pool group
@@ -84,7 +90,10 @@ class BasePool extends BaseHubSystem implements Visitable {
                } // END - if
 
                // Add it to given pool group
-               $this->getPoolEntriesInstance()->addInstance($group, $poolName, $instance);
+               $this->getPoolEntriesInstance()->addInstance($group, $poolName, $visitableInstance);
+
+               // Debug message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!');
        }
 
        /**
@@ -105,7 +114,7 @@ class BasePool extends BaseHubSystem implements Visitable {
         */
        public function accept (Visitor $visitorInstance) {
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __LINE__ . ']: ' . $visitorInstance->__toString() . ' has visited - START');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: ' . $visitorInstance->__toString() . ' has visited - START');
 
                // Visit this pool
                $visitorInstance->visitPool($this);
@@ -133,7 +142,7 @@ class BasePool extends BaseHubSystem implements Visitable {
                        // Is this entry visitable?
                        if ($poolEntry instanceof Visitable) {
                                // Visit this entry as well
-                               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-POOL[' . __LINE__ . ']: Going to visit pooled object ' . $poolEntry->__toString() . ' with visitor ' . $visitorInstance->__toString() . ' ...');
+                               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-POOL[' . __METHOD__ . ':' . __LINE__ . ']: Going to visit pooled object ' . $poolEntry->__toString() . ' with visitor ' . $visitorInstance->__toString() . ' ...');
                                $poolEntry->accept($visitorInstance);
                        } else {
                                // Cannot visit this entry
@@ -145,7 +154,7 @@ class BasePool extends BaseHubSystem implements Visitable {
                } // END - while
 
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __LINE__ . ']: ' . $visitorInstance->__toString() . ' has visited - FINISHED');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: ' . $visitorInstance->__toString() . ' has visited - FINISHED');
        }
 
        /**
@@ -170,7 +179,7 @@ class BasePool extends BaseHubSystem implements Visitable {
         */
        protected function isValidConnectionType ($connectionType) {
                // Is it valid?
-               $isValid = in_array($connectionType, $this->connectionTypes, true);
+               $isValid = in_array($connectionType, $this->connectionTypes, TRUE);
 
                // Return result
                return $isValid;