]> git.mxchange.org Git - hub.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Wed, 2 Dec 2020 19:29:39 +0000 (20:29 +0100)
committerRoland Häder <roland@mxchange.org>
Wed, 2 Dec 2020 19:29:39 +0000 (20:29 +0100)
- used more traits than direct instances + getter/setter
- added missing "import" lines
- updated core framework

Signed-off-by: Roland Häder <roland@mxchange.org>
14 files changed:
application/hub/classes/container/socket/class_SocketContainer.php
application/hub/classes/handler/package/class_NetworkPackageHandler.php
application/hub/classes/helper/class_BaseHubSystemHelper.php
application/hub/classes/info/class_BaseInfo.php
application/hub/classes/producer/cruncher/work_units/class_BaseUnitProducer.php
application/hub/classes/states/communicator/class_BaseCommunicatorState.php
application/hub/classes/states/crawler/class_BaseCrawlerState.php
application/hub/classes/states/cruncher/class_BaseCruncherState.php
application/hub/classes/states/dht/class_BaseDhtState.php
application/hub/classes/states/miner/class_BaseMinerState.php
application/hub/classes/states/node/class_BaseNodeState.php
application/hub/classes/states/peer/class_BasePeerState.php
application/hub/classes/tags/class_BaseTag.php
core

index eb2ad4bd90a05aeabbed888f6266246d0ab8f28d..d6eaa232c00024213067ac2783e5fca0f28abef3 100644 (file)
@@ -6,19 +6,18 @@ namespace Org\Shipsimu\Hub\Container\Socket;
 use Org\Shipsimu\Hub\Container\BaseHubContainer;
 use Org\Shipsimu\Hub\Factory\Network\Locator\UniversalNodeLocatorFactory;
 use Org\Shipsimu\Hub\Factory\Socket\SocketFactory;
+use Org\Shipsimu\Hub\Handler\Package\NetworkPackageHandler;
 use Org\Shipsimu\Hub\Helper\Connection\BaseConnectionHelper;
 use Org\Shipsimu\Hub\Helper\Connection\ConnectionHelper;
 use Org\Shipsimu\Hub\Information\ShareableInfo;
 use Org\Shipsimu\Hub\Listener\BaseListener;
 use Org\Shipsimu\Hub\Listener\Listenable;
 use Org\Shipsimu\Hub\Network\Package\DeliverablePackage;
-use Org\Shipsimu\Hub\Handler\Package\NetworkPackageHandler;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
 use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
 use Org\Mxchange\CoreFramework\Generic\NullPointerException;
-use Org\Mxchange\CoreFramework\Helper\Helper;
 use Org\Mxchange\CoreFramework\Registry\Registerable;
 use Org\Mxchange\CoreFramework\Socket\InvalidSocketException;
 use Org\Mxchange\CoreFramework\Socket\NoSocketErrorDetectedException;
@@ -26,6 +25,7 @@ use Org\Mxchange\CoreFramework\Socket\SocketBindingException;
 use Org\Mxchange\CoreFramework\Socket\SocketConnectionException;
 use Org\Mxchange\CoreFramework\Socket\SocketOperationException;
 use Org\Mxchange\CoreFramework\Socket\UnsupportedSocketErrorHandlerException;
+use Org\Mxchange\CoreFramework\Traits\Helper\HelperTrait;
 use Org\Mxchange\CoreFramework\Utils\String\StringUtils;
 use Org\Mxchange\CoreFramework\Visitor\Visitable;
 use Org\Mxchange\CoreFramework\Visitor\Visitor;
@@ -59,6 +59,9 @@ use \SplFileInfo;
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 class SocketContainer extends BaseHubContainer implements StorableSocket, Visitable, Registerable {
+       // Load traits
+       use HelperTrait;
+
        /**
         * Socket protocol:
         * - 'tcp' for TCP/IPv4 connections
@@ -116,11 +119,6 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita
         */
        private $socketResource = false;
 
-       /**
-        * A helper instance for the form
-        */
-       private $helperInstance = NULL;
-
        /**
         * Protected constructor
         *
@@ -230,7 +228,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita
         */
        public function shutdownSocket () {
                // Debug message
-               self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: Shutting down socket ' . $this->getSocketResource() . ' with state ' . $this->getPrintableState() . ' ...');
+               self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: Shutting down socket ' . $this->getSocketResource() . ' with state ' . $this->getHelperInstance()->getPrintableState() . ' ...');
 
                // Get a visitor instance
                $visitorInstance = ObjectFactory::createObjectByConfiguredName('shutdown_socket_visitor_class');
@@ -253,7 +251,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita
         */
        public function halfShutdownSocket () {
                // Debug message
-               self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: Half-shutting down socket resource ' . $this->getSocketResource() . ' with state ' . $this->getPrintableState() . ' ...');
+               self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: Half-shutting down socket resource ' . $this->getSocketResource() . ' with state ' . $this->getHelperInstance()->getPrintableState() . ' ...');
 
                // Get a visitor instance
                $visitorInstance = ObjectFactory::createObjectByConfiguredName('half_shutdown_socket_visitor_class');
@@ -1535,23 +1533,4 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita
                return $this->socketResource;
        }
 
-       /**
-        * Setter for helper instance
-        *
-        * @param       $helperInstance         An instance of a helper class
-        * @return      void
-        */
-       protected final function setHelperInstance (Helper $helperInstance) {
-               $this->helperInstance = $helperInstance;
-       }
-
-       /**
-        * Getter for helper instance
-        *
-        * @return      $helperInstance         An instance of a helper class
-        */
-       public final function getHelperInstance () {
-               return $this->helperInstance;
-       }
-
 }
index 492248644bfc1d315a9e01e95b91ad3922d0bfe8..6e4ebeb56a2ad60ff8f66fce6e3c2e068f52a0f6 100644 (file)
@@ -39,6 +39,7 @@ use Org\Mxchange\CoreFramework\Feature\FrameworkFeature;
 use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
 use Org\Mxchange\CoreFramework\Registry\Registerable;
 use Org\Mxchange\CoreFramework\Socket\InvalidSocketException;
+use Org\Mxchange\CoreFramework\State\UnexpectedStateException;
 use Org\Mxchange\CoreFramework\Traits\Crypto\CryptoTrait;
 use Org\Mxchange\CoreFramework\Traits\Visitor\VisitorTrait;
 use Org\Mxchange\CoreFramework\Visitor\Visitable;
@@ -530,9 +531,10 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
                $nextPackageInstance = $this->getStackInstance()->popNamed($stackerName);
 
                // Compare both hashes
-               if ($nextPackageInstance->getPackageHash() != $packageInstance->getPackageHash()) {
+               //* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: packageInstance=%s', __METHOD__, __LINE__, print_r($packageInstance, TRUE)));
+               if ($nextPackageInstance->getContentHash() != $packageInstance->getContentHash()) {
                        // Hash is not matching
-                       throw new InvalidArgumentException(sprintf('Hashes "%s" and "%s" are mismatching.', $packageInstance->getPackageHash(), $nextPackageInstance->getPackageHash()));
+                       throw new InvalidArgumentException(sprintf('Hashes "%s" and "%s" are mismatching.', $packageInstance->getContentHash(), $nextPackageInstance->getContentHash()));
                }
 
                // Temporary set the new status
index 959863a61d70effdce28b9f05a37b4f0042038f0..2bac436a9aff06e2aaf47ad200522bed9bc1be89 100644 (file)
@@ -5,9 +5,6 @@ namespace Org\Shipsimu\Hub\Helper;
 // Import application-specific stuff
 use Org\Shipsimu\Hub\Generic\BaseHubSystem;
 
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
-
 /**
  * A general hub helper class. This class does not extend BaseHelper.
  *
@@ -30,7 +27,7 @@ use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
  * 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 BaseHubSystemHelper extends BaseHubSystem implements HubHelper {
+abstract class BaseHubSystemHelper extends BaseHubSystem implements HubHelper {
        /**
         * Recipient id
         */
@@ -46,11 +43,6 @@ class BaseHubSystemHelper extends BaseHubSystem implements HubHelper {
         */
        private $packageTags = [];
 
-       /**
-        * Template engine instance
-        */
-       private $templateInstance = NULL;
-
        /**
         * Protected constructor
         *
@@ -117,25 +109,6 @@ class BaseHubSystemHelper extends BaseHubSystem implements HubHelper {
                $this->packageTags = $packageTags;
        }
 
-       /**
-        * Setter for template engine instances
-        *
-        * @param       $templateInstance       An instance of a template engine class
-        * @return      void
-        */
-       protected final function setTemplateInstance (CompileableTemplate $templateInstance) {
-               $this->templateInstance = $templateInstance;
-       }
-
-       /**
-        * Getter for template engine instances
-        *
-        * @return      $templateInstance       An instance of a template engine class
-        */
-       public final function getTemplateInstance () {
-               return $this->templateInstance;
-       }
-
        /**
         * Tries to determine the used protocol for this package (this helper is helping to send out)
         *
index 200ccbc85cfc866e210eca858ab6db5ac6d9f5d0..102e91965bf806d4d3b1598bf216ca238d300e73 100644 (file)
@@ -6,7 +6,7 @@ namespace Org\Shipsimu\Hub\Information;
 use Org\Shipsimu\Hub\Generic\BaseHubSystem;
 
 // Import framework stuff
-use Org\Mxchange\CoreFramework\Helper\Helper;
+use Org\Mxchange\CoreFramework\Traits\Helper\HelperTrait;
 
 /**
  * A general Info class
@@ -31,10 +31,8 @@ use Org\Mxchange\CoreFramework\Helper\Helper;
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 abstract class BaseInfo extends BaseHubSystem {
-       /**
-        * A helper instance for the form
-        */
-       private $helperInstance = NULL;
+       // Load traits
+       use HelperTrait;
 
        /**
         * Protected constructor
@@ -47,23 +45,4 @@ abstract class BaseInfo extends BaseHubSystem {
                parent::__construct($className);
        }
 
-       /**
-        * Setter for helper instance
-        *
-        * @param       $helperInstance         An instance of a helper class
-        * @return      void
-        */
-       protected final function setHelperInstance (Helper $helperInstance) {
-               $this->helperInstance = $helperInstance;
-       }
-
-       /**
-        * Getter for helper instance
-        *
-        * @return      $helperInstance         An instance of a helper class
-        */
-       public final function getHelperInstance () {
-               return $this->helperInstance;
-       }
-
 }
index 8091aff6f247d3e0357aad60e3e6b715075ef7b8..0b67d945e4748ae7f5057427e2441145edfd2ef9 100644 (file)
@@ -6,8 +6,8 @@ namespace Org\Shipsimu\Hub\Producer\Cruncher\Unit;
 use Org\Shipsimu\Hub\Producer\Cruncher\BaseCruncherProducer;
 
 // Import framework stuff
-use Org\Mxchange\CoreFramework\Helper\Helper;
-use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
+use Org\Mxchange\CoreFramework\Traits\Helper\HelperTrait;
+use Org\Mxchange\CoreFramework\Traits\Template\CompileableTemplateTrait;
 
 /**
  * A general UnitProducer class
@@ -32,6 +32,10 @@ use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 abstract class BaseUnitProducer extends BaseCruncherProducer {
+       // Load traits
+       use HelperTrait;
+       use CompileableTemplateTrait;
+
        /**
         * Work/test unit status
         */
@@ -45,16 +49,6 @@ abstract class BaseUnitProducer extends BaseCruncherProducer {
        const UNIT_TYPE_TEST_UNIT = 'test_unit';
        const UNIT_TYPE_TEST_WORK = 'work_unit';
 
-       /**
-        * Template engine instance
-        */
-       private $templateInstance = NULL;
-
-       /**
-        * A helper instance for the form
-        */
-       private $helperInstance = NULL;
-
        /**
         * Protected constructor
         *
@@ -66,42 +60,4 @@ abstract class BaseUnitProducer extends BaseCruncherProducer {
                parent::__construct($className);
        }
 
-       /**
-        * Setter for template engine instances
-        *
-        * @param       $templateInstance       An instance of a template engine class
-        * @return      void
-        */
-       protected final function setTemplateInstance (CompileableTemplate $templateInstance) {
-               $this->templateInstance = $templateInstance;
-       }
-
-       /**
-        * Getter for template engine instances
-        *
-        * @return      $templateInstance       An instance of a template engine class
-        */
-       protected final function getTemplateInstance () {
-               return $this->templateInstance;
-       }
-
-       /**
-        * Setter for helper instance
-        *
-        * @param       $helperInstance         An instance of a helper class
-        * @return      void
-        */
-       protected final function setHelperInstance (Helper $helperInstance) {
-               $this->helperInstance = $helperInstance;
-       }
-
-       /**
-        * Getter for helper instance
-        *
-        * @return      $helperInstance         An instance of a helper class
-        */
-       public final function getHelperInstance () {
-               return $this->helperInstance;
-       }
-
 }
index 072fe2ddaf2d86c8a61bb971e146475a95982e5b..8b1ca92060aa9c577fa4ca19626e21e187b5959a 100644 (file)
@@ -7,6 +7,7 @@ use Org\ShipSimu\Hub\Communicator\Communicator;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\State\BaseState;
+use Org\Mxchange\CoreFramework\State\UnexpectedStateException;
 
 /**
  * A general communicator state class
index db30dfb76aea13e84eebc8f11fdfcc04fb4ae146..f5d1d653562c9186907c02514817c1981b5f9a80 100644 (file)
@@ -4,6 +4,7 @@ namespace Org\Shipsimu\Hub\Crawler\State;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\State\BaseState;
+use Org\Mxchange\CoreFramework\State\UnexpectedStateException;
 
 /**
  * A general crawler state class
index af24a5a64e27d7d6fbf170235d87a333dcf86a39..82c9969ac2fa2daa86581cc9b1cc17ffa5368bf3 100644 (file)
@@ -4,6 +4,7 @@ namespace Org\Shipsimu\Hub\Cruncher\State;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\State\BaseState;
+use Org\Mxchange\CoreFramework\State\UnexpectedStateException;
 
 /**
  * A general cruncher state class
index 1f50132bfc79ed89d856c50b7c0da360e60e8003..ed338938e68ebde865d0a7598c4140b9714d50bb 100644 (file)
@@ -4,6 +4,7 @@ namespace Org\Shipsimu\Hub\State\Dht;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\State\BaseState;
+use Org\Mxchange\CoreFramework\State\UnexpectedStateException;
 
 /**
  * A general DHT state class
index 4d7d5f3f217cacc867c7246216792c5a018eadd9..0a00fd948d8c55ab46d2861640e8d7de0e7462c1 100644 (file)
@@ -8,6 +8,7 @@ use Org\Shipsimu\Hub\State\Miner\MinerInitState;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\State\BaseState;
+use Org\Mxchange\CoreFramework\State\UnexpectedStateException;
 
 /**
  * A general miner state class
index 432b027c0aa5e4fe0b4cbcd47d586f540e2e0275..3cb4588d4bfbf2e96dae0ad3a18017b3da1612c3 100644 (file)
@@ -4,6 +4,7 @@ namespace Org\Shipsimu\Hub\State\Node;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\State\BaseState;
+use Org\Mxchange\CoreFramework\State\UnexpectedStateException;
 
 /**
  * A general node state class
index 931a055d0b6215bd01620a2ecf30cb67607f0699..6c608f265e78f42de6803c0c00ee4693a836b8d4 100644 (file)
@@ -4,6 +4,7 @@ namespace Org\Shipsimu\Hub\State\Peer;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\State\BaseState;
+use Org\Mxchange\CoreFramework\State\UnexpectedStateException;
 
 /**
  * A general peer state class
index 82c02929c1defa844352395b6fd12af35c50635b..51052366018f5835df74d75115b241a16bd17a10 100644 (file)
@@ -7,7 +7,7 @@ use Org\Shipsimu\Hub\Generic\BaseHubSystem;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Registry\Registerable;
-use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
+use Org\Mxchange\CoreFramework\Traits\Template\CompileableTemplateTrait;
 
 /**
  * A general Tags class
@@ -32,16 +32,14 @@ use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 abstract class BaseTag extends BaseHubSystem implements Registerable {
+       // Load traits
+       use CompileableTemplateTrait;
+
        /**
         * An array with all tags
         */
        private $tags = [];
 
-       /**
-        * Template engine instance
-        */
-       private $templateInstance = NULL;
-
        /**
         * Protected constructor
         *
@@ -72,23 +70,4 @@ abstract class BaseTag extends BaseHubSystem implements Registerable {
                return $this->tags;
        }
 
-       /**
-        * Setter for template engine instances
-        *
-        * @param       $templateInstance       An instance of a template engine class
-        * @return      void
-        */
-       protected final function setTemplateInstance (CompileableTemplate $templateInstance) {
-               $this->templateInstance = $templateInstance;
-       }
-
-       /**
-        * Getter for template engine instances
-        *
-        * @return      $templateInstance       An instance of a template engine class
-        */
-       protected final function getTemplateInstance () {
-               return $this->templateInstance;
-       }
-
 }
diff --git a/core b/core
index 2a3f6350600cf6ad214923c57aef772dc5c0cb76..6187a6c39a906ce7ae3ae89cdbc4f6a59a69535d 160000 (submodule)
--- a/core
+++ b/core
@@ -1 +1 @@
-Subproject commit 2a3f6350600cf6ad214923c57aef772dc5c0cb76
+Subproject commit 6187a6c39a906ce7ae3ae89cdbc4f6a59a69535d