From: Roland Häder Date: Mon, 18 Apr 2011 22:08:56 +0000 (+0000) Subject: Introduced getListIterator() to all lists implementing Listable X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a44489127edbf6dcbf0b1da401872c74aecf9c1a;p=hub.git Introduced getListIterator() to all lists implementing Listable --- diff --git a/application/hub/config.php b/application/hub/config.php index f0dfaa5a1..d650da5b6 100644 --- a/application/hub/config.php +++ b/application/hub/config.php @@ -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'); diff --git a/application/hub/interfaces/lists/class_Listable.php b/application/hub/interfaces/lists/class_Listable.php index eb570137c..caac23f3c 100644 --- a/application/hub/interfaces/lists/class_Listable.php +++ b/application/hub/interfaces/lists/class_Listable.php @@ -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] diff --git a/application/hub/main/connectors/query/local/class_LocalQueryConnector.php b/application/hub/main/connectors/query/local/class_LocalQueryConnector.php index b44b560ac..d9e826827 100644 --- a/application/hub/main/connectors/query/local/class_LocalQueryConnector.php +++ b/application/hub/main/connectors/query/local/class_LocalQueryConnector.php @@ -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); diff --git a/application/hub/main/handler/network/class_BaseNetworkPackageHandler.php b/application/hub/main/handler/network/class_BaseNetworkPackageHandler.php index 3e6399645..2cd9d1661 100644 --- a/application/hub/main/handler/network/class_BaseNetworkPackageHandler.php +++ b/application/hub/main/handler/network/class_BaseNetworkPackageHandler.php @@ -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() + )); } /** diff --git a/application/hub/main/handler/network/tcp/class_TcpNetworkPackageHandler.php b/application/hub/main/handler/network/tcp/class_TcpNetworkPackageHandler.php index 3dd47493e..ab841180d 100644 --- a/application/hub/main/handler/network/tcp/class_TcpNetworkPackageHandler.php +++ b/application/hub/main/handler/network/tcp/class_TcpNetworkPackageHandler.php @@ -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); } } diff --git a/application/hub/main/listener/tcp/class_TcpListener.php b/application/hub/main/listener/tcp/class_TcpListener.php index c972c1f5f..005831ffc 100644 --- a/application/hub/main/listener/tcp/class_TcpListener.php +++ b/application/hub/main/listener/tcp/class_TcpListener.php @@ -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.'); } } diff --git a/application/hub/main/lists/groups/class_ListGroupList.php b/application/hub/main/lists/groups/class_ListGroupList.php index ae59c8d50..045569349 100644 --- a/application/hub/main/lists/groups/class_ListGroupList.php +++ b/application/hub/main/lists/groups/class_ListGroupList.php @@ -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] ?> diff --git a/application/hub/main/lists/hub/class_HubList.php b/application/hub/main/lists/hub/class_HubList.php index 3fb84610e..c663de19d 100644 --- a/application/hub/main/lists/hub/class_HubList.php +++ b/application/hub/main/lists/hub/class_HubList.php @@ -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] diff --git a/application/hub/main/lists/pool/class_PoolEntriesList.php b/application/hub/main/lists/pool/class_PoolEntriesList.php index abfe38238..4c2208373 100644 --- a/application/hub/main/lists/pool/class_PoolEntriesList.php +++ b/application/hub/main/lists/pool/class_PoolEntriesList.php @@ -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] ?> diff --git a/application/hub/main/lists/query/local/class_LocalQueryList.php b/application/hub/main/lists/query/local/class_LocalQueryList.php index b07f2ed3e..e364c0ff4 100644 --- a/application/hub/main/lists/query/local/class_LocalQueryList.php +++ b/application/hub/main/lists/query/local/class_LocalQueryList.php @@ -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] diff --git a/application/hub/main/lists/recipient/class_RecipientList.php b/application/hub/main/lists/recipient/class_RecipientList.php index 1f58106ff..538eb7476 100644 --- a/application/hub/main/lists/recipient/class_RecipientList.php +++ b/application/hub/main/lists/recipient/class_RecipientList.php @@ -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] diff --git a/application/hub/main/lists/tasks/class_TaskList.php b/application/hub/main/lists/tasks/class_TaskList.php index fb190ebbc..d5402dc72 100644 --- a/application/hub/main/lists/tasks/class_TaskList.php +++ b/application/hub/main/lists/tasks/class_TaskList.php @@ -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] diff --git a/application/hub/main/tasks/hub/ping/class_HubPingTask.php b/application/hub/main/tasks/hub/ping/class_HubPingTask.php index 19ad14978..d63c04f05 100644 --- a/application/hub/main/tasks/hub/ping/class_HubPingTask.php +++ b/application/hub/main/tasks/hub/ping/class_HubPingTask.php @@ -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);