From f0da0d019796cabacedb983d6d2b3d5e81840b56 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 19 Aug 2009 20:18:19 +0000 Subject: [PATCH] Interfaces, BaseDecorator added: - New interface DecoratorVisitor introduced which should be implemented by decorator visitors (so? ;-) ) - New interface ListenerVisitor introduced - Listener are now visited by ActiveTaskVisitor and should listen again for incoming data - NEWS/TODOs.txt updated --- .gitattributes | 6 +++ .../interfaces/visitor/decorator/.htaccess | 1 + .../decorator/class_DecoratorVisitor.php | 35 +++++++++++++++++ .../hub/interfaces/visitor/listener/.htaccess | 1 + .../listener/class_ListenerVisitor.php | 35 +++++++++++++++++ application/hub/main/decorators/.htaccess | 1 + .../main/decorators/class_BaseDecorator.php | 38 +++++++++++++++++++ .../main/handler/tasks/class_TaskHandler.php | 2 +- .../listener/class_BaseListenerDecorator.php | 8 +--- .../class_ClientUdpListenerDecorator.php | 2 +- .../class_HubUdpListenerDecorator.php | 2 +- .../visitor/tasks/class_ActiveTaskVisitor.php | 28 ++++++++++++-- docs/NEWS | 10 +++++ docs/TODOs.txt | 23 ++++++----- 14 files changed, 169 insertions(+), 23 deletions(-) create mode 100644 application/hub/interfaces/visitor/decorator/.htaccess create mode 100644 application/hub/interfaces/visitor/decorator/class_DecoratorVisitor.php create mode 100644 application/hub/interfaces/visitor/listener/.htaccess create mode 100644 application/hub/interfaces/visitor/listener/class_ListenerVisitor.php create mode 100644 application/hub/main/decorators/.htaccess create mode 100644 application/hub/main/decorators/class_BaseDecorator.php diff --git a/.gitattributes b/.gitattributes index 89cf94d9b..0aa62cbdc 100644 --- a/.gitattributes +++ b/.gitattributes @@ -54,6 +54,10 @@ 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/decorator/.htaccess -text +application/hub/interfaces/visitor/decorator/class_DecoratorVisitor.php -text +application/hub/interfaces/visitor/listener/.htaccess -text +application/hub/interfaces/visitor/listener/class_ListenerVisitor.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 @@ -89,6 +93,8 @@ application/hub/main/database/.htaccess -text application/hub/main/database/wrapper/.htaccess -text application/hub/main/database/wrapper/class_NodeInformationDatabaseWrapper.php -text application/hub/main/database/wrapper/class_NodeListDatabaseWrapper.php -text +application/hub/main/decorators/.htaccess -text +application/hub/main/decorators/class_BaseDecorator.php -text application/hub/main/filter/.htaccess -text application/hub/main/filter/activation/.htaccess -text application/hub/main/filter/activation/class_HubActivation -text diff --git a/application/hub/interfaces/visitor/decorator/.htaccess b/application/hub/interfaces/visitor/decorator/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/interfaces/visitor/decorator/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/interfaces/visitor/decorator/class_DecoratorVisitor.php b/application/hub/interfaces/visitor/decorator/class_DecoratorVisitor.php new file mode 100644 index 000000000..ef962715c --- /dev/null +++ b/application/hub/interfaces/visitor/decorator/class_DecoratorVisitor.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 DecoratorVisitor extends Visitor { + /** + * Visits the given decorator instance + * + * @param $decoratorInstance A decorator instance + * @return void + */ + function visitDecorator (BaseDecorator $decoratorInstance); +} + +// [EOF] +?> diff --git a/application/hub/interfaces/visitor/listener/.htaccess b/application/hub/interfaces/visitor/listener/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/interfaces/visitor/listener/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/interfaces/visitor/listener/class_ListenerVisitor.php b/application/hub/interfaces/visitor/listener/class_ListenerVisitor.php new file mode 100644 index 000000000..fa2da2c53 --- /dev/null +++ b/application/hub/interfaces/visitor/listener/class_ListenerVisitor.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 ListenerVisitor extends Visitor { + /** + * Visits the given listener instance + * + * @param $listenerInstance A Listenable instance + * @return void + */ + function visitListener (Listenable $listenerInstance); +} + +// [EOF] +?> diff --git a/application/hub/main/decorators/.htaccess b/application/hub/main/decorators/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/decorators/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/decorators/class_BaseDecorator.php b/application/hub/main/decorators/class_BaseDecorator.php new file mode 100644 index 000000000..43b6e5d05 --- /dev/null +++ b/application/hub/main/decorators/class_BaseDecorator.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 BaseDecorator 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/handler/tasks/class_TaskHandler.php b/application/hub/main/handler/tasks/class_TaskHandler.php index a502ff44e..ee751541a 100644 --- a/application/hub/main/handler/tasks/class_TaskHandler.php +++ b/application/hub/main/handler/tasks/class_TaskHandler.php @@ -112,7 +112,7 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask { $updateTask = true; // Debug message - $this->debugOutput('TASK-HANDLER: Task ' . $currentTask['id'] . ' started with startup_delay=' . $currentTask['task_startup_delay']); + $this->debugOutput('TASK-HANDLER: Task ' . $currentTask['id'] . ' started with startup_delay=' . $currentTask['task_startup_delay'] . 'ms'); } // END - if // Get time difference from interval delay diff --git a/application/hub/main/listener/class_BaseListenerDecorator.php b/application/hub/main/listener/class_BaseListenerDecorator.php index 92c69431f..dcf284649 100644 --- a/application/hub/main/listener/class_BaseListenerDecorator.php +++ b/application/hub/main/listener/class_BaseListenerDecorator.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 BaseListenerDecorator extends BaseHubSystem implements Visitable { +class BaseListenerDecorator extends BaseDecorator implements Visitable { /** * Protected constructor * @@ -67,17 +67,11 @@ class BaseListenerDecorator extends BaseHubSystem implements Visitable { * @return void */ public function accept (Visitor $visitorInstance) { - // Debug message - //* DEBUG: */ $this->debugOutput('DECO-LISTENER: ' . $visitorInstance->__toString() . ' has visited - START'); - // Visit this decorator $visitorInstance->visitDecorator($this); // Visit the covered class $visitorInstance->visitListener($this); - - // Debug message - //* DEBUG: */ $this->debugOutput('DECO-LISTENER: ' . $visitorInstance->__toString() . ' has visited - FINISHED'); } } diff --git a/application/hub/main/listener/udp/decorators/class_ClientUdpListenerDecorator.php b/application/hub/main/listener/udp/decorators/class_ClientUdpListenerDecorator.php index 14f1150bc..fc9c40cb2 100644 --- a/application/hub/main/listener/udp/decorators/class_ClientUdpListenerDecorator.php +++ b/application/hub/main/listener/udp/decorators/class_ClientUdpListenerDecorator.php @@ -64,7 +64,7 @@ class ClientUdpListenerDecorator extends BaseListenerDecorator implements Listen * @return void */ public function doListen() { - // Look for generic packages first + // Handle generic UDP packages first $this->getListenerInstance()->doListen(); // Handle this client UDP package diff --git a/application/hub/main/listener/udp/decorators/class_HubUdpListenerDecorator.php b/application/hub/main/listener/udp/decorators/class_HubUdpListenerDecorator.php index dc0630cc0..09a6c4462 100644 --- a/application/hub/main/listener/udp/decorators/class_HubUdpListenerDecorator.php +++ b/application/hub/main/listener/udp/decorators/class_HubUdpListenerDecorator.php @@ -64,7 +64,7 @@ class HubUdpListenerDecorator extends BaseListenerDecorator implements Listenabl * @return void */ public function doListen() { - // Handle generic package first + // Handle generic UDP package first $this->getListenerInstance()->doListen(); // Handle hub UDP package diff --git a/application/hub/main/visitor/tasks/class_ActiveTaskVisitor.php b/application/hub/main/visitor/tasks/class_ActiveTaskVisitor.php index adbaf7010..ecfe21bef 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, QueryConnectorVisitor, PoolVisitor { +class ActiveTaskVisitor extends BaseVisitor implements TaskVisitor, QueryConnectorVisitor, PoolVisitor, ListenerVisitor, DecoratorVisitor { /** * Protected constructor * @@ -49,9 +49,9 @@ class ActiveTaskVisitor extends BaseVisitor implements TaskVisitor, QueryConnect } /** - * Visits the given pool instance + * Visits the given task instance * - * @param $poolInstance A Taskable instance + * @param $taskInstance A Taskable instance * @return void */ public function visitTask (Taskable $taskInstance) { @@ -92,6 +92,28 @@ class ActiveTaskVisitor extends BaseVisitor implements TaskVisitor, QueryConnect public function visitQuery (Queryable $queryInstance) { // Empty for now... } + + /** + * Visits the given listener instance + * + * @param $listenerInstance A Listenable instance + * @return void + */ + public function visitListener (Listenable $listenerInstance) { + // Do "listen" here + $listenerInstance->doListen(); + } + + /** + * Visits the given decorator instance + * + * @param $decoratorInstance A decorator instance + * @return void + */ + public function visitDecorator (BaseDecorator $decoratorInstance) { + // A decorator itself can never bevome an active task so this method + // remains empty. + } } // [EOF] diff --git a/docs/NEWS b/docs/NEWS index a1dc3cf19..7339625fe 100644 --- a/docs/NEWS +++ b/docs/NEWS @@ -1,6 +1,13 @@ NEWS / ChangeLog ================ +[2009-08-19] +------------ +- These news are not in correct timeline! +- Task handling added, first idle loop task added +- Listeners are now visiited by ActiveTaskVisitor +- Task added for self-tests, if the ports are reachable from public IP + [2009-08-03] ------------ - More debugging (and grep-able) output added @@ -50,3 +57,6 @@ FreeMind: ("unoffical" but newer packages) OpenOffice: http://www.openoffice.org + +Might Commander: +http://www.gnu.org/software/mc/ diff --git a/docs/TODOs.txt b/docs/TODOs.txt index d32831965..a56d53c69 100644 --- a/docs/TODOs.txt +++ b/docs/TODOs.txt @@ -1,8 +1,8 @@ ### WARNING: THIS FILE IS AUTO-GENERATED BY ./todo-builder.sh ### ### DO NOT EDIT THIS FILE. ### ./application/hub/interfaces/nodes/class_NodeHelper.php:10: * @todo We need to find a better name for this interface -./application/hub/main/commands/console/class_HubConsoleMainCommand.php:108: * @todo Should we add some more filters? -./application/hub/main/commands/console/class_HubConsoleMainCommand.php:91: // @TODO We may have to catch some exceptions here +./application/hub/main/commands/console/class_HubConsoleMainCommand.php:104: * @todo Should we add some more filters? +./application/hub/main/connectors/query/local/class_LocalQueryConnector.php:10: * @todo Find an interface for: handleAllQueries() ./application/hub/main/filter/node/class_NodeInitializationFilter.php:54: * @todo 0% done ./application/hub/main/filter/node/class_NodeInitializationFilter.php:87: // @TODO Can we rewrite this to app_die() ? ./application/hub/main/filter/shutdown/class_HubShutdownDeinitQueuesFilter.php:55: * @todo 0% done @@ -11,15 +11,18 @@ ./application/hub/main/filter/task/class_TaskHandlerInitializerFilter.php:55: * @todo 0% done ./application/hub/main/handler/network/tcp/class_TcpNetworkPackageHandler.php:61: * @todo 0% ./application/hub/main/handler/network/udp/class_UdpNetworkPackageHandler.php:55: * @todo 0% +./application/hub/main/handler/tasks/class_TaskHandler.php:140: // @TODO Messurement can be added around this call ./application/hub/main/iterator/network/class_NetworkListenIterator.php:10: * @todo This current implementation is not recommended, use a ./application/hub/main/iterator/network/class_NetworkListenIterator.php:11: * @todo latency-based iteration or similar approaches ./application/hub/main/iterator/pool/handler/class_HandlerPoolIterator.php:10: * @todo This current implementation is not recommended, use a ./application/hub/main/iterator/pool/handler/class_HandlerPoolIterator.php:11: * @todo latency-based iteration or similar approaches +./application/hub/main/iterator/pool/tasks/class_TaskPoolIterator.php:10: * @todo This current implementation is not recommended, use a +./application/hub/main/iterator/pool/tasks/class_TaskPoolIterator.php:11: * @todo latency-based iteration or similar approaches ./application/hub/main/listener/tcp/class_TcpListener.php:160: * @todo 0% done ./application/hub/main/listener/udp/class_UdpListener.php:61: * @todo stream_socket_server() was declared slow by some user comments. ./application/hub/main/listener/udp/class_UdpListener.php:62: * @todo Please rewrite it to socket_create() and its brothers. ./application/hub/main/listener/udp/class_UdpListener.php:85: * @todo 0% done -./application/hub/main/lists/class_BaseList.php:233: // @TODO Extend this somehow? +./application/hub/main/lists/class_BaseList.php:236: // @TODO Extend this somehow? ./application/hub/main/nodes/boot/class_HubBootNode.php:113: * @todo 0% ./application/hub/main/nodes/boot/class_HubBootNode.php:58: * @todo add some more special bootstrap things for this boot node ./application/hub/main/nodes/boot/class_HubBootNode.php:99: * @todo Unfinished method @@ -35,18 +38,18 @@ ./application/hub/main/nodes/regular/class_HubRegularNode.php:68: * @todo Unfinished method ./application/hub/main/nodes/regular/class_HubRegularNode.php:82: * @todo 0% ./application/hub/main/resolver/state/network/class_NetworkStateResolver.php:69: * @todo 0% -./application/hub/main/visitor/pool/handler/class_HandlerListenerPoolVisitor.php:56: * @todo Find some use of doListen() method in listener pool classes -./application/hub/main/visitor/pool/handler/class_HandlerListenerPoolVisitor.php:69: * @todo Find some use of doListen() method in listener decorator classes +./application/hub/main/tasks/hub/class_HubSelfConnectTask.php:53: * @todo 0% +./application/hub/main/visitor/tasks/class_ActiveTaskVisitor.php:90: * @todo Does a query needs to perform some actions as an active task? ./inc/classes/exceptions/io/class_FileNotFoundException.php:10: * @todo Rename this class to FileIoException ./inc/classes/exceptions/main/class_ClassNotFoundException.php:10: * @todo Rename this class to NoClassException ./inc/classes/exceptions/main/class_ConfigEntryNotFoundException.php:10: * @todo Rename this class to NoFoundEntryException ./inc/classes/exceptions/main/class_MissingMethodException.php:13: * @todo Try to rewrite user/guest login classes and mark this exception as deprecated ./inc/classes/interfaces/class_FrameworkInterface.php:11: * @todo Find a better name for this interface -./inc/classes/main/class_BaseFrameworkSystem.php:1040: * @todo Write a logging mechanism for productive mode -./inc/classes/main/class_BaseFrameworkSystem.php:104: // @todo Try to clean these constants up -./inc/classes/main/class_BaseFrameworkSystem.php:1054: // @TODO Finish this part! -./inc/classes/main/class_BaseFrameworkSystem.php:185: * @todo This is old code. Do we still need this old lost code? -./inc/classes/main/class_BaseFrameworkSystem.php:253: * @todo SearchableResult and UpdateableResult shall have a super interface to use here +./inc/classes/main/class_BaseFrameworkSystem.php:1045: * @todo Write a logging mechanism for productive mode +./inc/classes/main/class_BaseFrameworkSystem.php:1059: // @TODO Finish this part! +./inc/classes/main/class_BaseFrameworkSystem.php:109: // @todo Try to clean these constants up +./inc/classes/main/class_BaseFrameworkSystem.php:190: * @todo This is old code. Do we still need this old lost code? +./inc/classes/main/class_BaseFrameworkSystem.php:258: * @todo SearchableResult and UpdateableResult shall have a super interface to use here ./inc/classes/main/commands/web/class_WebLoginAreaCommand.php:64: * @todo Add some stuff here: Some personal data, app/game related data ./inc/classes/main/console/class_ConsoleTools.php:41: * @todo We should connect this to a caching class to cache DNS requests ./inc/classes/main/console/class_ConsoleTools.php:54: // @TODO Here should the cacher be implemented -- 2.39.2