* @version 0.0.0 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 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 BaseHubSystem extends BaseFrameworkSystem { /** * An instance of a node */ private $nodeInstance = null; /** * An instance of a cruncher */ private $cruncherInstance = null; /** * Listener instance */ private $listenerInstance = null; /** * A network package handler instance */ private $packageInstance = null; /** * State instance */ private $stateInstance = null; /** * Protected constructor * * @param $className Name of the class * @return void */ protected function __construct ($className) { // Call parent constructor parent::__construct($className); } /** * Getter for node instance * * @return $nodeInstance An instance of a node node */ public final function getNodeInstance () { return $this->nodeInstance; } /** * Setter for node instance * * @param $nodeInstance An instance of a node node * @return void */ protected final function setNodeInstance (NodeHelper $nodeInstance) { $this->nodeInstance = $nodeInstance; } /** * Getter for cruncher instance * * @return $cruncherInstance An instance of a cruncher cruncher */ public final function getCruncherInstance () { return $this->cruncherInstance; } /** * Setter for cruncher instance * * @param $cruncherInstance An instance of a cruncher cruncher * @return void */ protected final function setCruncherInstance (CruncherHelper $cruncherInstance) { $this->cruncherInstance = $cruncherInstance; } /** * Setter for listener instance * * @param $listenerInstance A Listenable instance * @return void */ protected final function setListenerInstance (Listenable $listenerInstance) { $this->listenerInstance = $listenerInstance; } /** * Getter for listener instance * * @return $listenerInstance A Listenable instance */ protected final function getListenerInstance () { return $this->listenerInstance; } /** * Setter for network package handler instance * * @param $packageInstance The network package handler instance we shall set * @return void */ protected final function setPackageInstance (Networkable $packageInstance) { $this->packageInstance = $packageInstance; } /** * Getter for network package handler instance * * @return $packageInstance The network package handler instance we shall set */ protected final function getPackageInstance () { return $this->packageInstance; } /** * Setter for state instance * * @param $stateInstance A Stateable instance * @return void */ public final function setStateInstance (Stateable $stateInstance) { $this->stateInstance = $stateInstance; } /** * Getter for state instance * * @return $stateInstance A Stateable instance */ public final function getStateInstance () { return $this->stateInstance; } /** * Shuts down a given socket resource. This method does only ease calling * the right visitor. * * @param $socketResource A valid socket resource * @return void */ public function shutdownSocket ($socketResource) { // Debug message $this->debugOutput('Shutting down socket ' . $socketResource . ' ...'); // Set socket resource $this->setSocketResource($socketResource); // Get a visitor instance $visitorInstance = ObjectFactory::createObjectByConfiguredName('shutdown_socket_visitor_class'); // Call the visitor $this->accept($visitorInstance); } /** * "Getter" for a printable state name * * @return $stateName Name of the node's state in a printable format */ public final function getPrintableState () { // Default is 'null' $stateName = 'null'; // Get the state instance $stateInstance = $this->getStateInstance(); // Is it an instance of Stateable? if ($stateInstance instanceof Stateable) { // Then use that state name $stateName = $stateInstance->getStateName(); } // END - if // Return result return $stateName; } } // [EOF] ?>