From: Roland Häder Date: Fri, 7 Aug 2009 21:33:20 +0000 (+0000) Subject: Moved a lot classes, added visitors and methods X-Git-Url: https://git.mxchange.org/?p=hub.git;a=commitdiff_plain;h=de64d96085bba6ad43a908cbbad128ccd0d8214e Moved a lot classes, added visitors and methods - 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 --- diff --git a/.gitattributes b/.gitattributes index 2f5dca9da..46eae1536 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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 diff --git a/application/hub/config.php b/application/hub/config.php index 78e4fe8ed..51b113b95 100644 --- a/application/hub/config.php +++ b/application/hub/config.php @@ -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'); diff --git a/application/hub/interfaces/listener/class_Listenable.php b/application/hub/interfaces/listener/class_Listenable.php index ede2b555f..2f7bfe858 100644 --- a/application/hub/interfaces/listener/class_Listenable.php +++ b/application/hub/interfaces/listener/class_Listenable.php @@ -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 index c74c72f52..000000000 --- a/application/hub/interfaces/pool/class_PoolableClient.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @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 . - */ -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 index 162d8a6c7..000000000 --- a/application/hub/interfaces/pool/class_PoolableListener.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @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 . - */ -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 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/interfaces/pool/client/.htaccess @@ -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 index 000000000..c74c72f52 --- /dev/null +++ b/application/hub/interfaces/pool/client/class_PoolableClient.php @@ -0,0 +1,36 @@ + + * @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 . + */ +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 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/interfaces/pool/listener/.htaccess @@ -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 index 000000000..5b0f65c13 --- /dev/null +++ b/application/hub/interfaces/pool/listener/class_PoolableListener.php @@ -0,0 +1,42 @@ + + * @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 . + */ +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 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/interfaces/visitor/pool/listener/.htaccess @@ -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 index 000000000..e99be2dc0 --- /dev/null +++ b/application/hub/interfaces/visitor/pool/listener/class_ListenerPoolVisitor.php @@ -0,0 +1,43 @@ + + * @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 . + */ +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); +} + +// +?> diff --git a/application/hub/main/commands/console/class_HubConsoleMainCommand.php b/application/hub/main/commands/console/class_HubConsoleMainCommand.php index c3ece8c2e..c9e4a44b0 100644 --- a/application/hub/main/commands/console/class_HubConsoleMainCommand.php +++ b/application/hub/main/commands/console/class_HubConsoleMainCommand.php @@ -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 index 1fbc0f190..000000000 --- a/application/hub/main/iterator/pool/class_ShutdownPoolIterator.php +++ /dev/null @@ -1,122 +0,0 @@ - - * @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 . - */ -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 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/iterator/pool/handler/.htaccess @@ -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 index 000000000..febcac445 --- /dev/null +++ b/application/hub/main/iterator/pool/handler/class_Handler @@ -0,0 +1,107 @@ + + * @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 . + */ +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 index 000000000..c5e3779cc --- /dev/null +++ b/application/hub/main/iterator/pool/handler/class_HandlerPoolIterator.php @@ -0,0 +1,124 @@ + + * @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 . + */ +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 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/iterator/pool/shutdown/.htaccess @@ -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 index 000000000..758ab9b9b --- /dev/null +++ b/application/hub/main/iterator/pool/shutdown/class_Shutdown @@ -0,0 +1,107 @@ + + * @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 . + */ +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 index 000000000..1fbc0f190 --- /dev/null +++ b/application/hub/main/iterator/pool/shutdown/class_ShutdownPoolIterator.php @@ -0,0 +1,122 @@ + + * @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 . + */ +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/listener/class_ b/application/hub/main/listener/class_ index 4cd059783..199e8c7fc 100644 --- a/application/hub/main/listener/class_ +++ b/application/hub/main/listener/class_ @@ -1,6 +1,6 @@ * @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] diff --git a/application/hub/main/listener/class_BaseListener.php b/application/hub/main/listener/class_BaseListener.php index 32dbe2c7f..b4213785c 100644 --- a/application/hub/main/listener/class_BaseListener.php +++ b/application/hub/main/listener/class_BaseListener.php @@ -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'); } } diff --git a/application/hub/main/listener/class_BaseListenerDecorator.php b/application/hub/main/listener/class_BaseListenerDecorator.php index fe412f7aa..6db53684a 100644 --- a/application/hub/main/listener/class_BaseListenerDecorator.php +++ b/application/hub/main/listener/class_BaseListenerDecorator.php @@ -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'); } } diff --git a/application/hub/main/listener/tcp/class_ b/application/hub/main/listener/tcp/class_ index 67084818a..968182332 100644 --- a/application/hub/main/listener/tcp/class_ +++ b/application/hub/main/listener/tcp/class_ @@ -132,3 +132,77 @@ while (count($clients) > 0) { socket_close($mainSocket); ?> + + * @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 . + */ +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] +?> diff --git a/application/hub/main/listener/tcp/class_TcpListener.php b/application/hub/main/listener/tcp/class_TcpListener.php index c48f4d4f5..b5f3bc179 100644 --- a/application/hub/main/listener/tcp/class_TcpListener.php +++ b/application/hub/main/listener/tcp/class_TcpListener.php @@ -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] diff --git a/application/hub/main/listener/tcp/decorators/class_ClientTcpListenerDecorator.php b/application/hub/main/listener/tcp/decorators/class_ClientTcpListenerDecorator.php index e23d00c25..7dfb77868 100644 --- a/application/hub/main/listener/tcp/decorators/class_ClientTcpListenerDecorator.php +++ b/application/hub/main/listener/tcp/decorators/class_ClientTcpListenerDecorator.php @@ -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] diff --git a/application/hub/main/listener/tcp/decorators/class_HubTcpListenerDecorator.php b/application/hub/main/listener/tcp/decorators/class_HubTcpListenerDecorator.php index 109de8072..0335e98ce 100644 --- a/application/hub/main/listener/tcp/decorators/class_HubTcpListenerDecorator.php +++ b/application/hub/main/listener/tcp/decorators/class_HubTcpListenerDecorator.php @@ -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 index 000000000..c066c086e --- /dev/null +++ b/application/hub/main/listener/udp/class_ @@ -0,0 +1,74 @@ + + * @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 . + */ +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] +?> diff --git a/application/hub/main/listener/udp/class_UdpListener.php b/application/hub/main/listener/udp/class_UdpListener.php index f0d006655..1c770c63f 100644 --- a/application/hub/main/listener/udp/class_UdpListener.php +++ b/application/hub/main/listener/udp/class_UdpListener.php @@ -1,6 +1,6 @@ * @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] diff --git a/application/hub/main/listener/udp/decorators/class_ClientUdpListenerDecorator.php b/application/hub/main/listener/udp/decorators/class_ClientUdpListenerDecorator.php index d81400508..14f1150bc 100644 --- a/application/hub/main/listener/udp/decorators/class_ClientUdpListenerDecorator.php +++ b/application/hub/main/listener/udp/decorators/class_ClientUdpListenerDecorator.php @@ -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] diff --git a/application/hub/main/listener/udp/decorators/class_HubUdpListenerDecorator.php b/application/hub/main/listener/udp/decorators/class_HubUdpListenerDecorator.php index b5468fb7e..dc0630cc0 100644 --- a/application/hub/main/listener/udp/decorators/class_HubUdpListenerDecorator.php +++ b/application/hub/main/listener/udp/decorators/class_HubUdpListenerDecorator.php @@ -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] diff --git a/application/hub/main/pools/class_BasePool.php b/application/hub/main/pools/class_BasePool.php index 0a52e4835..9c9690322 100644 --- a/application/hub/main/pools/class_BasePool.php +++ b/application/hub/main/pools/class_BasePool.php @@ -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'); } } diff --git a/application/hub/main/pools/listener/class_DefaultListenerPool.php b/application/hub/main/pools/listener/class_DefaultListenerPool.php index 99579c55c..621c80c21 100644 --- a/application/hub/main/pools/listener/class_DefaultListenerPool.php +++ b/application/hub/main/pools/listener/class_DefaultListenerPool.php @@ -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); diff --git a/application/hub/main/visitor/class_ b/application/hub/main/visitor/class_ index aa602f20b..d64d546e6 100644 --- a/application/hub/main/visitor/class_ +++ b/application/hub/main/visitor/class_ @@ -30,6 +30,9 @@ class ???Visitor extends BaseVisitor implements Visitor { protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); + + // Set visitor mode + $this->setVisitorMode('???'); } /** diff --git a/application/hub/main/visitor/class_BaseVisitor.php b/application/hub/main/visitor/class_BaseVisitor.php index a955ea64c..c34ef9f2f 100644 --- a/application/hub/main/visitor/class_BaseVisitor.php +++ b/application/hub/main/visitor/class_BaseVisitor.php @@ -22,6 +22,11 @@ * along with this program. If not, see . */ 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 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/visitor/pool/.htaccess @@ -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 index 000000000..2174af554 --- /dev/null +++ b/application/hub/main/visitor/pool/class_ @@ -0,0 +1,64 @@ + + * @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 . + */ +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 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/visitor/pool/handler/.htaccess @@ -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 index 000000000..54b3463d2 --- /dev/null +++ b/application/hub/main/visitor/pool/handler/class_Handler @@ -0,0 +1,64 @@ + + * @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 . + */ +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 index 000000000..65dd5bcaf --- /dev/null +++ b/application/hub/main/visitor/pool/handler/class_HandlerListenerPoolVisitor.php @@ -0,0 +1,90 @@ + + * @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 . + */ +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 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/visitor/pool/shutdown/.htaccess @@ -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 index 000000000..04f7e6c36 --- /dev/null +++ b/application/hub/main/visitor/pool/shutdown/class_Shutdown @@ -0,0 +1,64 @@ + + * @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 . + */ +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 index 000000000..8d48dbd0a --- /dev/null +++ b/application/hub/main/visitor/pool/shutdown/class_ShutdownListenerPoolVisitor.php @@ -0,0 +1,70 @@ + + * @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 . + */ +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 index 3a4288278..000000000 --- a/application/hub/main/visitor/shutdown/.htaccess +++ /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 index 59511aa7b..000000000 --- a/application/hub/main/visitor/shutdown/class_Shutdown +++ /dev/null @@ -1,50 +0,0 @@ - - * @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 . - */ -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 index d4ca881d8..000000000 --- a/application/hub/main/visitor/shutdown/class_ShutdownListenerPoolVisitor.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @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 . - */ -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'); - } -} - -// -?>