From: Roland Häder Date: Fri, 19 May 2017 16:15:32 +0000 (+0200) Subject: also added BaseInfo and ConnectionInfo, now bound to BaseFrameworkSystem X-Git-Url: https://git.mxchange.org/?p=core.git;a=commitdiff_plain;h=3f541c25cfb055288a13141a1aa6fbbc78c9a9c2 also added BaseInfo and ConnectionInfo, now bound to BaseFrameworkSystem Signed-off-by: Roland Häder --- diff --git a/framework/main/classes/info/.htaccess b/framework/main/classes/info/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/framework/main/classes/info/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/framework/main/classes/info/class_ b/framework/main/classes/info/class_ new file mode 100644 index 00000000..b1926e16 --- /dev/null +++ b/framework/main/classes/info/class_ @@ -0,0 +1,48 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 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 . + */ +class ???Info extends BaseInfo implements ShareableInfo { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $infoInstance An instance of a ShareableInfo class + */ + public final static function create???Info () { + // Get new instance + $infoInstance = new ???Info(); + + // Return the prepared instance + return $infoInstance; + } + +} diff --git a/framework/main/classes/info/class_BaseInfo.php b/framework/main/classes/info/class_BaseInfo.php new file mode 100644 index 00000000..dad58709 --- /dev/null +++ b/framework/main/classes/info/class_BaseInfo.php @@ -0,0 +1,42 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 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 . + */ +class BaseInfo extends BaseFrameworkSystem { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + +} diff --git a/framework/main/classes/info/connection/.htaccess b/framework/main/classes/info/connection/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/framework/main/classes/info/connection/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/framework/main/classes/info/connection/class_ConnectionInfo.php b/framework/main/classes/info/connection/class_ConnectionInfo.php new file mode 100644 index 00000000..5443ece9 --- /dev/null +++ b/framework/main/classes/info/connection/class_ConnectionInfo.php @@ -0,0 +1,119 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 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 . + */ +class ConnectionInfo extends BaseInfo implements ShareableInfo, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $infoInstance An instance of a ShareableInfo class + */ + public final static function createConnectionInfo () { + // Get new instance + $infoInstance = new ConnectionInfo(); + + // Return the prepared instance + return $infoInstance; + } + + /** + * Fills the information class with data from a Listenable instance + * + * @param $listenerInstance An instance of a Listenable class + * @return void + */ + public function fillWithListenerInformation (Listenable $listenerInstance) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: protocolName=' . $listenerInstance->getProtocolName() . ',listenerInstance=' . $listenerInstance->__toString() . ' - CALLED!'); + + // Fill the generic array with several data from the listener: + $this->setProtocolName($listenerInstance->getProtocolName()); + $this->setGenericArrayElement('connection', 'dummy', 'dummy', UniversalNodeLocator::UNL_PART_ADDRESS , $listenerInstance->getListenAddress()); + $this->setGenericArrayElement('connection', 'dummy', 'dummy', UniversalNodeLocator::UNL_PART_PORT , $listenerInstance->getListenPort()); + + // Set listener here + $this->setListenerInstance($listenerInstance); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); + } + + /** + * Fills the information class with data from a ConnectionHelper instance + * + * @param $helperInstance An instance of a ConnectionHelper class + * @return void + */ + public function fillWithConnectionHelperInformation (ConnectionHelper $helperInstance) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: protocolName=' . $helperInstance->getProtocolName() . ',helperInstance=' . $helperInstance->__toString() . ',socketResource=' . $helperInstance->getSocketResource() . ' - CALLED!'); + + // Fill the generic array with several data from the listener: + $this->setProtocolName($helperInstance->getProtocolName()); + $this->setGenericArrayElement('connection', 'dummy', 'dummy', UniversalNodeLocator::UNL_PART_ADDRESS , $helperInstance->getAddress()); + $this->setGenericArrayElement('connection', 'dummy', 'dummy', UniversalNodeLocator::UNL_PART_PORT , $helperInstance->getConnectionPort()); + + // Set helper here + $this->setHelperInstance($helperInstance); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); + } + + /** + * Getter for address + * + * @return $address Address from shared information + */ + public final function getAddress () { + // Return it from generic array + return $this->getGenericArrayElement('connection', 'dummy', 'dummy', UniversalNodeLocator::UNL_PART_ADDRESS); + } + + /** + * Getter for port + * + * @return $port Port from shared information + */ + public final function getPort () { + // Return it from generic array + return $this->getGenericArrayElement('connection', 'dummy', 'dummy', UniversalNodeLocator::UNL_PART_PORT); + } + +} diff --git a/framework/main/interfaces/shareable/info/class_ShareableInfo.php b/framework/main/interfaces/shareable/info/class_ShareableInfo.php index fc1367bc..cd7fe45d 100644 --- a/framework/main/interfaces/shareable/info/class_ShareableInfo.php +++ b/framework/main/interfaces/shareable/info/class_ShareableInfo.php @@ -44,7 +44,5 @@ interface ShareableInfo extends FrameworkInterface { * @return void */ function fillWithConnectionHelperInformation (ConnectionHelper $helperInstance); -} -// [EOF] -?> +}