3 * A UniversalNodeLocator
5 * @author Roland Haeder <webmaster@ship-simu.org>
7 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
8 * @license GNU GPL 3.0 or any newer version
9 * @link http://www.ship-simu.org
11 * This program is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 class UniversalNodeLocator extends BaseFrameworkSystem implements LocateableNode {
25 //------- UNL parts -------
27 const UNL_PART_PROTOCOL = 'protocol';
29 const UNL_PART_ADDRESS = 'address';
31 const UNL_PART_EXTRA = 'extra';
33 const UNL_PART_PORT = 'port';
38 private $unlData = array();
41 * Protected constructor
45 protected function __construct () {
46 // Call parent constructor
47 parent::__construct(__CLASS__);
51 * Creates an instance of this class
53 * @param $current An array with "raw" data from the database layer for the UNL. This parameter is optional.
54 * @return $unlInstance An instance of a LocateableNode class
56 public final static function createUniversalNodeLocator (array $current = array()) {
58 $unlInstance = new UniversalNodeLocator();
61 $unlInstance->initUniversalNodeLocator($current);
63 // Return the prepared instance
68 * Initializes the UNL instance by givena array. If an entry is found, it
69 * will be copied, otherwise the entry is set empty.
71 * @param $current An array with "raw" data from the database layer for the UNL. This parameter is optional.
74 private function initUniversalNodeLocator (array $current = array()) {
76 $this->unlData = array();
78 // Copy all found entries
80 NodeInformationDatabaseWrapper::DB_COLUMN_NODE_ID,
81 NodeInformationDatabaseWrapper::DB_COLUMN_SESSION_ID,
82 NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH,
83 NodeInformationDatabaseWrapper::DB_COLUMN_NODE_MODE,
84 NodeInformationDatabaseWrapper::DB_COLUMN_INTERNAL_UNL,
85 NodeInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL) as $key) {
87 $this->unlData[$key] = NULL;
90 if (isset($current[$key])) {
92 $this->unlData[$key] = $current[$key];
98 * Getter for UNL data array
100 * @return $unlData An array with UNL data
102 public final function getUnlData () {
103 return $this->unlData;