3 * A UniversalNodeLocator
5 * @author Roland Haeder <webmaster@ship-simu.org>
7 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 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 {
28 private $unlData = array();
31 * Protected constructor
35 protected function __construct () {
36 // Call parent constructor
37 parent::__construct(__CLASS__);
41 * Creates an instance of this class
43 * @param $current An array with "raw" data from the database layer for the UNL. This parameter is optional.
44 * @return $unlInstance An instance of a LocateableNode class
46 public final static function createUniversalNodeLocator (array $current = array()) {
48 $unlInstance = new UniversalNodeLocator();
51 $unlInstance->initUniversalNodeLocator($current);
53 // Return the prepared instance
58 * Initializes the UNL instance by givena array. If an entry is found, it
59 * will be copied, otherwise the entry is set empty.
61 * @param $current An array with "raw" data from the database layer for the UNL. This parameter is optional.
64 private function initUniversalNodeLocator (array $current = array()) {
66 $this->unlData = array();
68 // Copy all found entries
70 NodeInformationDatabaseWrapper::DB_COLUMN_NODE_ID,
71 NodeInformationDatabaseWrapper::DB_COLUMN_SESSION_ID,
72 NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH,
73 NodeInformationDatabaseWrapper::DB_COLUMN_NODE_MODE,
74 NodeInformationDatabaseWrapper::DB_COLUMN_INTERNAL_UNL,
75 NodeInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL) as $key) {
77 $this->unlData[$key] = NULL;
80 if (isset($current[$key])) {
82 $this->unlData[$key] = $current[$key];
88 * Getter for UNL data array
90 * @return $unlData An array with UNL data
92 public final function getUnlData () {
93 return $this->unlData;