]> git.mxchange.org Git - hub.git/commitdiff
Exceptions, interfaces and many classes added/rewritten:
authorRoland Häder <roland@mxchange.org>
Tue, 4 Aug 2009 23:28:37 +0000 (23:28 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 4 Aug 2009 23:28:37 +0000 (23:28 +0000)
- Exceptions for lists (Iterator Pattern) added
- Interfaces for Visitor Pattern added
- Interface Listable (Iterator Pattern) added
- Base listener extended with Visitor Pattern method accept()
- List and list group classes added (Iterator Pattern)
- Shutdown visitor class for listener pool added

34 files changed:
.gitattributes
application/hub/config.php
application/hub/exceptions/lists/.htaccess [new file with mode: 0644]
application/hub/exceptions/lists/class_ListGroupAlreadyAddedException.php [new file with mode: 0644]
application/hub/exceptions/lists/class_NoListGroupException.php [new file with mode: 0644]
application/hub/interfaces/listener/class_Listenable.php
application/hub/interfaces/lists/.htaccess [new file with mode: 0644]
application/hub/interfaces/lists/class_Listable.php [new file with mode: 0644]
application/hub/interfaces/visitor/class_Visitable.php
application/hub/interfaces/visitor/class_Visitor.php [new file with mode: 0644]
application/hub/interfaces/visitor/pool/.htaccess [new file with mode: 0644]
application/hub/interfaces/visitor/pool/class_PoolVisitor.php [new file with mode: 0644]
application/hub/main/iterator/.htaccess [new file with mode: 0644]
application/hub/main/iterator/class_ [new file with mode: 0644]
application/hub/main/iterator/class_BaseIterator.php [new file with mode: 0644]
application/hub/main/iterator/pool/.htaccess [new file with mode: 0644]
application/hub/main/iterator/pool/class_ShutdownPoolIterator.php [new file with mode: 0644]
application/hub/main/listener/class_BaseListener.php
application/hub/main/listener/class_BaseListenerDecorator.php
application/hub/main/lists/.htaccess [new file with mode: 0644]
application/hub/main/lists/class_ [new file with mode: 0644]
application/hub/main/lists/class_BaseList.php [new file with mode: 0644]
application/hub/main/lists/groups/.htaccess [new file with mode: 0644]
application/hub/main/lists/groups/class_ListGroupList.php [new file with mode: 0644]
application/hub/main/lists/pool/.htaccess [new file with mode: 0644]
application/hub/main/lists/pool/class_PoolEntriesList.php [new file with mode: 0644]
application/hub/main/pools/class_BasePool.php
application/hub/main/pools/listener/class_DefaultListenerPool.php
application/hub/main/visitor/.htaccess [new file with mode: 0644]
application/hub/main/visitor/class_ [new file with mode: 0644]
application/hub/main/visitor/class_BaseVisitor.php [new file with mode: 0644]
application/hub/main/visitor/shutdown/.htaccess [new file with mode: 0644]
application/hub/main/visitor/shutdown/class_Shutdown [new file with mode: 0644]
application/hub/main/visitor/shutdown/class_ShutdownListenerPoolVisitor.php [new file with mode: 0644]

index 7d24211cdd52b3eabc187d7c708815d7dc0fa904..13b2fc17b86db5e8db85606cf108fe70a0f34222 100644 (file)
@@ -8,12 +8,17 @@ application/hub/data.php -text
 application/hub/debug.php -text
 application/hub/exceptions.php -text
 application/hub/exceptions/.htaccess -text
+application/hub/exceptions/lists/.htaccess -text
+application/hub/exceptions/lists/class_ListGroupAlreadyAddedException.php -text
+application/hub/exceptions/lists/class_NoListGroupException.php -text
 application/hub/init.php -text
 application/hub/interfaces/.htaccess -text
 application/hub/interfaces/connectors/.htaccess -text
 application/hub/interfaces/connectors/class_Connectable.php -text
 application/hub/interfaces/listener/.htaccess -text
 application/hub/interfaces/listener/class_Listenable.php -text
+application/hub/interfaces/lists/.htaccess -text
+application/hub/interfaces/lists/class_Listable.php -text
 application/hub/interfaces/nodes/.htaccess -text
 application/hub/interfaces/nodes/class_NodeHelper.php -text
 application/hub/interfaces/pool/.htaccess -text
@@ -33,6 +38,9 @@ application/hub/interfaces/states/hub/.htaccess -text
 application/hub/interfaces/states/hub/class_HubStateable.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/pool/.htaccess -text
+application/hub/interfaces/visitor/pool/class_PoolVisitor.php -text
 application/hub/loader.php -text
 application/hub/main/.htaccess -text
 application/hub/main/class_ -text
@@ -84,6 +92,11 @@ application/hub/main/filter/shutdown/class_HubShutdownDeinitQueuesFilter.php -te
 application/hub/main/filter/shutdown/class_HubShutdownFlushNodeListFilter.php -text
 application/hub/main/filter/shutdown/class_HubShutdownListenerPoolFilter.php -text
 application/hub/main/filter/shutdown/class_HubShutdownNodeFilter.php -text
+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/listener/.htaccess -text
 application/hub/main/listener/class_ -text
 application/hub/main/listener/class_BaseListener.php -text
@@ -100,6 +113,13 @@ 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
 application/hub/main/listener/udp/decorators/class_HubUdpListenerDecorator.php -text
+application/hub/main/lists/.htaccess -text
+application/hub/main/lists/class_ -text
+application/hub/main/lists/class_BaseList.php -text
+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/nodes/.htaccess -text
 application/hub/main/nodes/boot/.htaccess -text
 application/hub/main/nodes/boot/class_HubBootNode.php -text
@@ -137,6 +157,12 @@ application/hub/main/states/client/.htaccess -text
 application/hub/main/states/client/class_BaseClientState.php -text
 application/hub/main/states/hub/.htaccess -text
 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/starter.php -text
 /clear-cache.sh -text
 db/.htaccess -text
index 3a549b1ba13836e7ce854b24fa046402144cee70..e824a269574c264bd09fdf9f6701ce700f0a5904 100644 (file)
@@ -84,6 +84,18 @@ $cfg->setConfigEntry('client_udp_listener_class', 'ClientUdpListenerDecorator');
 // CFG: CLIENT-POOL-CLASS
 $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-POOL-ITERATOR-CLASS
+$cfg->setConfigEntry('shutdown_pool_iterator_class', 'ShutdownPoolIterator');
+
+// CFG: LIST-GROUP-CLASS
+$cfg->setConfigEntry('list_group_class', 'ListGroupList');
+
 // CFG: DEFAULT-CONSOLE-COMMAND
 $cfg->setConfigEntry('default_console_command', 'main');
 
diff --git a/application/hub/exceptions/lists/.htaccess b/application/hub/exceptions/lists/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/exceptions/lists/class_ListGroupAlreadyAddedException.php b/application/hub/exceptions/lists/class_ListGroupAlreadyAddedException.php
new file mode 100644 (file)
index 0000000..d401037
--- /dev/null
@@ -0,0 +1,45 @@
+<?php
+/**
+ * This exception is thrown when a list group is already added
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class ListGroupAlreadyAddedException extends FrameworkException {
+       /**
+        * The super constructor for all exceptions
+        *
+        * @param               $messageArray   Error message array
+        * @param               $code                   Error code
+        * @return      void
+        */
+       public function __construct (array $messageArray, $code) {
+               // Construct the message
+               $message = sprintf("[%s] List group <span class=\"exception_reason\">%s</span> has already been added.",
+                       $messageArray[0]->__toString(),
+                       $messageArray[1]
+               );
+
+               // Call parent exception constructor
+               parent::__construct($message, $code);
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/exceptions/lists/class_NoListGroupException.php b/application/hub/exceptions/lists/class_NoListGroupException.php
new file mode 100644 (file)
index 0000000..ee8e282
--- /dev/null
@@ -0,0 +1,45 @@
+<?php
+/**
+ * This exception is thrown when a list group is not found
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class NoListGroupException extends FrameworkException {
+       /**
+        * The super constructor for all exceptions
+        *
+        * @param               $messageArray   Error message array
+        * @param               $code                   Error code
+        * @return      void
+        */
+       public function __construct (array $messageArray, $code) {
+               // Construct the message
+               $message = sprintf("[%s] List group <span class=\"exception_reason\">%s</span> was not found.",
+                       $messageArray[0]->__toString(),
+                       $messageArray[1]
+               );
+
+               // Call parent exception constructor
+               parent::__construct($message, $code);
+       }
+}
+
+// [EOF]
+?>
index a8e9ed30bb2e9181ee4ca710869de720b301d256..ede2b555fe56d23b9265718ba28f38158bc8067f 100644 (file)
@@ -21,7 +21,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
-interface Listenable {
+interface Listenable extends FrameworkInterface {
        /**
         * Initializes the listener by setting up the required socket server
         *
diff --git a/application/hub/interfaces/lists/.htaccess b/application/hub/interfaces/lists/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/interfaces/lists/class_Listable.php b/application/hub/interfaces/lists/class_Listable.php
new file mode 100644 (file)
index 0000000..d2b26b9
--- /dev/null
@@ -0,0 +1,65 @@
+<?php
+/**
+ * An interface for lists
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+interface Listable extends FrameworkInterface, IteratorAggregate {
+       /**
+        * Checks wether the given group is set
+        *
+        * @param       $groupName      Group to check if found in list
+        * @return      $isset          Wether the group is valid
+        */
+       function isGroupSet ($groupName);
+
+       /**
+        * Adds the given group or if already added issues a ListGroupAlreadyAddedException
+        *
+        * @param       $groupName      Group to add
+        * @return      void
+        * @throws      ListGroupAlreadyAddedException  If the given group is already added
+        */
+       function addGroup ($groupName);
+
+       /**
+        * Adds the given instance to list group and sub group
+        *
+        * @param       $groupName      Group to add instance to
+        * @param       $subGroup       Sub group to add instance to
+        * @param       $instance       An instance of Visitable
+        * @return      void
+        * @throws      NoListGroupException    If the given group is not found
+        */
+       function addInstance ($groupName, $subGroup, Visitable $instance);
+
+       /**
+        * Adds the given entry to list group
+        *
+        * @param       $groupName      Group to add instance to
+        * @param       $entry          An entry of any type
+        * @return      void
+        * @throws      NoListGroupException    If the given group is not found
+        */
+       function addEntry ($groupName, $entry);
+}
+
+//
+?>
index f91e448a4f063b3b05315cc04762295be4afbd9e..8319c3163bd34394cf7852f17b1de865864070e8 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * An interface for the visitor pattern
+ * An interface for a visitable class that 'accepts' visitors
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 interface Visitable extends FrameworkInterface {
+       /**
+        * Accepts the visitor to rpocess the visit "request"
+        *
+        * @param       $visitorInstance        An instance of a Visitor class
+        * @return      void
+        */
+       function accept (Visitor $visitorInstance);
 }
 
 //
diff --git a/application/hub/interfaces/visitor/class_Visitor.php b/application/hub/interfaces/visitor/class_Visitor.php
new file mode 100644 (file)
index 0000000..e2bce79
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+/**
+ * An interface for the visitor implementation
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+interface Visitor extends FrameworkInterface {
+}
+
+//
+?>
diff --git a/application/hub/interfaces/visitor/pool/.htaccess b/application/hub/interfaces/visitor/pool/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/interfaces/visitor/pool/class_PoolVisitor.php b/application/hub/interfaces/visitor/pool/class_PoolVisitor.php
new file mode 100644 (file)
index 0000000..f7df689
--- /dev/null
@@ -0,0 +1,35 @@
+<?php
+/**
+ * An interface for the visitor implementation for pools
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+interface PoolVisitor extends Visitor {
+       /**
+        * Visits the given pool instance
+        *
+        * @param       $poolInstance   A Poolable instance
+        * @return      void
+        */
+       function visitPool (Poolable $poolInstance);
+}
+
+//
+?>
diff --git a/application/hub/main/iterator/.htaccess b/application/hub/main/iterator/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/iterator/class_ b/application/hub/main/iterator/class_
new file mode 100644 (file)
index 0000000..a259cea
--- /dev/null
@@ -0,0 +1,107 @@
+<?php
+/**
+ * A ??? iterator
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+class ???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 create???Iterator () {
+               // Get new instance
+               $iteratorInstance = new ???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/class_BaseIterator.php b/application/hub/main/iterator/class_BaseIterator.php
new file mode 100644 (file)
index 0000000..bea332d
--- /dev/null
@@ -0,0 +1,62 @@
+<?php
+/**
+ * A general iterator
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+class BaseIterator extends BaseHubSystem {
+       /**
+        * Instance of the list
+        */
+       private $listInstance = null;
+
+       /**
+        * Protected constructor
+        *
+        * @param       $className      Name of the class
+        * @return      void
+        */
+       protected function __construct ($className) {
+               // Call parent constructor
+               parent::__construct($className);
+       }
+
+       /**
+        * Setter for the list instance
+        *
+        * @param       $listInstance   A list of IteratorAggregate
+        * @return      void
+        */
+       protected final function setListInstance (IteratorAggregate $listInstance) {
+               $this->listInstance = $listInstance;
+       }
+
+       /**
+        * Getter for the list instance
+        *
+        * @return      $listInstance   A list of IteratorAggregate
+        */
+       protected final function getListInstance () {
+               return $this->listInstance;
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/iterator/pool/.htaccess b/application/hub/main/iterator/pool/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/iterator/pool/class_ShutdownPoolIterator.php b/application/hub/main/iterator/pool/class_ShutdownPoolIterator.php
new file mode 100644 (file)
index 0000000..d6a16f5
--- /dev/null
@@ -0,0 +1,111 @@
+<?php
+/**
+ * A ShutdownPool iterator
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+class ShutdownPoolIterator extends BaseIterator implements Iterator {
+       /**
+        * 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
+        */
+       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]
+?>
index f06b7f25982acce827d1e8303d19be8d729e9cf3..0fce415d1de27246053ca13ea3582883f8cbffdf 100644 (file)
@@ -199,6 +199,26 @@ class BaseListener extends BaseHubSystem implements Visitable {
        protected final function getPoolInstance () {
                return $this->poolInstance;
        }
+
+       /**
+        * Accepts the visitor to rpocess the visit "request"
+        *
+        * @param       $visitorInstance        An instance of a Visitor class
+        * @return      void
+        */
+       public function accept (Visitor $visitorInstance) {
+               // Debug message
+               $this->debugOutput('LISTENER: ' . $visitorInstance->__toString() . ' has visited - START');
+
+               // Visit this listener
+               $visitorInstance->visitListener($this);
+
+               // Visit the pool
+               $this->getPoolInstance()->accept($visitor);
+
+               // Debug message
+               $this->debugOutput('LISTENER: ' . $visitorInstance->__toString() . ' has visited - FINISHED');
+       }
 }
 
 // [EOF]
index fd0a3f2b102b69a143c16f8e1fe9b729b5f73e92..fe412f7aa74a78a38dffeb4b3af82f596d371d61 100644 (file)
@@ -63,6 +63,26 @@ class BaseListenerDecorator extends BaseHubSystem implements Visitable {
        public final function getProtocol () {
                return $this->getListenerInstance()->getProtocol();
        }
+
+       /**
+        * Accepts the visitor to rpocess the visit "request"
+        *
+        * @param       $visitorInstance        An instance of a Visitor class
+        * @return      void
+        */
+       public function accept (Visitor $visitorInstance) {
+               // Debug message
+               $this->debugOutput('DECO-LISTENER: ' . $visitorInstance->__toString() . ' has visited - START');
+
+               // Visit this decorator
+               $visitorInstance->visitDecorator($this);
+
+               // Visit the covered class
+               $this->getListenerInstance()->accept($visitorInstance);
+
+               // Debug message
+               $this->debugOutput('DECO-LISTENER: ' . $visitorInstance->__toString() . ' has visited - FINISHED');
+       }
 }
 
 // [EOF]
diff --git a/application/hub/main/lists/.htaccess b/application/hub/main/lists/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/lists/class_ b/application/hub/main/lists/class_
new file mode 100644 (file)
index 0000000..fa85737
--- /dev/null
@@ -0,0 +1,50 @@
+<?php
+/**
+ * A ??? list
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+class ???List 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 create???List () {
+               // Get new instance
+               $listInstance = new ???List();
+
+               // Return the prepared instance
+               return $listInstance;
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/lists/class_BaseList.php b/application/hub/main/lists/class_BaseList.php
new file mode 100644 (file)
index 0000000..c810639
--- /dev/null
@@ -0,0 +1,208 @@
+<?php
+/**
+ * A general list class
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+class BaseList extends BaseHubSystem implements IteratorAggregate {
+       // Exception constants
+       const EXCEPTION_GROUP_ALREADY_ADDED = 0xf20;
+       const EXCEPTION_GROUP_NOT_FOUND     = 0xf21;
+
+       /**
+        * List groups array
+        */
+       private $listGroups = array();
+
+       /**
+        * List entries array
+        */
+       private $listEntries = array();
+
+       /**
+        * List index array
+        */
+       private $listIndex = array();
+
+       /**
+        * Protected constructor
+        *
+        * @param       $className      Name of the class
+        * @return      void
+        */
+       protected function __construct ($className) {
+               // Call parent constructor
+               parent::__construct($className);
+
+               // Remove some attributes
+               $this->removeNumberFormaters();
+               $this->removeSystemArray();
+       }
+
+       /**
+        * Getter for iterator instance from this list
+        *
+        * @return      $iteratorInstance       An instance of a Iterator class
+        */
+       public function getIterator () {
+               // Prepare a default iterator
+               $iteratorInstance = ObjectFactory::createObjectByConfiguredName('default_iterator_class');
+
+               // And return it
+               return $iteratorInstance;
+       }
+
+       /**
+        * Checks wether the given group is set
+        *
+        * @param       $groupName      Group to check if found in list
+        * @return      $isset          Wether the group is valid
+        */
+       public function isGroupSet ($groupName) {
+               //* DEBUG: */ $this->debugOutput(__METHOD__.': '.$groupName);
+               return isset($this->listGroups[$groupName]);
+       }
+
+       /**
+        * Adds the given group or if already added issues a ListGroupAlreadyAddedException
+        *
+        * @param       $groupName      Group to add
+        * @return      void
+        * @throws      ListGroupAlreadyAddedException  If the given group is already added
+        */
+       public function addGroup ($groupName) {
+               //* DEBUG: */ $this->debugOutput(__METHOD__.': '.$groupName . ' - START');
+               // Is the group already added?
+               if ($this->isGroupSet($groupName)) {
+                       // Throw the exception here
+                       throw new ListGroupAlreadyAddedException(array($this, $groupName), self::EXCEPTION_GROUP_ALREADY_ADDED);
+               } // END - if
+
+               // Add the group which is a simple array
+               $this->listGroups[$groupName] = ObjectFactory::createObjectByConfiguredName('list_group_class');
+               //* DEBUG: */ $this->debugOutput(__METHOD__.': '.$groupName . ' - FINISHED');
+       }
+
+       /**
+        * Adds the given instance to list group and sub group
+        *
+        * @param       $groupName      Group to add instance to
+        * @param       $subGroup       Sub group to add instance to
+        * @param       $instance       An instance of Visitable
+        * @return      void
+        * @throws      NoListGroupException    If the given group is not found
+        */
+       public function addInstance ($groupName, $subGroup, Visitable $instance) {
+               //* DEBUG: */ $this->debugOutput(__METHOD__.': '.$groupName  . '/' . $subGroup . ' - START');
+               // Is the group there?
+               if (!$this->isGroupSet($groupName)) {
+                       // Throw the exception here
+                       throw new NoListGroupException(array($this, $groupName), self::EXCEPTION_GROUP_NOT_FOUND);
+               } // END - if
+
+               // Is the sub group there?
+               if (!$this->listGroups[$groupName]->isGroupSet($subGroup)) {
+                       // Automatically add it
+                       $this->listGroups[$groupName]->addGroup($subGroup);
+               } // END - if
+
+               // Generate the hash
+               $hash = $this->generateHash($groupName, $subGroup, $instance);
+
+               // Now add it to the group list and hash it
+               $this->listGroups[$groupName]->addEntry($subGroup, $hash);
+
+               // Add the hash to the index
+               $this->listIndex[] = $hash;
+
+               // Add the instance itself to the list
+               $this->listEntries[$hash] = $instance;
+               //* DEBUG: */ $this->debugOutput(__METHOD__.': '.$groupName  . '/' . $subGroup . ' - START');
+       }
+
+       /**
+        * Adds the given entry to list group
+        *
+        * @param       $groupName      Group to add instance to
+        * @param       $entry          An entry of any type
+        * @return      void
+        * @throws      NoListGroupException    If the given group is not found
+        */
+       public function addEntry ($groupName, $entry) {
+               //* DEBUG: */ $this->debugOutput(__METHOD__.': '.$groupName . ' - START');
+               // Is the group already added?
+               if (!$this->isGroupSet($groupName)) {
+                       // Throw the exception here
+                       throw new NoListGroupException(array($this, $groupName), self::EXCEPTION_GROUP_NOT_FOUND);
+               } // END - if
+
+               // Generate hash
+               $hash = $this->generateHash($groupName, $groupName, $entry);
+
+               // Add the hash to the index
+               $this->listIndex[] = $hash;
+
+               // Now add the entry to the list
+               $this->listEntries[$hash] = $entry;
+               //* DEBUG: */ $this->debugOutput(__METHOD__.': '.$groupName . ' - FINISHED');
+       }
+
+       /**
+        * Generates a hash from given group, sub group and entry
+        *
+        * @param       $groupName      Group to add instance to
+        * @param       $subGroup       Sub group to add instance to
+        * @param       $entry          An entry of any type
+        * @return      $hash           The generated
+        */
+       private function generateHash ($groupName, $subGroup, $entry) {
+               // Created entry, 'null' is default
+               $entry2 = 'null';
+
+               // Determine type of entry
+               if (is_null($entry)) {
+                       // Ignore this
+               } elseif ($entry instanceof FrameworkInterface) {
+                       // Own instance detected
+                       $entry2 = $entry->hashCode();
+               } elseif (!is_array($entry)) {
+                       // Non-array found, use it directly with type
+                       $entry2 = gettype($entry) . ':' . $entry2;
+               } else {
+                       // Arrays are unsupported at the momement
+                       $this->debugOutut(__METHOD__ . ': entry is an array. UNSUPPORTED!');
+
+                       // @TODO Extend this somehow?
+                       $entry2 = gettype($entry);
+               }
+
+               // Construct string which we shall hash
+               $hashString = $groupName . ':' . $subGroup . ':' . $entry2;
+
+               // Hash it with fastest hasher
+               $hash = crc32($hashString);
+
+               // And return it
+               return $hash;
+       }
+}
+
+//
+?>
diff --git a/application/hub/main/lists/groups/.htaccess b/application/hub/main/lists/groups/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/lists/groups/class_ListGroupList.php b/application/hub/main/lists/groups/class_ListGroupList.php
new file mode 100644 (file)
index 0000000..1cf1062
--- /dev/null
@@ -0,0 +1,50 @@
+<?php
+/**
+ * A ListGroup list
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+class ListGroupList 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 createListGroupList () {
+               // Get new instance
+               $listInstance = new ListGroupList();
+
+               // Return the prepared instance
+               return $listInstance;
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/lists/pool/.htaccess b/application/hub/main/lists/pool/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/lists/pool/class_PoolEntriesList.php b/application/hub/main/lists/pool/class_PoolEntriesList.php
new file mode 100644 (file)
index 0000000..8fce67e
--- /dev/null
@@ -0,0 +1,53 @@
+<?php
+/**
+ * A list for pool entries
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+class PoolEntriesList 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 createPoolEntriesList () {
+               // Get new instance
+               $listInstance = new PoolEntriesList();
+
+               // Add generic group
+               $listInstance->addGroup('generic');
+
+               // Return the prepared instance
+               return $listInstance;
+       }
+}
+
+//
+?>
index b585fc2ca4a1b624669982563daedd15071abb33..0a52e48358c78c36a6ce0b071999ce95a53ab83f 100644 (file)
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
-class BasePool extends BaseHubSystem {
+class BasePool extends BaseHubSystem implements Visitable {
        /**
         * A list of pool entries
         */
-       private $poolEntries = array();
+       private $poolEntriesInstance = null;
 
        /**
         * Protected constructor
@@ -36,6 +36,9 @@ class BasePool extends BaseHubSystem {
        protected function __construct ($className) {
                // Call parent constructor
                parent::__construct($className);
+
+               // Init the pool entries
+               $this->poolEntriesInstance = ObjectFactory::createObjectByConfiguredName('pool_entries_list_class');
        }
 
        /**
@@ -47,7 +50,14 @@ class BasePool extends BaseHubSystem {
         * @return      void
         */
        protected final function addInstance ($group, $poolName, Visitable $instance) {
-               $this->poolEntries[$group][$poolName][] = $instance;
+               // Is the pool group there?
+               if (!$this->poolEntriesInstance->isGroupSet($group)) {
+                       // Create the missing pool group
+                       $this->poolEntriesInstance->addGroup($group);
+               } // END - if
+
+               // Add it to given pool group
+               $this->poolEntriesInstance->addInstance($group, $poolName, $instance);
        }
 
        /**
@@ -57,7 +67,48 @@ class BasePool extends BaseHubSystem {
         * @return      void
         */
        protected final function addPoolEntry ($poolEntry) {
-               $this->poolEntries[] = $poolEntry;
+               $this->poolEntriesInstance->addEntry('generic', $poolEntry);
+       }
+
+       /**
+        * Accepts the visitor to rpocess the visit "request"
+        *
+        * @param       $visitorInstance        An instance of a Visitor class
+        * @return      void
+        */
+       public function accept (Visitor $visitorInstance) {
+               // Debug message
+               $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));
+
+               // Reset the counter
+               $iteratorInstance->rewind();
+
+               // Visit all registered entries
+               while ($iteratorInstance->valid()) {
+                       // Get current entry
+                       $poolEntry = $iteratorInstance->current();
+
+                       // Is this entry visitable?
+                       if ($poolEntry instanceof Visitable) {
+                               // Visit this entry as well
+                               $poolEntry->accept($visitorInstance);
+                       } else {
+                               // Cannot visit this entry
+                               $this->partialStub('Pool entry with key ' . $iteratorInstance->key() . ' has improper type ' . gettype($poolEntry) . '.');
+                       }
+
+                       // Advance to next entry
+                       $iteratorInstance->next();
+               } // END - while
+
+               // Debug message
+               $this->debugOutput('POOL: ' . $visitorInstance->__toString() . ' has visited - FINISHED');
        }
 }
 
index fce149e502d089873739c727f21097db4836d2c2..99579c55cee87fcf04318f5c9d8152aa0917b3c7 100644 (file)
@@ -66,6 +66,25 @@ class DefaultListenerPool extends BasePool implements PoolableListener {
                        $listenerInstance->getListenPort() . ' added to listener pool.'
                );
        }
+
+       /**
+        * Run the shutdown seqeuence by a Visitor Pattern
+        *
+        * @return      void
+        */
+       public function doShutdown () {
+               // Debug message
+               $this->debugOutput('POOL: Shutting down listener pool - START');
+
+               // Get a new visitor
+               $visitorInstance = ObjectFactory::createObjectByConfiguredName('listener_pool_visitor_class');
+
+               // Start visiting
+               $this->accept($visitorInstance);
+
+               // Debug message
+               $this->debugOutput('POOL: Shutting down listener pool - FINISHED');
+       }
 }
 
 // [EOF]
diff --git a/application/hub/main/visitor/.htaccess b/application/hub/main/visitor/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/visitor/class_ b/application/hub/main/visitor/class_
new file mode 100644 (file)
index 0000000..aa602f2
--- /dev/null
@@ -0,0 +1,50 @@
+<?php
+/**
+ * A ??? visitor
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+class ???Visitor extends BaseVisitor implements Visitor {
+       /**
+        * 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 create???Visitor () {
+               // Get new instance
+               $visitorInstance = new ???Visitor();
+
+               // Return the prepared instance
+               return $visitorInstance;
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/visitor/class_BaseVisitor.php b/application/hub/main/visitor/class_BaseVisitor.php
new file mode 100644 (file)
index 0000000..a955ea6
--- /dev/null
@@ -0,0 +1,42 @@
+<?php
+/**
+ * A general visitor class
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+class BaseVisitor extends BaseHubSystem {
+       /**
+        * Protected constructor
+        *
+        * @param       $className      Name of the class
+        * @return      void
+        */
+       protected function __construct ($className) {
+               // Call parent constructor
+               parent::__construct($className);
+
+               // Remove some attributes
+               $this->removeNumberFormaters();
+               $this->removeSystemArray();
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/visitor/shutdown/.htaccess b/application/hub/main/visitor/shutdown/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/visitor/shutdown/class_Shutdown b/application/hub/main/visitor/shutdown/class_Shutdown
new file mode 100644 (file)
index 0000000..59511aa
--- /dev/null
@@ -0,0 +1,50 @@
+<?php
+/**
+ * A ??? shutdown visitor
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+class Shutdown???Visitor extends BaseVisitor implements PoolVisitor {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $visitorInstance                An instance a Visitorable class
+        */
+       public final static function createShutdown???Visitor () {
+               // Get new instance
+               $visitorInstance = new Shutdown???Visitor();
+
+               // Return the prepared instance
+               return $visitorInstance;
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/visitor/shutdown/class_ShutdownListenerPoolVisitor.php b/application/hub/main/visitor/shutdown/class_ShutdownListenerPoolVisitor.php
new file mode 100644 (file)
index 0000000..d4ca881
--- /dev/null
@@ -0,0 +1,67 @@
+<?php
+/**
+ * A ListenerPool shutdown visitor
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+class ShutdownListenerPoolVisitor extends BaseVisitor implements PoolVisitor {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $visitorInstance                An instance a Visitorable class
+        */
+       public final static function createShutdownListenerPoolVisitor () {
+               // Get new instance
+               $visitorInstance = new ShutdownListenerPoolVisitor();
+
+               // Return the prepared instance
+               return $visitorInstance;
+       }
+
+       /**
+        * Visits the given pool instance
+        *
+        * @param       $poolInstance   A Poolable instance
+        * @return      void
+        */
+       public function visitPool (Poolable $poolInstance) {
+               // Debug message
+               $this->debugOutput('VISITOR: Visit of ' . $poolInstance->__toString() . ' - START');
+
+               // Pre-shutdown the pool
+               $poolInstance->preShutdown();
+
+               // Debug message
+               $this->debugOutput('VISITOR: Visit of ' . $poolInstance->__toString() . ' - FINISHED');
+       }
+}
+
+//
+?>