]> git.mxchange.org Git - hub.git/commitdiff
Introduced getListIterator() to all lists implementing Listable
authorRoland Häder <roland@mxchange.org>
Mon, 18 Apr 2011 22:08:56 +0000 (22:08 +0000)
committerRoland Häder <roland@mxchange.org>
Mon, 18 Apr 2011 22:08:56 +0000 (22:08 +0000)
13 files changed:
application/hub/config.php
application/hub/interfaces/lists/class_Listable.php
application/hub/main/connectors/query/local/class_LocalQueryConnector.php
application/hub/main/handler/network/class_BaseNetworkPackageHandler.php
application/hub/main/handler/network/tcp/class_TcpNetworkPackageHandler.php
application/hub/main/listener/tcp/class_TcpListener.php
application/hub/main/lists/groups/class_ListGroupList.php
application/hub/main/lists/hub/class_HubList.php
application/hub/main/lists/pool/class_PoolEntriesList.php
application/hub/main/lists/query/local/class_LocalQueryList.php
application/hub/main/lists/recipient/class_RecipientList.php
application/hub/main/lists/tasks/class_TaskList.php
application/hub/main/tasks/hub/ping/class_HubPingTask.php

index f0dfaa5a1f57b891a93d9dc70df404ffb9ace89b..d650da5b68e30173bfc6f9aabb6f103ad2d51920 100644 (file)
@@ -240,6 +240,9 @@ $cfg->setConfigEntry('code_template_type', 'xml');
 // CFG: PACKAGE-STACKER-CLASS
 $cfg->setConfigEntry('network_package_stacker_class', 'FiFoStacker');
 
+// CFG: NODE-RAW-DATA-STACKER-CLASS
+$cfg->setConfigEntry('node_raw_data_stacker_class', 'FiFoStacker');
+
 // CFG: PRODUCER-OUTGOING-QUEUE
 $cfg->setConfigEntry('producer_outgoing_queue', 'FiFoStacker');
 
index eb570137c0895f48e8008238adf1cfdebe594681..caac23f3c23e636653efed4ca7fb2787e6b19a2f 100644 (file)
@@ -69,6 +69,13 @@ interface Listable extends FrameworkInterface, IteratorAggregate {
         * @throws      InvalidListHashException        If the solved hash index is invalid
         */
        function updateCurrentEntryByHash ($hash, array $entryArray);
+
+       /**
+        * "Getter" for an iterator instance of this list
+        *
+        * @return      $iteratorInstance       An instance of a Iterator class
+        */
+       function getListIterator ();
 }
 
 // [EOF]
index b44b560ac9ae3111d1f4909f1049b6f9ea0498a7..d9e826827b82423a62a3981c2b98aa017a41b84d 100644 (file)
@@ -61,7 +61,7 @@ class LocalQueryConnector extends BaseQueryConnector implements Connectable, Vis
                $connectorInstance->setListInstance($listInstance);
 
                // Prepare iterator instance
-               $iteratorInstance = ObjectFactory::createObjectByConfiguredName('query_iterator_class', array($listInstance));
+               $iteratorInstance = $listInstance->getListIterator();
 
                // Set it, too
                $connectorInstance->setIteratorInstance($iteratorInstance);
index 3e63996459fdb345cd876e6ff04f5c74b3fb712d..2cd9d1661f04fc5d821a9d7e10de82e365ec5de9 100644 (file)
@@ -58,6 +58,38 @@ class BaseNetworkPackageHandler extends BaseHandler {
 
                // Set it in this network-package handler
                $this->setInputStreamInstance($streamInstance);
+
+               // Init stacker instance for processed raw data
+               $stackerInstance = ObjectFactory::createObjectByConfiguredName('node_raw_data_stacker_class');
+
+               // Remember this in this package handler
+               $this->setStackerInstance($stackerInstance);
+
+               // Init stacker
+               $this->initStacker();
+       }
+
+       /**
+        * Initializes the stacker for raw data
+        *
+        * @return      void
+        */
+       protected function initStacker () {
+               $this->getStackerInstance()->initStacker('raw_data');
+       }
+
+       /**
+        * Adds given decoded data to the raw data stacker
+        *
+        * @param       $decodedData    Decoded data from the socket resource
+        * @return      void
+        */
+       protected function addDecodedDataToStacker ($decodedData) {
+               // Add it
+               $this->getStackerInstance()->pushNamed('raw_data', array(
+                       'decoded_data' => $decodedData,
+                       'error_code'   => $this->getErrorCode()
+               ));
        }
 
        /**
index 3dd47493e143365735f2e3c3ceff655cd839fa1e..ab841180d8c4d622ce920567a5ddc45e71f894de 100644 (file)
@@ -44,8 +44,6 @@ class TcpNetworkPackageHandler extends BaseNetworkPackageHandler implements Netw
                // Get new instance
                $handlerInstance = new TcpNetworkPackageHandler();
 
-               // Init stacker instance for processed raw data
-               $stackerInstance = ObjectFactory::createObjectByConfiguredName('
                // Return the prepared instance
                return $handlerInstance;
        }
@@ -100,6 +98,7 @@ class TcpNetworkPackageHandler extends BaseNetworkPackageHandler implements Netw
                }
 
                // Add the (maybe above decoded) data and error code to the stacker
+               $this->addRawDataToStacker($decodedData);
        }
 }
 
index c972c1f5f6d6a156e33f1ae71ab38ce8e4f17141..005831ffc2f9c5e4676e3805fa910d765aba8cf6 100644 (file)
@@ -249,8 +249,8 @@ class TcpListener extends BaseListener implements Listenable {
         * @param       $packageData    Raw package data
         * @return      $accepts                Wether this listener does accept
         */
-       function ifListenerAcceptsPackageData (array $packageData) {
-               $this->partialStub('This call should not happen. Please report.');
+       public function ifListenerAcceptsPackageData (array $packageData) {
+               $this->partialStub('This call should not happen. Please report it.');
        }
 }
 
index ae59c8d50d01162d3e62833defa7dc84b9599836..045569349719349e9f1d00f55991800cecbca65b 100644 (file)
@@ -44,7 +44,16 @@ class ListGroupList extends BaseList implements Listable {
                // Return the prepared instance
                return $listInstance;
        }
-}
+
+       /**
+        * "Getter" for an iterator instance of this list
+        *
+        * @return      $iteratorInstance       An instance of a Iterator class
+        * @todo        0% done
+        */
+       public function getListIterator () {
+               $this->partialStub('Please implement this method.');
+       }
 
 // [EOF]
 ?>
index 3fb84610e3460196eb4b82d08ce9de04a47c52b1..c663de19d4e3607a3f5b6dbe3c060bd97225abd4 100644 (file)
@@ -48,6 +48,16 @@ class HubList extends BaseList implements Listable {
                // Return the prepared instance
                return $listInstance;
        }
+
+       /**
+        * "Getter" for an iterator instance of this list
+        *
+        * @return      $iteratorInstance       An instance of a Iterator class
+        * @todo0% done
+        */
+       public function getListIterator () {
+               $this->partialStub('Please implement this method.');
+       }
 }
 
 // [EOF]
index abfe382384c7b379a20b91a8301446ff5879126b..4c220837390bc8a6c5f56b518bc7ef62426eafe7 100644 (file)
@@ -47,7 +47,23 @@ class PoolEntriesList extends BaseList implements Listable {
                // Return the prepared instance
                return $listInstance;
        }
+
+       /**
+        * "Getter" for an iterator instance of this list
+        *
+        * @return      $iteratorInstance       An instance of a Iterator class
+        */
+       public function getListIterator () {
+               // Get the iterator instance from the factory
+               $iteratorInstance = ObjectFactory::createObjectByConfiguredName('hub_ping_iterator_class', array($this));
+
+               // Rewind it
+               $iteratorInstance->rewind();
+
+               // ... and return it
+               return $iteratorInstance;
+       }
 }
 
-//
+// [EOF]
 ?>
index b07f2ed3e758a6d3f9b25534d30a1c03cc28cc22..e364c0ff45ced2c627377f768092f9ca80f14ad2 100644 (file)
@@ -44,6 +44,22 @@ class LocalQueryList extends BaseList implements Listable {
                // Return the prepared instance
                return $listInstance;
        }
+
+       /**
+        * "Getter" for iterator from this list
+        *
+        * @return      $iteratorInstance       An instance of a Iterator class
+        */
+       public function getListIterator () {
+               // Get the instance from factory
+               $iteratorInstance = ObjectFactory::createObjectByConfiguredName('query_iterator_class', array($this));
+
+               // Rewind it
+               $iteratorInstance->rewind();
+
+               // ... and return it
+               return $iteratorInstance;
+       }
 }
 
 // [EOF]
index 1f58106ff2a3d443cc2c806facd9e2ac75f296f7..538eb7476c3745ac33aff2525357519a646d5432 100644 (file)
@@ -51,6 +51,16 @@ class RecipientList extends BaseList implements Listable, Registerable {
                // Return the prepared instance
                return $listInstance;
        }
+
+       /**
+        * "Getter" for an iterator instance of this list
+        *
+        * @return      $iteratorInstance       An instance of a Iterator class
+        * @todo0% done
+        */
+       public function getListIterator () {
+               $this->partialStub('Please implement this method.');
+       }
 }
 
 // [EOF]
index fb190ebbcc39fd42d19771c0a30512956ad61f02..d5402dc720bfba50e0b1cd8dfb627bd8795306ec 100644 (file)
@@ -47,6 +47,16 @@ class TaskList extends BaseList implements Listable {
                // Return the prepared instance
                return $listInstance;
        }
+
+       /**
+        * "Getter" for an iterator instance of this list
+        *
+        * @return      $iteratorInstance       An instance of a Iterator class
+        * @todo0% done
+        */
+       public function getListIterator () {
+               $this->partialStub('Please implement this method.');
+       }
 }
 
 // [EOF]
index 19ad14978ede3406fdc7f3e27d8a4cc31a95296c..d63c04f05a0917f2d75931278952788acb73e9dd 100644 (file)
@@ -46,7 +46,7 @@ class HubPingTask extends BaseTask implements Taskable, Visitable {
                $taskInstance->setListInstance($listInstance);
 
                // Init ping iterator instance
-               $iteratorInstance = ObjectFactory::createObjectByConfiguredName('hub_ping_iterator_class', array($listInstance));
+               $iteratorInstance = $listInstance->getListIterator();
 
                // Set it as well
                $taskInstance->setIteratorInstance($iteratorInstance);