]> git.mxchange.org Git - hub.git/commitdiff
Moved a lot classes, added visitors and methods
authorRoland Häder <roland@mxchange.org>
Fri, 7 Aug 2009 21:33:20 +0000 (21:33 +0000)
committerRoland Häder <roland@mxchange.org>
Fri, 7 Aug 2009 21:33:20 +0000 (21:33 +0000)
- Moved a lot classes in more specific folders
- Listener visitor added
- Some more stubs (from new visitor) implemented
- Intefaces updated/added to reflect current changes

45 files changed:
.gitattributes
application/hub/config.php
application/hub/interfaces/listener/class_Listenable.php
application/hub/interfaces/pool/class_PoolableClient.php [deleted file]
application/hub/interfaces/pool/class_PoolableListener.php [deleted file]
application/hub/interfaces/pool/client/.htaccess [new file with mode: 0644]
application/hub/interfaces/pool/client/class_PoolableClient.php [new file with mode: 0644]
application/hub/interfaces/pool/listener/.htaccess [new file with mode: 0644]
application/hub/interfaces/pool/listener/class_PoolableListener.php [new file with mode: 0644]
application/hub/interfaces/visitor/pool/listener/.htaccess [new file with mode: 0644]
application/hub/interfaces/visitor/pool/listener/class_ListenerPoolVisitor.php [new file with mode: 0644]
application/hub/main/commands/console/class_HubConsoleMainCommand.php
application/hub/main/iterator/pool/class_ShutdownPoolIterator.php [deleted file]
application/hub/main/iterator/pool/handler/.htaccess [new file with mode: 0644]
application/hub/main/iterator/pool/handler/class_Handler [new file with mode: 0644]
application/hub/main/iterator/pool/handler/class_HandlerPoolIterator.php [new file with mode: 0644]
application/hub/main/iterator/pool/shutdown/.htaccess [new file with mode: 0644]
application/hub/main/iterator/pool/shutdown/class_Shutdown [new file with mode: 0644]
application/hub/main/iterator/pool/shutdown/class_ShutdownPoolIterator.php [new file with mode: 0644]
application/hub/main/listener/class_
application/hub/main/listener/class_BaseListener.php
application/hub/main/listener/class_BaseListenerDecorator.php
application/hub/main/listener/tcp/class_
application/hub/main/listener/tcp/class_TcpListener.php
application/hub/main/listener/tcp/decorators/class_ClientTcpListenerDecorator.php
application/hub/main/listener/tcp/decorators/class_HubTcpListenerDecorator.php
application/hub/main/listener/udp/class_ [new file with mode: 0644]
application/hub/main/listener/udp/class_UdpListener.php
application/hub/main/listener/udp/decorators/class_ClientUdpListenerDecorator.php
application/hub/main/listener/udp/decorators/class_HubUdpListenerDecorator.php
application/hub/main/pools/class_BasePool.php
application/hub/main/pools/listener/class_DefaultListenerPool.php
application/hub/main/visitor/class_
application/hub/main/visitor/class_BaseVisitor.php
application/hub/main/visitor/pool/.htaccess [new file with mode: 0644]
application/hub/main/visitor/pool/class_ [new file with mode: 0644]
application/hub/main/visitor/pool/handler/.htaccess [new file with mode: 0644]
application/hub/main/visitor/pool/handler/class_Handler [new file with mode: 0644]
application/hub/main/visitor/pool/handler/class_HandlerListenerPoolVisitor.php [new file with mode: 0644]
application/hub/main/visitor/pool/shutdown/.htaccess [new file with mode: 0644]
application/hub/main/visitor/pool/shutdown/class_Shutdown [new file with mode: 0644]
application/hub/main/visitor/pool/shutdown/class_ShutdownListenerPoolVisitor.php [new file with mode: 0644]
application/hub/main/visitor/shutdown/.htaccess [deleted file]
application/hub/main/visitor/shutdown/class_Shutdown [deleted file]
application/hub/main/visitor/shutdown/class_ShutdownListenerPoolVisitor.php [deleted file]

index 2f5dca9da2a8c0223c8121e7a490c1d8fcb43328..46eae153685d02316ac71f92170663abef5f9d65 100644 (file)
@@ -24,8 +24,10 @@ application/hub/interfaces/nodes/.htaccess -text
 application/hub/interfaces/nodes/class_NodeHelper.php -text
 application/hub/interfaces/pool/.htaccess -text
 application/hub/interfaces/pool/class_Poolable.php -text
-application/hub/interfaces/pool/class_PoolableClient.php -text
-application/hub/interfaces/pool/class_PoolableListener.php -text
+application/hub/interfaces/pool/client/.htaccess -text
+application/hub/interfaces/pool/client/class_PoolableClient.php -text
+application/hub/interfaces/pool/listener/.htaccess -text
+application/hub/interfaces/pool/listener/class_PoolableListener.php -text
 application/hub/interfaces/query/.htaccess -text
 application/hub/interfaces/query/class_Queryable.php -text
 application/hub/interfaces/queues/.htaccess -text
@@ -42,6 +44,8 @@ application/hub/interfaces/visitor/class_Visitable.php -text
 application/hub/interfaces/visitor/class_Visitor.php -text
 application/hub/interfaces/visitor/pool/.htaccess -text
 application/hub/interfaces/visitor/pool/class_PoolVisitor.php -text
+application/hub/interfaces/visitor/pool/listener/.htaccess -text
+application/hub/interfaces/visitor/pool/listener/class_ListenerPoolVisitor.php -text
 application/hub/loader.php -text
 application/hub/main/.htaccess -text
 application/hub/main/class_ -text
@@ -97,7 +101,12 @@ application/hub/main/iterator/.htaccess -text
 application/hub/main/iterator/class_ -text
 application/hub/main/iterator/class_BaseIterator.php -text
 application/hub/main/iterator/pool/.htaccess -text
-application/hub/main/iterator/pool/class_ShutdownPoolIterator.php -text
+application/hub/main/iterator/pool/handler/.htaccess -text
+application/hub/main/iterator/pool/handler/class_Handler -text
+application/hub/main/iterator/pool/handler/class_HandlerPoolIterator.php -text
+application/hub/main/iterator/pool/shutdown/.htaccess -text
+application/hub/main/iterator/pool/shutdown/class_Shutdown -text
+application/hub/main/iterator/pool/shutdown/class_ShutdownPoolIterator.php -text
 application/hub/main/listener/.htaccess -text
 application/hub/main/listener/class_ -text
 application/hub/main/listener/class_BaseListener.php -text
@@ -110,6 +119,7 @@ application/hub/main/listener/tcp/decorators/.htaccess -text
 application/hub/main/listener/tcp/decorators/class_ClientTcpListenerDecorator.php -text
 application/hub/main/listener/tcp/decorators/class_HubTcpListenerDecorator.php -text
 application/hub/main/listener/udp/.htaccess -text
+application/hub/main/listener/udp/class_ -text
 application/hub/main/listener/udp/class_UdpListener.php -text
 application/hub/main/listener/udp/decorators/.htaccess -text
 application/hub/main/listener/udp/decorators/class_ClientUdpListenerDecorator.php -text
@@ -161,9 +171,14 @@ application/hub/main/states/hub/class_BaseHubState.php -text
 application/hub/main/visitor/.htaccess -text
 application/hub/main/visitor/class_ -text
 application/hub/main/visitor/class_BaseVisitor.php -text
-application/hub/main/visitor/shutdown/.htaccess -text
-application/hub/main/visitor/shutdown/class_Shutdown -text
-application/hub/main/visitor/shutdown/class_ShutdownListenerPoolVisitor.php -text
+application/hub/main/visitor/pool/.htaccess -text
+application/hub/main/visitor/pool/class_ -text
+application/hub/main/visitor/pool/handler/.htaccess -text
+application/hub/main/visitor/pool/handler/class_Handler -text
+application/hub/main/visitor/pool/handler/class_HandlerListenerPoolVisitor.php -text
+application/hub/main/visitor/pool/shutdown/.htaccess -text
+application/hub/main/visitor/pool/shutdown/class_Shutdown -text
+application/hub/main/visitor/pool/shutdown/class_ShutdownListenerPoolVisitor.php -text
 application/hub/starter.php -text
 /clear-cache.sh -text
 db/.htaccess -text
index 78e4fe8ede4fdc334029ce63b3669bde8796f562..51b113b955807d774e85679f23b94864bdf6bbd0 100644 (file)
@@ -87,12 +87,18 @@ $cfg->setConfigEntry('client_pool_class', 'DefaultClientPool');
 // CFG: POOL-ENTRIES-LIST-CLASS
 $cfg->setConfigEntry('pool_entries_list_class', 'PoolEntriesList');
 
-// CFG: LISTENER-POOL-VISITOR-CLASS
-$cfg->setConfigEntry('listener_pool_visitor_class', 'ShutdownListenerPoolVisitor');
+// CFG: SHUTDOWN-LISTENER-POOL-VISITOR-CLASS
+$cfg->setConfigEntry('shutdown_listener_pool_visitor_class', 'ShutdownListenerPoolVisitor');
 
 // CFG: SHUTDOWN-POOL-ITERATOR-CLASS
 $cfg->setConfigEntry('shutdown_pool_iterator_class', 'ShutdownPoolIterator');
 
+// CFG: HANDLER-LISTENER-POOL-VISITOR-CLASS
+$cfg->setConfigEntry('handler_listener_pool_visitor_class', 'HandlerListenerPoolVisitor');
+
+// CFG: HANDLER-POOL-ITERATOR-CLASS
+$cfg->setConfigEntry('handler_pool_iterator_class', 'HandlerPoolIterator');
+
 // CFG: LIST-GROUP-CLASS
 $cfg->setConfigEntry('list_group_class', 'ListGroupList');
 
index ede2b555fe56d23b9265718ba28f38158bc8067f..2f7bfe858ace62248264747217b598eb28f750e1 100644 (file)
@@ -28,6 +28,13 @@ interface Listenable extends FrameworkInterface {
         * @return      void
         */
        function initListener();
+
+       /**
+        * "Listens" for incoming network packages
+        *
+        * @return      void
+        */
+       function doListen();
 }
 
 //
diff --git a/application/hub/interfaces/pool/class_PoolableClient.php b/application/hub/interfaces/pool/class_PoolableClient.php
deleted file mode 100644 (file)
index c74c72f..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-<?php
-/**
- * A default client pool class
- *
- * @author             Roland Haeder <webmaster@ship-simu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.ship-simu.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 PoolableClient extends Poolable {
-       /**
-        * Adds a socket resource to the client pool
-        *
-        * @param       $socketResource         A valid (must be!) socket resource
-        * @return      void
-        * @todo        0% done
-        */
-       function addClient ($socketResource);
-}
-
-//
-?>
diff --git a/application/hub/interfaces/pool/class_PoolableListener.php b/application/hub/interfaces/pool/class_PoolableListener.php
deleted file mode 100644 (file)
index 162d8a6..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
-/**
- * An interface for pools
- *
- * @author             Roland Haeder <webmaster@ship-simu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.ship-simu.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 PoolableListener extends Poolable {
-       /**
-        * Adds a listener instance to this pool
-        *
-        * @param       $listenerInstance       An instance of a Listenable class
-        * @return      void
-        */
-       function addListener (Listenable $listenerInstance);
-}
-
-//
-?>
diff --git a/application/hub/interfaces/pool/client/.htaccess b/application/hub/interfaces/pool/client/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/interfaces/pool/client/class_PoolableClient.php b/application/hub/interfaces/pool/client/class_PoolableClient.php
new file mode 100644 (file)
index 0000000..c74c72f
--- /dev/null
@@ -0,0 +1,36 @@
+<?php
+/**
+ * A default client pool class
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.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 PoolableClient extends Poolable {
+       /**
+        * Adds a socket resource to the client pool
+        *
+        * @param       $socketResource         A valid (must be!) socket resource
+        * @return      void
+        * @todo        0% done
+        */
+       function addClient ($socketResource);
+}
+
+//
+?>
diff --git a/application/hub/interfaces/pool/listener/.htaccess b/application/hub/interfaces/pool/listener/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/interfaces/pool/listener/class_PoolableListener.php b/application/hub/interfaces/pool/listener/class_PoolableListener.php
new file mode 100644 (file)
index 0000000..5b0f65c
--- /dev/null
@@ -0,0 +1,42 @@
+<?php
+/**
+ * An interface for pools
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.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 PoolableListener extends Poolable {
+       /**
+        * Adds a listener instance to this pool
+        *
+        * @param       $listenerInstance       An instance of a Listenable class
+        * @return      void
+        */
+       function addListener (Listenable $listenerInstance);
+
+       /**
+        * Handle the listeners by asking them for received network packages
+        *
+        * @return      void
+        */
+       function handleListenerPool ();
+}
+
+//
+?>
diff --git a/application/hub/interfaces/visitor/pool/listener/.htaccess b/application/hub/interfaces/visitor/pool/listener/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/interfaces/visitor/pool/listener/class_ListenerPoolVisitor.php b/application/hub/interfaces/visitor/pool/listener/class_ListenerPoolVisitor.php
new file mode 100644 (file)
index 0000000..e99be2d
--- /dev/null
@@ -0,0 +1,43 @@
+<?php
+/**
+ * An interface for the visitor implementation for pools
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.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 ListenerPoolVisitor extends PoolVisitor {
+       /**
+        * Visits the given listener instance
+        *
+        * @param       $listenerInstance       A Listenable instance
+        * @return      void
+        */
+       function visitListener (Listenable $listenerInstance);
+
+       /**
+        * Visits the given listener instance
+        *
+        * @param       $listenerInstance       A Listenable instance
+        * @return      void
+        */
+       function visitDecorator (Listenable $listenerInstance);
+}
+
+//
+?>
index c3ece8c2e6ce47e7c7dbf906c4baf2635f10fdc0..c9e4a44b0a5f277e7040fd6c2394724868b7037e 100644 (file)
@@ -94,12 +94,24 @@ class HubConsoleMainCommand extends BaseCommand implements Commandable {
                // the attribute $hubIsActive to true
                $nodeInstance->activateHub($requestInstance, $responseInstance);
 
+               // Debug message
+               $this->debugOutput('MAIN: --- Entering main loop. ---');
+
                // ----------------------------- Main loop ----------------------------
                // This is the main loop. Queried calls should come back here very fast
                // so the whole application runs on nice speed. This while-loop goes
                // until the hub is no longer active.
                while ($nodeInstance->isHubActive()) {
+                       // Handle the listeners
+                       // @TODO We may have to catch some exceptions here
+                       $nodeInstance->getListenerPoolInstance()->handleListenerPool();
+
+                       // Handle the qeues
+                       $nodeInstance->getQueryInstance()->handleQueues();
                } // END - while
+
+               // Debug message
+               $this->debugOutput('MAIN: --- Leaving main loop. ---');
        }
 
        /**
diff --git a/application/hub/main/iterator/pool/class_ShutdownPoolIterator.php b/application/hub/main/iterator/pool/class_ShutdownPoolIterator.php
deleted file mode 100644 (file)
index 1fbc0f1..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-<?php
-/**
- * A ShutdownPool iterator
- *
- * @author             Roland Haeder <webmaster@ship-simu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.ship-simu.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/>.
- */
-class ShutdownPoolIterator extends BaseIterator implements Iterator {
-       /**
-        * Key for the global list index
-        */
-       private $indexKey = 0;
-
-       /**
-        * Protected constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-       }
-
-       /**
-        * Creates an instance of this class
-        *
-        * @param       $listInstance           A list of a IteratorAggregate
-        * @return      $iteratorInstance       An instance a Iterator class
-        */
-       public final static function createShutdownPoolIterator (IteratorAggregate $listInstance) {
-               // Get new instance
-               $iteratorInstance = new ShutdownPoolIterator();
-
-               // Set the list
-               $iteratorInstance->setListInstance($listInstance);
-
-               // Return the prepared instance
-               return $iteratorInstance;
-       }
-
-       /**
-        * Getter for current value from group or generic
-        *
-        * @return      $current        Current value in iteration
-        * @throws      IndexOutOfBoundsException       If $indexKey is out of bounds
-        */
-       public function current () {
-               // Default is null
-               $current = null;
-
-               // Is the entry valid?
-               if (!$this->valid()) {
-                       // Throw an exception here
-                       throw new IndexOutOfBoundsException($this->key(), self::EXCEPTION_INDEX_OUT_OF_BOUNDS);
-               } // END - if
-
-               // Now get the entry
-               $current = $this->getListInstance()->getEntry($this->key());
-
-               // Return it
-               return $current;
-       }
-
-       /**
-        * Getter for key from group or generic
-        *
-        * @return      $indexKey       Current key in iteration
-        */
-       public function key () {
-               return $this->indexKey;
-       }
-
-       /**
-        * Advances to the next entry
-        *
-        * @return      void
-        */
-       public function next () {
-               $this->indexKey++;
-       }
-
-       /**
-        * Rewinds to the beginning of the iteration
-        *
-        * @return      void
-        */
-       public function rewind () {
-               $this->indexKey = 0;
-       }
-
-       /**
-        * Checks wether the current entry is valid (not at the end of the list)
-        *
-        * @return      $isValid        Wether the current entry is there
-        */
-       public function valid () {
-               // Check for total active clients and if we are not at the end
-               $isValid = ($this->key() < $this->getListInstance()->count());
-
-               // Return result
-               return $isValid;
-       }
-}
-
-// [EOF]
-?>
diff --git a/application/hub/main/iterator/pool/handler/.htaccess b/application/hub/main/iterator/pool/handler/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/iterator/pool/handler/class_Handler b/application/hub/main/iterator/pool/handler/class_Handler
new file mode 100644 (file)
index 0000000..febcac4
--- /dev/null
@@ -0,0 +1,107 @@
+<?php
+/**
+ * A handler ??? iterator
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.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/>.
+ */
+class Handler???Iterator extends BaseIterator implements Iterator {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $iteratorInstance               An instance a Iterator class
+        */
+       public final static function createHandler???Iterator () {
+               // Get new instance
+               $iteratorInstance = new Handler???Iterator();
+
+               // Return the prepared instance
+               return $iteratorInstance;
+       }
+
+       /**
+        * Getter for current value from group or generic
+        *
+        * @return      $current        Current value in iteration
+        */
+       public function current () {
+               // Default is null
+               $current = null;
+
+               $this->partialStub('Please implement this method.');
+
+               // Return it
+               return $current;
+       }
+
+       /**
+        * Getter for key from group or generic
+        *
+        * @return      $key    Current key in iteration
+        */
+       public function key () {
+               // Default is null
+               $key = null;
+
+               $this->partialStub('Please implement this method.');
+
+               // Return it
+               return $key;
+       }
+
+       /**
+        * Advances to the next entry
+        *
+        * @return      void
+        */
+       public function next () {
+               $this->partialStub('Please implement this method.');
+       }
+
+       /**
+        * Rewinds to the beginning of the iteration
+        *
+        * @return      void
+        */
+       public function rewind () {
+               $this->partialStub('Please implement this method.');
+       }
+
+       /**
+        * Checks wether the current entry is valid (not at the end of the list)
+        *
+        * @return      void
+        */
+       public function valid () {
+               $this->partialStub('Please implement this method.');
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/iterator/pool/handler/class_HandlerPoolIterator.php b/application/hub/main/iterator/pool/handler/class_HandlerPoolIterator.php
new file mode 100644 (file)
index 0000000..c5e3779
--- /dev/null
@@ -0,0 +1,124 @@
+<?php
+/**
+ * A HandlerPool iterator
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ * @todo               This current implementation is not recommended, use a
+ * @todo               latency-based iteration or similar approaches
+ *
+ * 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/>.
+ */
+class HandlerPoolIterator extends BaseIterator implements Iterator {
+       /**
+        * Key for the global list index
+        */
+       private $indexKey = 0;
+
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @param       $listInstance           A list of a IteratorAggregate
+        * @return      $iteratorInstance       An instance a Iterator class
+        */
+       public final static function createHandlerPoolIterator (IteratorAggregate $listInstance) {
+               // Get new instance
+               $iteratorInstance = new HandlerPoolIterator();
+
+               // Set the list
+               $iteratorInstance->setListInstance($listInstance);
+
+               // Return the prepared instance
+               return $iteratorInstance;
+       }
+
+       /**
+        * Getter for current value from group or generic
+        *
+        * @return      $current        Current value in iteration
+        * @throws      IndexOutOfBoundsException       If $indexKey is out of bounds
+        */
+       public function current () {
+               // Default is null
+               $current = null;
+
+               // Is the entry valid?
+               if (!$this->valid()) {
+                       // Throw an exception here
+                       throw new IndexOutOfBoundsException($this->key(), self::EXCEPTION_INDEX_OUT_OF_BOUNDS);
+               } // END - if
+
+               // Now get the entry
+               $current = $this->getListInstance()->getEntry($this->key());
+
+               // Return it
+               return $current;
+       }
+
+       /**
+        * Getter for key from group or generic
+        *
+        * @return      $indexKey       Current key in iteration
+        */
+       public function key () {
+               return $this->indexKey;
+       }
+
+       /**
+        * Advances to the next entry
+        *
+        * @return      void
+        */
+       public function next () {
+               $this->indexKey++;
+       }
+
+       /**
+        * Rewinds to the beginning of the iteration
+        *
+        * @return      void
+        */
+       public function rewind () {
+               $this->indexKey = 0;
+       }
+
+       /**
+        * Checks wether the current entry is valid (not at the end of the list)
+        *
+        * @return      $isValid        Wether the current entry is there
+        */
+       public function valid () {
+               // Check for total active clients and if we are not at the end
+               $isValid = ($this->key() < $this->getListInstance()->count());
+
+               // Return result
+               return $isValid;
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/iterator/pool/shutdown/.htaccess b/application/hub/main/iterator/pool/shutdown/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/iterator/pool/shutdown/class_Shutdown b/application/hub/main/iterator/pool/shutdown/class_Shutdown
new file mode 100644 (file)
index 0000000..758ab9b
--- /dev/null
@@ -0,0 +1,107 @@
+<?php
+/**
+ * A shutdown ??? iterator
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.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/>.
+ */
+class Shutdown???Iterator extends BaseIterator implements Iterator {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $iteratorInstance               An instance a Iterator class
+        */
+       public final static function createShutdown???Iterator () {
+               // Get new instance
+               $iteratorInstance = new Shutdown???Iterator();
+
+               // Return the prepared instance
+               return $iteratorInstance;
+       }
+
+       /**
+        * Getter for current value from group or generic
+        *
+        * @return      $current        Current value in iteration
+        */
+       public function current () {
+               // Default is null
+               $current = null;
+
+               $this->partialStub('Please implement this method.');
+
+               // Return it
+               return $current;
+       }
+
+       /**
+        * Getter for key from group or generic
+        *
+        * @return      $key    Current key in iteration
+        */
+       public function key () {
+               // Default is null
+               $key = null;
+
+               $this->partialStub('Please implement this method.');
+
+               // Return it
+               return $key;
+       }
+
+       /**
+        * Advances to the next entry
+        *
+        * @return      void
+        */
+       public function next () {
+               $this->partialStub('Please implement this method.');
+       }
+
+       /**
+        * Rewinds to the beginning of the iteration
+        *
+        * @return      void
+        */
+       public function rewind () {
+               $this->partialStub('Please implement this method.');
+       }
+
+       /**
+        * Checks wether the current entry is valid (not at the end of the list)
+        *
+        * @return      void
+        */
+       public function valid () {
+               $this->partialStub('Please implement this method.');
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/iterator/pool/shutdown/class_ShutdownPoolIterator.php b/application/hub/main/iterator/pool/shutdown/class_ShutdownPoolIterator.php
new file mode 100644 (file)
index 0000000..1fbc0f1
--- /dev/null
@@ -0,0 +1,122 @@
+<?php
+/**
+ * A ShutdownPool iterator
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.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/>.
+ */
+class ShutdownPoolIterator extends BaseIterator implements Iterator {
+       /**
+        * Key for the global list index
+        */
+       private $indexKey = 0;
+
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @param       $listInstance           A list of a IteratorAggregate
+        * @return      $iteratorInstance       An instance a Iterator class
+        */
+       public final static function createShutdownPoolIterator (IteratorAggregate $listInstance) {
+               // Get new instance
+               $iteratorInstance = new ShutdownPoolIterator();
+
+               // Set the list
+               $iteratorInstance->setListInstance($listInstance);
+
+               // Return the prepared instance
+               return $iteratorInstance;
+       }
+
+       /**
+        * Getter for current value from group or generic
+        *
+        * @return      $current        Current value in iteration
+        * @throws      IndexOutOfBoundsException       If $indexKey is out of bounds
+        */
+       public function current () {
+               // Default is null
+               $current = null;
+
+               // Is the entry valid?
+               if (!$this->valid()) {
+                       // Throw an exception here
+                       throw new IndexOutOfBoundsException($this->key(), self::EXCEPTION_INDEX_OUT_OF_BOUNDS);
+               } // END - if
+
+               // Now get the entry
+               $current = $this->getListInstance()->getEntry($this->key());
+
+               // Return it
+               return $current;
+       }
+
+       /**
+        * Getter for key from group or generic
+        *
+        * @return      $indexKey       Current key in iteration
+        */
+       public function key () {
+               return $this->indexKey;
+       }
+
+       /**
+        * Advances to the next entry
+        *
+        * @return      void
+        */
+       public function next () {
+               $this->indexKey++;
+       }
+
+       /**
+        * Rewinds to the beginning of the iteration
+        *
+        * @return      void
+        */
+       public function rewind () {
+               $this->indexKey = 0;
+       }
+
+       /**
+        * Checks wether the current entry is valid (not at the end of the list)
+        *
+        * @return      $isValid        Wether the current entry is there
+        */
+       public function valid () {
+               // Check for total active clients and if we are not at the end
+               $isValid = ($this->key() < $this->getListInstance()->count());
+
+               // Return result
+               return $isValid;
+       }
+}
+
+// [EOF]
+?>
index 4cd05978302f48d106d9c63ed939dc4720099daa..199e8c7fc598cf7fe86f9a6d7b779020f36f30a1 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * 
+ * A ??? listener
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
@@ -58,6 +58,16 @@ class ???Listener extends BaseListener implements Listenable, Visitable {
        public function initListener() {
                $this->partialStub('Need to implement this method.');
        }
+
+       /**
+        * "Listens" for incoming network packages
+        *
+        * @return      void
+        * @todo        0% done
+        */
+       public function doListen() {
+               $this->partialStub('Need to implement this method.');
+       }
 }
 
 // [EOF]
index 32dbe2c7f2aa95c6aba1cb5b9364c4a6ac50980d..b4213785ce2dfb1664dac0dd42a7d31b20c004b3 100644 (file)
@@ -208,18 +208,18 @@ class BaseListener extends BaseHubSystem implements Visitable {
         */
        public function accept (Visitor $visitorInstance) {
                // Debug message
-               $this->debugOutput('LISTENER: ' . $visitorInstance->__toString() . ' has visited - START');
+               //* DEBUG: */ $this->debugOutput('LISTENER: ' . $visitorInstance->__toString() . ' has visited - START');
 
                // Visit this listener
                $visitorInstance->visitListener($this);
 
                // Visit the pool if set
                if ($this->getPoolInstance() instanceof Poolable) {
-                       $this->getPoolInstance()->accept($visitor);
+                       $this->getPoolInstance()->accept($visitorInstance);
                } // END - if
 
                // Debug message
-               $this->debugOutput('LISTENER: ' . $visitorInstance->__toString() . ' has visited - FINISHED');
+               //* DEBUG: */ $this->debugOutput('LISTENER: ' . $visitorInstance->__toString() . ' has visited - FINISHED');
        }
 }
 
index fe412f7aa74a78a38dffeb4b3af82f596d371d61..6db53684a37afed5c3d70a2f05c8070ace8a33b0 100644 (file)
@@ -72,16 +72,16 @@ class BaseListenerDecorator extends BaseHubSystem implements Visitable {
         */
        public function accept (Visitor $visitorInstance) {
                // Debug message
-               $this->debugOutput('DECO-LISTENER: ' . $visitorInstance->__toString() . ' has visited - START');
+               //* DEBUG: */ $this->debugOutput('DECO-LISTENER: ' . $visitorInstance->__toString() . ' has visited - START');
 
                // Visit this decorator
                $visitorInstance->visitDecorator($this);
 
                // Visit the covered class
-               $this->getListenerInstance()->accept($visitorInstance);
+               $visitorInstance->visitListener($this);
 
                // Debug message
-               $this->debugOutput('DECO-LISTENER: ' . $visitorInstance->__toString() . ' has visited - FINISHED');
+               //* DEBUG: */ $this->debugOutput('DECO-LISTENER: ' . $visitorInstance->__toString() . ' has visited - FINISHED');
        }
 }
 
index 67084818a0196bc7fd6e5e941de080155f7ce46c..9681823326a5932faa2402ce5dee0fd13411f322 100644 (file)
@@ -132,3 +132,77 @@ while (count($clients) > 0) {
 socket_close($mainSocket);
 
 ?>
+<?php
+/**
+ * A TCP ??? listener
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.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/>.
+ */
+class ???Listener extends BaseListener implements Listenable, Visitable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @param       $nodeInstance           A NodeHelper instance
+        * @return      $listenerInstance       An instance a prepared listener class
+        */
+       public final static function create???Listener (NodeHelper $nodeInstance) {
+               // Get new instance
+               $listenerInstance = new ???Listener();
+
+               // Set the application instance
+               $listenerInstance->setNodeInstance($nodeInstance);
+
+               // Return the prepared instance
+               return $listenerInstance;
+       }
+
+       /**
+        * Initializes the listener by setting up the required socket server
+        *
+        * @return      void
+        * @todo        0% done
+        */
+       public function initListener() {
+               $this->partialStub('Need to implement this method.');
+       }
+
+       /**
+        * "Listens" for incoming network packages
+        *
+        * @return      void
+        * @todo        0% done
+        */
+       public function doListen() {
+               $this->partialStub('Need to implement this method.');
+       }
+}
+
+// [EOF]
+?>
index c48f4d4f5faefdd380eb58e30541fd83049f3763..b5f3bc179057091102e886b8f7cb8e62af945293 100644 (file)
@@ -139,6 +139,16 @@ class TcpListener extends BaseListener implements Listenable {
                // Output message
                $this->debugOutput('LISTENER: TCP listener now ready on IP ' . $this->getListenAddress() . ', port ' . $this->getListenPort() . ' for service.');
        }
+
+       /**
+        * "Listens" for incoming network packages
+        *
+        * @return      void
+        * @todo        0% done
+        */
+       public function doListen() {
+               $this->partialStub('Need to implement this method.');
+       }
 }
 
 // [EOF]
index e23d00c25d84ccd1a4cf91b4fe96149df761d2f4..7dfb77868c74d23db333232d09f1ca32b352950f 100644 (file)
@@ -57,6 +57,19 @@ class ClientTcpListenerDecorator extends BaseListenerDecorator implements Listen
        public function initListener() {
                $this->partialStub('WARNING: This method should not be called.');
        }
+
+       /**
+        * "Listens" for incoming network packages
+        *
+        * @return      void
+        */
+       public function doListen() {
+               // Handle generic TCP package
+               $this->getListenerInstance()->doListen();
+
+               // Handle client TCP package
+               $this->partialStub('Need to handle client TCP package.');
+       }
 }
 
 // [EOF]
index 109de807278a8139e2c8df3973ac61cd1d2277c3..0335e98ce17c598bf2321ebb784c3d1edf21e315 100644 (file)
@@ -57,6 +57,19 @@ class HubTcpListenerDecorator extends BaseListenerDecorator implements Listenabl
        public function initListener() {
                $this->partialStub('WARNING: This method should not be called.');
        }
+
+       /**
+        * "Listens" for incoming network packages
+        *
+        * @return      void
+        */
+       public function doListen() {
+               // Handle generic TCP package
+               $this->getListenerInstance()->doListen();
+
+               // Handle hub TCP package
+               $this->partialStub('Need to handle hub TCP package.');
+       }
 }
 
 // [EOF]
diff --git a/application/hub/main/listener/udp/class_ b/application/hub/main/listener/udp/class_
new file mode 100644 (file)
index 0000000..c066c08
--- /dev/null
@@ -0,0 +1,74 @@
+<?php
+/**
+ * An UDP ??? listener
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.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/>.
+ */
+class Udp???Listener extends BaseListener implements Listenable, Visitable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @param       $nodeInstance           A NodeHelper instance
+        * @return      $listenerInstance       An instance a prepared listener class
+        */
+       public final static function createUdp???Listener (NodeHelper $nodeInstance) {
+               // Get new instance
+               $listenerInstance = new Udp???Listener();
+
+               // Set the application instance
+               $listenerInstance->setNodeInstance($nodeInstance);
+
+               // Return the prepared instance
+               return $listenerInstance;
+       }
+
+       /**
+        * Initializes the listener by setting up the required socket server
+        *
+        * @return      void
+        * @todo        0% done
+        */
+       public function initListener() {
+               $this->partialStub('Need to implement this method.');
+       }
+
+       /**
+        * "Listens" for incoming network packages
+        *
+        * @return      void
+        * @todo        0% done
+        */
+       public function doListen() {
+               $this->partialStub('Need to implement this method.');
+       }
+}
+
+// [EOF]
+?>
index f0d006655844fb01c298962a352c283ed9b8f1c3..1c770c63f1c1102ebf5044da894bb9ac1bec5be4 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * A UDP connection listener
+ * An UDP connection listener
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
@@ -77,6 +77,16 @@ class UdpListener extends BaseListener implements Listenable {
                // Output message
                $this->debugOutput('LISTENER: UDP listener now ready on IP ' . $this->getListenAddress() . ', port ' . $this->getListenPort() . ' for service.');
        }
+
+       /**
+        * "Listens" for incoming network packages
+        *
+        * @return      void
+        * @todo        0% done
+        */
+       public function doListen() {
+               $this->partialStub('Need to implement this method.');
+       }
 }
 
 // [EOF]
index d814005082b648eedecfc327604f7ea22c32115c..14f1150bcbaf99e8cd70c9873a85ec60190bc3ff 100644 (file)
@@ -57,6 +57,19 @@ class ClientUdpListenerDecorator extends BaseListenerDecorator implements Listen
        public function initListener() {
                $this->partialStub('WARNING: This method should not be called.');
        }
+
+       /**
+        * "Listens" for incoming network packages
+        *
+        * @return      void
+        */
+       public function doListen() {
+               // Look for generic packages first
+               $this->getListenerInstance()->doListen();
+
+               // Handle this client UDP package
+               $this->partialStub('Need to handle client UDP package.');
+       }
 }
 
 // [EOF]
index b5468fb7ece1c6cb0589cae131d32f4b413ae4a7..dc0630cc0ba20d5153b01b91fb0b256851cd3bf0 100644 (file)
@@ -57,6 +57,19 @@ class HubUdpListenerDecorator extends BaseListenerDecorator implements Listenabl
        public function initListener() {
                $this->partialStub('WARNING: This method should not be called.');
        }
+
+       /**
+        * "Listens" for incoming network packages
+        *
+        * @return      void
+        */
+       public function doListen() {
+               // Handle generic package first
+               $this->getListenerInstance()->doListen();
+
+               // Handle hub UDP package
+               $this->partialStub('Need to handle hub UDP package.');
+       }
 }
 
 // [EOF]
index 0a52e48358c78c36a6ce0b071999ce95a53ab83f..9c9690322770d4de674c1c6c17893cb28fa87b34 100644 (file)
@@ -78,13 +78,13 @@ class BasePool extends BaseHubSystem implements Visitable {
         */
        public function accept (Visitor $visitorInstance) {
                // Debug message
-               $this->debugOutput('POOL: ' . $visitorInstance->__toString() . ' has visited - START');
+               //* DEBUG: */ $this->debugOutput('POOL: ' . $visitorInstance->__toString() . ' has visited - START');
 
                // Visit this pool
                $visitorInstance->visitPool($this);
 
                // Get a new iterator instance
-               $iteratorInstance = ObjectFactory::createObjectByConfiguredName('shutdown_pool_iterator_class', array($this->poolEntriesInstance));
+               $iteratorInstance = ObjectFactory::createObjectByConfiguredName($visitorInstance->getVisitorMode() . '_pool_iterator_class', array($this->poolEntriesInstance));
 
                // Reset the counter
                $iteratorInstance->rewind();
@@ -97,6 +97,7 @@ class BasePool extends BaseHubSystem implements Visitable {
                        // Is this entry visitable?
                        if ($poolEntry instanceof Visitable) {
                                // Visit this entry as well
+                               print __METHOD__.':'.$poolEntry."\n";
                                $poolEntry->accept($visitorInstance);
                        } else {
                                // Cannot visit this entry
@@ -108,7 +109,7 @@ class BasePool extends BaseHubSystem implements Visitable {
                } // END - while
 
                // Debug message
-               $this->debugOutput('POOL: ' . $visitorInstance->__toString() . ' has visited - FINISHED');
+               //* DEBUG: */ $this->debugOutput('POOL: ' . $visitorInstance->__toString() . ' has visited - FINISHED');
        }
 }
 
index 99579c55cee87fcf04318f5c9d8152aa0917b3c7..621c80c21fbfc1d93b5d5816b5bf855d0cf6c97c 100644 (file)
@@ -67,6 +67,21 @@ class DefaultListenerPool extends BasePool implements PoolableListener {
                );
        }
 
+       /**
+        * Handle the listeners by asking them for received network packages.
+        * You should not add any debug lines here because they will be executed
+        * in the main loop and may be a performance impact.
+        *
+        * @return      void
+        */
+       public function handleListenerPool () {
+               // Get a visitor instance
+               $visitorInstance = ObjectFactory::createObjectByConfiguredName('handler_listener_pool_visitor_class');
+
+               // Start the visit
+               $this->accept($visitorInstance);
+       }
+
        /**
         * Run the shutdown seqeuence by a Visitor Pattern
         *
@@ -77,7 +92,7 @@ class DefaultListenerPool extends BasePool implements PoolableListener {
                $this->debugOutput('POOL: Shutting down listener pool - START');
 
                // Get a new visitor
-               $visitorInstance = ObjectFactory::createObjectByConfiguredName('listener_pool_visitor_class');
+               $visitorInstance = ObjectFactory::createObjectByConfiguredName('shutdown_listener_pool_visitor_class');
 
                // Start visiting
                $this->accept($visitorInstance);
index aa602f20b657f5bfd0c9af4041035d359e4f63ff..d64d546e67eebc220f621c805ab452f31da0f6e1 100644 (file)
@@ -30,6 +30,9 @@ class ???Visitor extends BaseVisitor implements Visitor {
        protected function __construct () {
                // Call parent constructor
                parent::__construct(__CLASS__);
+
+               // Set visitor mode
+               $this->setVisitorMode('???');
        }
 
        /**
index a955ea64c76fccddde65b9c40bfa05068d0e8a83..c34ef9f2fc23a7091b13aeeead39c05941c317f8 100644 (file)
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 class BaseVisitor extends BaseHubSystem {
+       /**
+        * Mode of the visitor (the first word of the concrete class' name)
+        */
+       private $visitorMode = 'invalid';
+
        /**
         * Protected constructor
         *
@@ -36,6 +41,25 @@ class BaseVisitor extends BaseHubSystem {
                $this->removeNumberFormaters();
                $this->removeSystemArray();
        }
+
+       /**
+        * Setter for visitor mode
+        *
+        * @param       $visitorMode    New visitor mode to set
+        * @return      void
+        */
+       protected final function setVisitorMode ($visitorMode) {
+               $this->visitorMode = (string) $visitorMode;
+       }
+
+       /**
+        * Getter for visitor mode
+        *
+        * @return      $visitorMode    New visitor mode to set
+        */
+       public final function getVisitorMode () {
+               return $this->visitorMode;
+       }
 }
 
 // [EOF]
diff --git a/application/hub/main/visitor/pool/.htaccess b/application/hub/main/visitor/pool/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/visitor/pool/class_ b/application/hub/main/visitor/pool/class_
new file mode 100644 (file)
index 0000000..2174af5
--- /dev/null
@@ -0,0 +1,64 @@
+<?php
+/**
+ * A ??? visitor
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.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/>.
+ */
+class ???Visitor extends BaseVisitor implements PoolVisitor {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set visitor mode
+               $this->setVisitorMode('???');
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $visitorInstance                An instance a Visitorable class
+        */
+       public final static function create???Visitor () {
+               // Get new instance
+               $visitorInstance = new ???Visitor();
+
+               // Return the prepared instance
+               return $visitorInstance;
+       }
+
+       /**
+        * Visits the given pool instance
+        *
+        * @param       $poolInstance   A Poolable instance
+        * @return      void
+        * @todo        0%
+        */
+       public function visitPool (Poolable $poolInstance) {
+               $this->partialStub('Please implement this method.');
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/visitor/pool/handler/.htaccess b/application/hub/main/visitor/pool/handler/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/visitor/pool/handler/class_Handler b/application/hub/main/visitor/pool/handler/class_Handler
new file mode 100644 (file)
index 0000000..54b3463
--- /dev/null
@@ -0,0 +1,64 @@
+<?php
+/**
+ * A ??? handler visitor
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.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/>.
+ */
+class Handler???Visitor extends BaseVisitor implements PoolVisitor {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set visitor mode
+               $this->setVisitorMode('handler');
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $visitorInstance                An instance a Visitorable class
+        */
+       public final static function createHandler???Visitor () {
+               // Get new instance
+               $visitorInstance = new Handler???Visitor();
+
+               // Return the prepared instance
+               return $visitorInstance;
+       }
+
+       /**
+        * Visits the given pool instance
+        *
+        * @param       $poolInstance   A Poolable instance
+        * @return      void
+        * @todo        0%
+        */
+       public function visitPool (Poolable $poolInstance) {
+               $this->partialStub('Please implement this method.');
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/visitor/pool/handler/class_HandlerListenerPoolVisitor.php b/application/hub/main/visitor/pool/handler/class_HandlerListenerPoolVisitor.php
new file mode 100644 (file)
index 0000000..65dd5bc
--- /dev/null
@@ -0,0 +1,90 @@
+<?php
+/**
+ * A ListenerPool handler visitor
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.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/>.
+ */
+class HandlerListenerPoolVisitor extends BaseVisitor implements ListenerPoolVisitor {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set visitor mode
+               $this->setVisitorMode('handler');
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $visitorInstance                An instance a Visitorable class
+        */
+       public final static function createHandlerListenerPoolVisitor () {
+               // Get new instance
+               $visitorInstance = new HandlerListenerPoolVisitor();
+
+               // Return the prepared instance
+               return $visitorInstance;
+       }
+
+       /**
+        * Visits the given pool instance
+        *
+        * @param       $poolInstance   A Poolable instance
+        * @return      void
+        * @todo        Find some use of doListen() method in listener pool classes
+        */
+       public function visitPool (Poolable $poolInstance) {
+               // The pool itself wont listen to any connections but maybe we need
+               // this stub for something later on
+               // $poolInstance->doListen();
+       }
+
+       /**
+        * Visits the given decorator instance
+        *
+        * @param       $listenerInstance       A Listenable instance
+        * @return      void
+        * @todo        Find some use of doListen() method in listener decorator classes
+        */
+       public function visitDecorator (Listenable $listenerInstance) {
+               // The decorator itself wont listen to any connections but maybe we need
+               // this stub for something later on
+               // $listenerInstance->doListen();
+       }
+
+       /**
+        * Visits the given listener instance
+        *
+        * @param       $listenerInstance       A listenerable instance
+        * @return      void
+        */
+       public function visitListener (Listenable $listenerInstance) {
+               // Just call the listener->doListen
+               $listenerInstance->doListen();
+       }
+}
+
+//
+?>
diff --git a/application/hub/main/visitor/pool/shutdown/.htaccess b/application/hub/main/visitor/pool/shutdown/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/visitor/pool/shutdown/class_Shutdown b/application/hub/main/visitor/pool/shutdown/class_Shutdown
new file mode 100644 (file)
index 0000000..04f7e6c
--- /dev/null
@@ -0,0 +1,64 @@
+<?php
+/**
+ * A ??? shutdown visitor
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.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/>.
+ */
+class Shutdown???Visitor extends BaseVisitor implements PoolVisitor {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set visitor mode
+               $this->setVisitorMode('shutdown');
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $visitorInstance                An instance a Visitorable class
+        */
+       public final static function createShutdown???Visitor () {
+               // Get new instance
+               $visitorInstance = new Shutdown???Visitor();
+
+               // Return the prepared instance
+               return $visitorInstance;
+       }
+
+       /**
+        * Visits the given pool instance
+        *
+        * @param       $poolInstance   A Poolable instance
+        * @return      void
+        * @todo        0%
+        */
+       public function visitPool (Poolable $poolInstance) {
+               $this->partialStub('Please implement this method.');
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/visitor/pool/shutdown/class_ShutdownListenerPoolVisitor.php b/application/hub/main/visitor/pool/shutdown/class_ShutdownListenerPoolVisitor.php
new file mode 100644 (file)
index 0000000..8d48dbd
--- /dev/null
@@ -0,0 +1,70 @@
+<?php
+/**
+ * A ListenerPool shutdown visitor
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.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/>.
+ */
+class ShutdownListenerPoolVisitor extends BaseVisitor implements PoolVisitor {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set visitor mode
+               $this->setVisitorMode('shutdown');
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $visitorInstance                An instance a Visitorable class
+        */
+       public final static function createShutdownListenerPoolVisitor () {
+               // Get new instance
+               $visitorInstance = new ShutdownListenerPoolVisitor();
+
+               // Return the prepared instance
+               return $visitorInstance;
+       }
+
+       /**
+        * Visits the given pool instance
+        *
+        * @param       $poolInstance   A Poolable instance
+        * @return      void
+        */
+       public function visitPool (Poolable $poolInstance) {
+               // Debug message
+               $this->debugOutput('VISITOR: Visit of ' . $poolInstance->__toString() . ' - START');
+
+               // Pre-shutdown the pool
+               $poolInstance->preShutdown();
+
+               // Debug message
+               $this->debugOutput('VISITOR: Visit of ' . $poolInstance->__toString() . ' - FINISHED');
+       }
+}
+
+//
+?>
diff --git a/application/hub/main/visitor/shutdown/.htaccess b/application/hub/main/visitor/shutdown/.htaccess
deleted file mode 100644 (file)
index 3a42882..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Deny from all
diff --git a/application/hub/main/visitor/shutdown/class_Shutdown b/application/hub/main/visitor/shutdown/class_Shutdown
deleted file mode 100644 (file)
index 59511aa..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-<?php
-/**
- * A ??? shutdown visitor
- *
- * @author             Roland Haeder <webmaster@ship-simu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.ship-simu.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/>.
- */
-class Shutdown???Visitor extends BaseVisitor implements PoolVisitor {
-       /**
-        * Protected constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-       }
-
-       /**
-        * Creates an instance of this class
-        *
-        * @return      $visitorInstance                An instance a Visitorable class
-        */
-       public final static function createShutdown???Visitor () {
-               // Get new instance
-               $visitorInstance = new Shutdown???Visitor();
-
-               // Return the prepared instance
-               return $visitorInstance;
-       }
-}
-
-// [EOF]
-?>
diff --git a/application/hub/main/visitor/shutdown/class_ShutdownListenerPoolVisitor.php b/application/hub/main/visitor/shutdown/class_ShutdownListenerPoolVisitor.php
deleted file mode 100644 (file)
index d4ca881..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-<?php
-/**
- * A ListenerPool shutdown visitor
- *
- * @author             Roland Haeder <webmaster@ship-simu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.ship-simu.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/>.
- */
-class ShutdownListenerPoolVisitor extends BaseVisitor implements PoolVisitor {
-       /**
-        * Protected constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-       }
-
-       /**
-        * Creates an instance of this class
-        *
-        * @return      $visitorInstance                An instance a Visitorable class
-        */
-       public final static function createShutdownListenerPoolVisitor () {
-               // Get new instance
-               $visitorInstance = new ShutdownListenerPoolVisitor();
-
-               // Return the prepared instance
-               return $visitorInstance;
-       }
-
-       /**
-        * Visits the given pool instance
-        *
-        * @param       $poolInstance   A Poolable instance
-        * @return      void
-        */
-       public function visitPool (Poolable $poolInstance) {
-               // Debug message
-               $this->debugOutput('VISITOR: Visit of ' . $poolInstance->__toString() . ' - START');
-
-               // Pre-shutdown the pool
-               $poolInstance->preShutdown();
-
-               // Debug message
-               $this->debugOutput('VISITOR: Visit of ' . $poolInstance->__toString() . ' - FINISHED');
-       }
-}
-
-//
-?>