From b801ade42b786e67d5a56a7f7b38f329b8241c18 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 1 Dec 2020 23:41:52 +0100 Subject: [PATCH] Continued: - moved $handerInstance from monolithic BaseFrameworkSystem class (the class later cleaned from such instances is doing fine) to proper classes - updated core framework MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../hub/classes/decoder/class_BaseDecoder.php | 25 ++++++++ .../protocol/class_BaseProtocolHandler.php | 2 +- .../ipv4/class_BaseIpV4ConnectionHelper.php | 63 +++++++++++++------ .../hub/classes/info/class_BaseInfo.php | 2 +- .../classes/listener/class_BaseListener.php | 25 ++++++++ .../listener/class_BaseListenerDecorator.php | 2 +- .../assembler/class_PackageAssembler.php | 25 ++++++++ .../chunks/class_NodeChunkAssemblerTask.php | 25 ++++++++ core | 2 +- 9 files changed, 148 insertions(+), 23 deletions(-) diff --git a/application/hub/classes/decoder/class_BaseDecoder.php b/application/hub/classes/decoder/class_BaseDecoder.php index 73c986855..b6af54381 100644 --- a/application/hub/classes/decoder/class_BaseDecoder.php +++ b/application/hub/classes/decoder/class_BaseDecoder.php @@ -7,6 +7,7 @@ use Org\Shipsimu\Hub\Generic\BaseHubSystem; use Org\Shipsimu\Hub\Network\Delivery\Deliverable; // Import framework stuff +use Org\Mxchange\CoreFramework\Handler\Handleable; use Org\Mxchange\CoreFramework\Stacker\Stackable; /** @@ -42,6 +43,11 @@ abstract class BaseDecoder extends BaseHubSystem { */ private $stackInstance = NULL; + /** + * Handler instance + */ + private $handlerInstance = NULL; + /** * Protected constructor * @@ -91,4 +97,23 @@ abstract class BaseDecoder extends BaseHubSystem { return $this->stackInstance; } + /** + * Setter for handler instance + * + * @param $handlerInstance An instance of a Handleable class + * @return void + */ + protected final function setHandlerInstance (Handleable $handlerInstance) { + $this->handlerInstance = $handlerInstance; + } + + /** + * Getter for handler instance + * + * @return $handlerInstance A Handleable instance + */ + protected final function getHandlerInstance () { + return $this->handlerInstance; + } + } diff --git a/application/hub/classes/handler/protocol/class_BaseProtocolHandler.php b/application/hub/classes/handler/protocol/class_BaseProtocolHandler.php index d89bc6b48..a6fc984f6 100644 --- a/application/hub/classes/handler/protocol/class_BaseProtocolHandler.php +++ b/application/hub/classes/handler/protocol/class_BaseProtocolHandler.php @@ -61,7 +61,7 @@ abstract class BaseProtocolHandler extends BaseHubHandler implements HandleableP * @param $protocolName Name of used protocol * @return void */ - protected final function setProtocolName ($protocolName) { + protected final function setProtocolName (string $protocolName) { $this->protocolName = $protocolName; } diff --git a/application/hub/classes/helper/connection/ipv4/class_BaseIpV4ConnectionHelper.php b/application/hub/classes/helper/connection/ipv4/class_BaseIpV4ConnectionHelper.php index 1c39b7fb5..853fc73ab 100644 --- a/application/hub/classes/helper/connection/ipv4/class_BaseIpV4ConnectionHelper.php +++ b/application/hub/classes/helper/connection/ipv4/class_BaseIpV4ConnectionHelper.php @@ -9,6 +9,7 @@ use Org\Shipsimu\Hub\Locator\Node\LocateableNode; // Import framework stuff use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; +use Org\Mxchange\CoreFramework\Handler\Handleable; /** * A ??? connection helper class @@ -39,6 +40,11 @@ abstract class BaseIpV4ConnectionHelper extends BaseConnectionHelper { */ private $protocolName = 'invalid'; + /** + * Handler instance + */ + private $handlerInstance = NULL; + /** * Protected constructor * @@ -50,6 +56,44 @@ abstract class BaseIpV4ConnectionHelper extends BaseConnectionHelper { parent::__construct($className); } + /** + * Setter for protocol name + * + * @param $protocolName Name of used protocol + * @return void + */ + protected final function setProtocolName (string $protocolName) { + $this->protocolName = $protocolName; + } + + /** + * Getter for protocol name + * + * @return $protocolName Name of used protocol + */ + public final function getProtocolName () { + return $this->protocolName; + } + + /** + * Setter for handler instance + * + * @param $handlerInstance An instance of a Handleable class + * @return void + */ + protected final function setHandlerInstance (Handleable $handlerInstance) { + $this->handlerInstance = $handlerInstance; + } + + /** + * Getter for handler instance + * + * @return $handlerInstance A Handleable instance + */ + protected final function getHandlerInstance () { + return $this->handlerInstance; + } + /** * Attempts to connect to a peer by given IP number and port from an UNL * instance with currently configured timeout. @@ -162,23 +206,4 @@ abstract class BaseIpV4ConnectionHelper extends BaseConnectionHelper { $this->initSocketInstance(); } - /** - * Setter for protocol name - * - * @param $protocolName Name of used protocol - * @return void - */ - protected final function setProtocolName ($protocolName) { - $this->protocolName = $protocolName; - } - - /** - * Getter for protocol name - * - * @return $protocolName Name of used protocol - */ - public final function getProtocolName () { - return $this->protocolName; - } - } diff --git a/application/hub/classes/info/class_BaseInfo.php b/application/hub/classes/info/class_BaseInfo.php index f56407093..200ccbc85 100644 --- a/application/hub/classes/info/class_BaseInfo.php +++ b/application/hub/classes/info/class_BaseInfo.php @@ -5,7 +5,7 @@ namespace Org\Shipsimu\Hub\Information; // Import application-specific stuff use Org\Shipsimu\Hub\Generic\BaseHubSystem; -// Import framework-specific stuff +// Import framework stuff use Org\Mxchange\CoreFramework\Helper\Helper; /** diff --git a/application/hub/classes/listener/class_BaseListener.php b/application/hub/classes/listener/class_BaseListener.php index d4131f38f..ba84a870d 100644 --- a/application/hub/classes/listener/class_BaseListener.php +++ b/application/hub/classes/listener/class_BaseListener.php @@ -20,6 +20,7 @@ use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Factory\Registry\Socket\SocketRegistryFactory; use Org\Mxchange\CoreFramework\Generic\NullPointerException; +use Org\Mxchange\CoreFramework\Handler\Handleable; use Org\Mxchange\CoreFramework\Registry\Register; use Org\Mxchange\CoreFramework\Socket\InvalidServerSocketException; use Org\Mxchange\CoreFramework\Socket\SocketAlreadyRegisteredException; @@ -88,6 +89,11 @@ abstract class BaseListener extends BaseHubSystem implements Visitable { */ private $registryInstance = NULL; + /** + * Handler instance + */ + private $handlerInstance = NULL; + /** * Protected constructor * @@ -235,6 +241,25 @@ abstract class BaseListener extends BaseHubSystem implements Visitable { return $this->registryInstance; } + /** + * Setter for handler instance + * + * @param $handlerInstance An instance of a Handleable class + * @return void + */ + protected final function setHandlerInstance (Handleable $handlerInstance) { + $this->handlerInstance = $handlerInstance; + } + + /** + * Getter for handler instance + * + * @return $handlerInstance A Handleable instance + */ + public final function getHandlerInstance () { + return $this->handlerInstance; + } + /** * Registeres the given socket resource for "this" listener instance. This * will be done in a seperate class to allow package writers to use it diff --git a/application/hub/classes/listener/class_BaseListenerDecorator.php b/application/hub/classes/listener/class_BaseListenerDecorator.php index 6918df201..69c9f54d2 100644 --- a/application/hub/classes/listener/class_BaseListenerDecorator.php +++ b/application/hub/classes/listener/class_BaseListenerDecorator.php @@ -74,7 +74,7 @@ abstract class BaseListenerDecorator extends BaseDecorator implements Visitable * @param $protocolName Name of used protocol * @return void */ - protected final function setProtocolName ($protocolName) { + protected final function setProtocolName (string $protocolName) { $this->protocolName = $protocolName; } diff --git a/application/hub/classes/package/assembler/class_PackageAssembler.php b/application/hub/classes/package/assembler/class_PackageAssembler.php index 9ccbac0ee..15a7095f6 100644 --- a/application/hub/classes/package/assembler/class_PackageAssembler.php +++ b/application/hub/classes/package/assembler/class_PackageAssembler.php @@ -16,6 +16,7 @@ use Org\Shipsimu\Hub\Network\Receive\Receivable; // Import framework stuff use Org\Mxchange\CoreFramework\Factory\ObjectFactory; +use Org\Mxchange\CoreFramework\Handler\Handleable; use Org\Mxchange\CoreFramework\Registry\Registerable; use Org\Mxchange\CoreFramework\Utils\String\StringUtils; use Org\Mxchange\CoreFramework\Stacker\Stackable; @@ -79,6 +80,11 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable, */ private $stackInstance = NULL; + /** + * Handler instance + */ + private $handlerInstance = NULL; + /** * Protected constructor * @@ -175,6 +181,25 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable, return $this->stackInstance; } + /** + * Setter for handler instance + * + * @param $handlerInstance An instance of a Handleable class + * @return void + */ + protected final function setHandlerInstance (Handleable $handlerInstance) { + $this->handlerInstance = $handlerInstance; + } + + /** + * Getter for handler instance + * + * @return $handlerInstance A Handleable instance + */ + protected final function getHandlerInstance () { + return $this->handlerInstance; + } + /** * Checks whether the input buffer (stacker to be more preceise) is empty. * diff --git a/application/hub/classes/tasks/node/chunks/class_NodeChunkAssemblerTask.php b/application/hub/classes/tasks/node/chunks/class_NodeChunkAssemblerTask.php index c0cad7659..33c1d749a 100644 --- a/application/hub/classes/tasks/node/chunks/class_NodeChunkAssemblerTask.php +++ b/application/hub/classes/tasks/node/chunks/class_NodeChunkAssemblerTask.php @@ -7,6 +7,7 @@ use Org\Shipsimu\Hub\Factory\Handler\Chunk\ChunkHandlerFactory; use Org\Shipsimu\Hub\Task\BaseHubTask; // Import framework stuff +use Org\Mxchange\CoreFramework\Handler\Handleable; use Org\Mxchange\CoreFramework\Task\BaseTask; use Org\Mxchange\CoreFramework\Task\Taskable; use Org\Mxchange\CoreFramework\Visitor\Visitable; @@ -35,6 +36,11 @@ use Org\Mxchange\CoreFramework\Visitor\Visitor; * along with this program. If not, see . */ class NodeChunkAssemblerTask extends BaseHubTask implements Taskable, Visitable { + /** + * Handler instance + */ + private $handlerInstance = NULL; + /** * Protected constructor * @@ -45,6 +51,25 @@ class NodeChunkAssemblerTask extends BaseHubTask implements Taskable, Visitable parent::__construct(__CLASS__); } + /** + * Setter for handler instance + * + * @param $handlerInstance An instance of a Handleable class + * @return void + */ + protected final function setHandlerInstance (Handleable $handlerInstance) { + $this->handlerInstance = $handlerInstance; + } + + /** + * Getter for handler instance + * + * @return $handlerInstance A Handleable instance + */ + protected final function getHandlerInstance () { + return $this->handlerInstance; + } + /** * Creates an instance of this class * diff --git a/core b/core index 28ff0710d..2b0e7f20e 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 28ff0710d8eb3a2d0c1547d6ebeaae05eb50c7f6 +Subproject commit 2b0e7f20e7d554a5675c3268db6de3dd3ab3421d -- 2.39.5