From 7cebddfa0d95b33a987bea7cc8bc6fb3471d0a2b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Mon, 17 Aug 2009 20:40:23 +0000 Subject: [PATCH] Deprecated visitor removed, new added, rewrites: - Deprecated visitor HandlerListenerPoolVisitor removed due to pools cannot be tasks (see ActiveTaskVisitor) and we don't need to visit it again for handling pooled listeners because we handle them directly. - QueryConnectorVisitor added for visiting query connector classes - LocalQueryList added for handling queries in an OOP'ed way - LocalQuery added which runs queries locally --- .gitattributes | 11 ++- application/hub/class_ApplicationHelper.php | 2 +- application/hub/config.php | 9 +- .../pool/listener/class_PoolableListener.php | 7 -- .../interfaces/visitor/connector/.htaccess | 1 + .../connector/class_QueryConnectorVisitor.php | 35 ++++++++ application/hub/main/class_ | 2 +- .../console/class_HubConsoleMainCommand.php | 4 - application/hub/main/connectors/query/class_ | 46 ++++++++-- .../query/class_BaseQueryConnector.php | 24 +++++ .../query/local/class_LocalQueryConnector.php | 24 ++++- .../class_HubShutdownDeinitQueuesFilter.php | 6 +- .../class_TaskHandlerInitializerFilter.php | 2 +- application/hub/main/lists/query/.htaccess | 1 + .../hub/main/lists/query/local/.htaccess | 1 + .../query/local/class_LocalQueryList.php | 50 +++++++++++ .../hub/main/nodes/class_BaseHubNode.php | 18 ++-- .../listener/class_DefaultListenerPool.php | 15 ---- application/hub/main/queries/.htaccess | 1 + application/hub/main/queries/class_ | 50 +++++++++++ .../hub/main/queries/class_BaseQuery.php | 38 ++++++++ application/hub/main/queries/local/.htaccess | 1 + .../main/queries/local/class_LocalQuery.php | 50 +++++++++++ .../class_HandlerListenerPoolVisitor.php | 90 ------------------- .../visitor/tasks/class_ActiveTaskVisitor.php | 13 +-- 25 files changed, 350 insertions(+), 151 deletions(-) create mode 100644 application/hub/interfaces/visitor/connector/.htaccess create mode 100644 application/hub/interfaces/visitor/connector/class_QueryConnectorVisitor.php create mode 100644 application/hub/main/lists/query/.htaccess create mode 100644 application/hub/main/lists/query/local/.htaccess create mode 100644 application/hub/main/lists/query/local/class_LocalQueryList.php create mode 100644 application/hub/main/queries/.htaccess create mode 100644 application/hub/main/queries/class_ create mode 100644 application/hub/main/queries/class_BaseQuery.php create mode 100644 application/hub/main/queries/local/.htaccess create mode 100644 application/hub/main/queries/local/class_LocalQuery.php delete mode 100644 application/hub/main/visitor/pool/handler/class_HandlerListenerPoolVisitor.php diff --git a/.gitattributes b/.gitattributes index a7f2b027c..7a678a733 100644 --- a/.gitattributes +++ b/.gitattributes @@ -52,6 +52,8 @@ application/hub/interfaces/tasks/class_Taskable.php -text application/hub/interfaces/visitor/.htaccess -text application/hub/interfaces/visitor/class_Visitable.php -text application/hub/interfaces/visitor/class_Visitor.php -text +application/hub/interfaces/visitor/connector/.htaccess -text +application/hub/interfaces/visitor/connector/class_QueryConnectorVisitor.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 @@ -167,6 +169,9 @@ application/hub/main/lists/groups/.htaccess -text application/hub/main/lists/groups/class_ListGroupList.php -text application/hub/main/lists/pool/.htaccess -text application/hub/main/lists/pool/class_PoolEntriesList.php -text +application/hub/main/lists/query/.htaccess -text +application/hub/main/lists/query/local/.htaccess -text +application/hub/main/lists/query/local/class_LocalQueryList.php -text application/hub/main/lists/tasks/.htaccess -text application/hub/main/lists/tasks/class_TaskList.php -text application/hub/main/nodes/.htaccess -text @@ -187,6 +192,11 @@ application/hub/main/pools/client/.htaccess -text application/hub/main/pools/client/class_DefaultClientPool.php -text application/hub/main/pools/listener/.htaccess -text application/hub/main/pools/listener/class_DefaultListenerPool.php -text +application/hub/main/queries/.htaccess -text +application/hub/main/queries/class_ -text +application/hub/main/queries/class_BaseQuery.php -text +application/hub/main/queries/local/.htaccess -text +application/hub/main/queries/local/class_LocalQuery.php -text application/hub/main/queues/.htaccess -text application/hub/main/queues/class_ -text application/hub/main/queues/class_BaseQueue.php -text @@ -223,7 +233,6 @@ 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 diff --git a/application/hub/class_ApplicationHelper.php b/application/hub/class_ApplicationHelper.php index 49c4acab7..3e62874fd 100644 --- a/application/hub/class_ApplicationHelper.php +++ b/application/hub/class_ApplicationHelper.php @@ -219,7 +219,7 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica public function handleFatalMessages (array $messageList) { // Walk through all messages foreach ($messageList as $message) { - die("MSG:" . $message); + die('MSG:' . $message); } } diff --git a/application/hub/config.php b/application/hub/config.php index 319f83868..f0b6bc42f 100644 --- a/application/hub/config.php +++ b/application/hub/config.php @@ -102,9 +102,6 @@ $cfg->setConfigEntry('tcp_network_package_handler_class', 'TcpNetworkPackageHand // CFG: SHUTDOWN-LISTENER-POOL-VISITOR-CLASS $cfg->setConfigEntry('shutdown_listener_pool_visitor_class', 'ShutdownListenerPoolVisitor'); -// CFG: HANDLER-LISTENER-POOL-VISITOR-CLASS -$cfg->setConfigEntry('handler_listener_pool_visitor_class', 'HandlerListenerPoolVisitor'); - // CFG: ACTIVE-TASK-VISITOR-CLASS $cfg->setConfigEntry('active_task_visitor_class', 'ActiveTaskVisitor'); @@ -207,5 +204,11 @@ $cfg->setConfigEntry('task_pool_iterator_class', 'TaskPoolIterator'); // CFG: DEFAULT-ITERATOR-CLASS $cfg->setConfigEntry('default_iterator_class', 'DefaultIterator'); +// CFG: LOCAL-QUERY-LIST-CLASS +$cfg->setConfigEntry('local_query_list_class', 'LocalQueryList'); + +// CFG: LOCAL-QUERY-CLASS +$cfg->setConfigEntry('local_query_class', 'LocalQuery'); + // [EOF] ?> diff --git a/application/hub/interfaces/pool/listener/class_PoolableListener.php b/application/hub/interfaces/pool/listener/class_PoolableListener.php index 5b0f65c13..162d8a6c7 100644 --- a/application/hub/interfaces/pool/listener/class_PoolableListener.php +++ b/application/hub/interfaces/pool/listener/class_PoolableListener.php @@ -29,13 +29,6 @@ interface PoolableListener extends Poolable { * @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/connector/.htaccess b/application/hub/interfaces/visitor/connector/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/interfaces/visitor/connector/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/interfaces/visitor/connector/class_QueryConnectorVisitor.php b/application/hub/interfaces/visitor/connector/class_QueryConnectorVisitor.php new file mode 100644 index 000000000..baf86edcc --- /dev/null +++ b/application/hub/interfaces/visitor/connector/class_QueryConnectorVisitor.php @@ -0,0 +1,35 @@ + + * @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 QueryConnectorVisitor extends Visitor { + /** + * QueryConnector visitor method for active queries + * + * @param $connectorInstance A Connectable instance + * @return void + */ + function visitQueryConnector (Connectable $connectorInstance); +} + +// [EOF] +?> diff --git a/application/hub/main/class_ b/application/hub/main/class_ index 9f2dcb696..ea4538679 100644 --- a/application/hub/main/class_ +++ b/application/hub/main/class_ @@ -21,7 +21,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class ??? extends BaseFrameworkSystem { +class ??? extends BaseFrameworkSystem implements === { /** * Protected constructor * diff --git a/application/hub/main/commands/console/class_HubConsoleMainCommand.php b/application/hub/main/commands/console/class_HubConsoleMainCommand.php index d57140cb1..2463c9a58 100644 --- a/application/hub/main/commands/console/class_HubConsoleMainCommand.php +++ b/application/hub/main/commands/console/class_HubConsoleMainCommand.php @@ -89,10 +89,6 @@ class HubConsoleMainCommand extends BaseCommand implements Commandable { while (($nodeInstance->isHubActive()) && ($handlerInstance->hasTasksLeft())) { // Handle all tasks here $handlerInstance->handleTasks(); - - // Handle the listeners - // @TODO We may have to catch some exceptions here - //$nodeInstance->getListenerPoolInstance()->handleListenerPool(); } // END - while // Debug message diff --git a/application/hub/main/connectors/query/class_ b/application/hub/main/connectors/query/class_ index 066db0bda..4a285a047 100644 --- a/application/hub/main/connectors/query/class_ +++ b/application/hub/main/connectors/query/class_ @@ -1,12 +1,13 @@ * @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 Find an interface for: handleAllQueries() * * 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 @@ -21,7 +22,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class ???QueueConnector extends BaseQueueConnector implements Connectable, Queueable { +class ???QueryConnector extends BaseQueryConnector implements Connectable, Visitable { /** * Protected constructor * @@ -33,17 +34,48 @@ class ???QueueConnector extends BaseQueueConnector implements Connectable, Queue } /** - * Creates an instance of this queue connector class + * Creates an instance of this query connector class * - * @return $connectorInstance An instance of this queue connector class + * @param $nodeInstance An instance of a node + * @return $connectorInstance An instance of this query connector class */ - public final static function create???QueueConnector () { + public final static function create???QueryConnector (NodeHelper $nodeInstance) { // Create the instance - $connectorInstance = new ???QueueConnector(); + $connectorInstance = new ???QueryConnector(); - // Finally return it + // Set the node instance + $connectorInstance->setNodeInstance($nodeInstance); + + // Get a list instance + $listInstance = ObjectFactory::createObjectByConfiguredName('!!!_query_list_class'); + + // Set it in the connector + $connectorInstance->setListInstance($listInstance); + + // Finally return the connector return $connectorInstance; } + + /** + * Accepts the visitor to rpocess the visit "request" + * + * @param $visitorInstance An instance of a Visitor class + * @return void + */ + public function accept (Visitor $visitorInstance) { + // Visit the query connector + $visitorInstance->visitQuery($this); + } + + /** + * Handles all unsent queries and should be called from a visitor + * + * @return void + * @todo 0% done + */ + public function handleAllQueries () { + $this->partialStub('Please implement this method.'); + } } // [EOF] diff --git a/application/hub/main/connectors/query/class_BaseQueryConnector.php b/application/hub/main/connectors/query/class_BaseQueryConnector.php index f84666857..df4d0960d 100644 --- a/application/hub/main/connectors/query/class_BaseQueryConnector.php +++ b/application/hub/main/connectors/query/class_BaseQueryConnector.php @@ -22,6 +22,11 @@ * along with this program. If not, see . */ class BaseQueryConnector extends BaseConnector { + /** + * A FIFO (First In First Out) list instance + */ + private $listInstance = null; + /** * Protected constructor * @@ -32,6 +37,25 @@ class BaseQueryConnector extends BaseConnector { // Call parent constructor parent::__construct($className); } + + /** + * Getter for FIFO list instance + * + * @return $listInstance A FIFO list instance + */ + protected final function getListInstance () { + return $this->listInstance; + } + + /** + * Setter for FIFO list instance + * + * @param $listInstance A FIFO list instance + * @return void + */ + private final function setListInstance (Listable $listInstance) { + $this->listInstance = $listInstance; + } } // [EOF] diff --git a/application/hub/main/connectors/query/local/class_LocalQueryConnector.php b/application/hub/main/connectors/query/local/class_LocalQueryConnector.php index 22f052135..23989f4bd 100644 --- a/application/hub/main/connectors/query/local/class_LocalQueryConnector.php +++ b/application/hub/main/connectors/query/local/class_LocalQueryConnector.php @@ -7,6 +7,7 @@ * @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 Find an interface for: handleAllQueries() * * 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 @@ -21,7 +22,12 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class LocalQueryConnector extends BaseQueryConnector implements Connectable, Queryable, Visitable { +class LocalQueryConnector extends BaseQueryConnector implements Connectable, Visitable { + /** + * The query class instance + */ + private $queryInstance = null; + /** * Protected constructor * @@ -30,6 +36,9 @@ class LocalQueryConnector extends BaseQueryConnector implements Connectable, Que protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); + + // Init query instance + $this->queryInstance = ObjectFactory::createObjectByConfiguredName('local_query_class'); } /** @@ -45,7 +54,13 @@ class LocalQueryConnector extends BaseQueryConnector implements Connectable, Que // Set the node instance $connectorInstance->setNodeInstance($nodeInstance); - // Finally return it + // Get a list instance + $listInstance = ObjectFactory::createObjectByConfiguredName('local_query_list_class'); + + // Set it in the connector + $connectorInstance->setListInstance($listInstance); + + // Finally return the connector return $connectorInstance; } @@ -57,7 +72,10 @@ class LocalQueryConnector extends BaseQueryConnector implements Connectable, Que */ public function accept (Visitor $visitorInstance) { // Visit the query connector - $visitorInstance->visitQuery($this); + $visitorInstance->visitQueryConnector($this); + + // Visit the query as well + $this->queryInstance->accept($visitorInstance); } } diff --git a/application/hub/main/filter/shutdown/class_HubShutdownDeinitQueuesFilter.php b/application/hub/main/filter/shutdown/class_HubShutdownDeinitQueuesFilter.php index aba685df3..dea5619e3 100644 --- a/application/hub/main/filter/shutdown/class_HubShutdownDeinitQueuesFilter.php +++ b/application/hub/main/filter/shutdown/class_HubShutdownDeinitQueuesFilter.php @@ -59,16 +59,16 @@ class HubShutdownDeinitQueuesFilter extends BaseFilter implements Filterable { $nodeInstance = Registry::getRegistry()->getInstance('node'); // Get query instance - $queryInstance = $nodeInstance->getQueryInstance(); + $connectorInstance = $nodeInstance->getQueryConnectorInstance(); // Sanity-check on it - if (is_null($queryInstance)) { + if (is_null($connectorInstance)) { // Throws a FilterChainException to stop further processing throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); } // END - if // Now shutdown this one done - $queryInstance->doShutdown(); + $connectorInstance->doShutdown(); } } diff --git a/application/hub/main/filter/task/class_TaskHandlerInitializerFilter.php b/application/hub/main/filter/task/class_TaskHandlerInitializerFilter.php index 2d2f3adf1..da413addc 100644 --- a/application/hub/main/filter/task/class_TaskHandlerInitializerFilter.php +++ b/application/hub/main/filter/task/class_TaskHandlerInitializerFilter.php @@ -65,7 +65,7 @@ class TaskHandlerInitializerFilter extends BaseFilter implements Filterable { // 1.) Network package reader, needs to be delayed a little $handlerInstance->registerTask('network_package_reader', $nodeInstance->getListenerPoolInstance()); // 2.) Query instance - $handlerInstance->registerTask('query_handler', $nodeInstance->getQueryInstance()); + $handlerInstance->registerTask('query_handler', $nodeInstance->getQueryConnectorInstance()); // Generate idle task $taskInstance = ObjectFactory::createObjectByConfiguredName('idle_task_class'); diff --git a/application/hub/main/lists/query/.htaccess b/application/hub/main/lists/query/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/lists/query/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/lists/query/local/.htaccess b/application/hub/main/lists/query/local/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/lists/query/local/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/lists/query/local/class_LocalQueryList.php b/application/hub/main/lists/query/local/class_LocalQueryList.php new file mode 100644 index 000000000..83475e098 --- /dev/null +++ b/application/hub/main/lists/query/local/class_LocalQueryList.php @@ -0,0 +1,50 @@ + + * @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 LocalQueryList extends BaseList implements Listable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $listInstance An instance a Listable class + */ + public final static function createLocalQueryList () { + // Get new instance + $listInstance = new LocalQueryList(); + + // Return the prepared instance + return $listInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/main/nodes/class_BaseHubNode.php b/application/hub/main/nodes/class_BaseHubNode.php index c6aba05b6..633e207e6 100644 --- a/application/hub/main/nodes/class_BaseHubNode.php +++ b/application/hub/main/nodes/class_BaseHubNode.php @@ -40,7 +40,7 @@ class BaseHubNode extends BaseHubSystem implements Updateable { /** * Query connector instance */ - private $queryInstance = null; + private $connectorInstance = null; /** * Listener pool instance @@ -123,20 +123,20 @@ class BaseHubNode extends BaseHubSystem implements Updateable { /** * Setter for query instance * - * @param $queryInstance Our new query instance + * @param $connectorInstance Our new query instance * @return void */ - private final function setQueryInstance (Queryable $queryInstance) { - $this->queryInstance = $queryInstance; + private final function setQueryConnectorInstance (Connectable $connectorInstance) { + $this->connectorInstance = $connectorInstance; } /** * Getter for query instance * - * @return $queryInstance Our new query instance + * @return $connectorInstance Our new query instance */ - public final function getQueryInstance () { - return $this->queryInstance; + public final function getQueryConnectorInstance () { + return $this->connectorInstance; } /** @@ -308,10 +308,10 @@ class BaseHubNode extends BaseHubSystem implements Updateable { $this->debugOutput('BOOTSTRAP: Initialize queues: START'); // Set the query connector instance - $this->setQueryInstance(ObjectFactory::createObjectByConfiguredName('query_connector_class', array($this))); + $this->setQueryConnectorInstance(ObjectFactory::createObjectByConfiguredName('query_connector_class', array($this))); // Run a test query - $this->getQueryInstance()->doTestQuery(); + $this->getQueryConnectorInstance()->doTestQuery(); // Debug message $this->debugOutput('BOOTSTRAP: Initialize queues: FINISHED'); diff --git a/application/hub/main/pools/listener/class_DefaultListenerPool.php b/application/hub/main/pools/listener/class_DefaultListenerPool.php index 621c80c21..dccbfcc34 100644 --- a/application/hub/main/pools/listener/class_DefaultListenerPool.php +++ b/application/hub/main/pools/listener/class_DefaultListenerPool.php @@ -67,21 +67,6 @@ 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 * diff --git a/application/hub/main/queries/.htaccess b/application/hub/main/queries/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/queries/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/queries/class_ b/application/hub/main/queries/class_ new file mode 100644 index 000000000..99d8ab5c6 --- /dev/null +++ b/application/hub/main/queries/class_ @@ -0,0 +1,50 @@ + + * @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 ???Query extends BaseQuery implements Queryable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $queryInstance An instance of a Queryable class + */ + public final static function create???Query () { + // Get new instance + $queryInstance = new ???Query(); + + // Return the prepared instance + return $queryInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/main/queries/class_BaseQuery.php b/application/hub/main/queries/class_BaseQuery.php new file mode 100644 index 000000000..e85325e42 --- /dev/null +++ b/application/hub/main/queries/class_BaseQuery.php @@ -0,0 +1,38 @@ + + * @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 BaseQuery extends BaseHubSystem { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/application/hub/main/queries/local/.htaccess b/application/hub/main/queries/local/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/queries/local/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/queries/local/class_LocalQuery.php b/application/hub/main/queries/local/class_LocalQuery.php new file mode 100644 index 000000000..b6ae4b047 --- /dev/null +++ b/application/hub/main/queries/local/class_LocalQuery.php @@ -0,0 +1,50 @@ + + * @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 LocalQuery extends BaseQuery implements Queryable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $queryInstance An instance of a Queryable class + */ + public final static function createLocalQuery () { + // Get new instance + $queryInstance = new LocalQuery(); + + // Return the prepared instance + return $queryInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/main/visitor/pool/handler/class_HandlerListenerPoolVisitor.php b/application/hub/main/visitor/pool/handler/class_HandlerListenerPoolVisitor.php deleted file mode 100644 index 65dd5bcaf..000000000 --- a/application/hub/main/visitor/pool/handler/class_HandlerListenerPoolVisitor.php +++ /dev/null @@ -1,90 +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 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/tasks/class_ActiveTaskVisitor.php b/application/hub/main/visitor/tasks/class_ActiveTaskVisitor.php index 5794ae6bc..6d4bfc429 100644 --- a/application/hub/main/visitor/tasks/class_ActiveTaskVisitor.php +++ b/application/hub/main/visitor/tasks/class_ActiveTaskVisitor.php @@ -21,7 +21,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class ActiveTaskVisitor extends BaseVisitor implements TaskVisitor, QueryVisitor, PoolVisitor { +class ActiveTaskVisitor extends BaseVisitor implements TaskVisitor, QueryConnectorVisitor, PoolVisitor { /** * Protected constructor * @@ -60,14 +60,14 @@ class ActiveTaskVisitor extends BaseVisitor implements TaskVisitor, QueryVisitor } /** - * Query visitor method for active tasks + * Connector visitor method for active tasks * - * @param $queryInstance A Queryable instance + * @param $connectorInstance A Connectable instance * @return void */ - public function visitQuery (Queryable $queryInstance) { + public function visitQueryConnector (Connectable $connectorInstance) { // Handle all queries - $queryInstance->handleQueries(); + $connectorInstance->handleQueryConnector(); } /** @@ -78,7 +78,8 @@ class ActiveTaskVisitor extends BaseVisitor implements TaskVisitor, QueryVisitor */ public function visitPool (Poolable $poolInstance) { // We don't need to visit a pool as an active task because a pool can - // never become a task. + // never become a task. Instead e.g. by a listener pool we should visit + // all listeners one by one } } -- 2.39.2