3 namespace Org\Mxchange\CoreFramework\State;
5 // Import framework stuff
6 use Org\Mxchange\CoreFramework\Executor\Executor;
7 use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
8 use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
9 use Org\Mxchange\CoreFramework\State\Stateable;
12 * A general state class
14 * @author Roland Haeder <webmaster@shipsimu.org>
16 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
17 * @license GNU GPL 3.0 or any newer version
18 * @link http://www.shipsimu.org
20 * This program is free software: you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation, either version 3 of the License, or
23 * (at your option) any later version.
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
30 * You should have received a copy of the GNU General Public License
31 * along with this program. If not, see <http://www.gnu.org/licenses/>.
33 abstract class BaseState extends BaseFrameworkSystem implements Stateable {
34 // Exception code constants
35 const EXCEPTION_INVALID_STATE = 0xc00;
38 * State name for printing out (except debug output where you want to use
39 * $stateInstance->__toString() instead of this).
41 private $stateName = '';
44 * Protected constructor
46 * @param $className Name of the class
49 protected function __construct ($className) {
50 // Call parent constructor
51 parent::__construct($className);
55 * Getter for state name
57 * @return $stateName Name of this state in a printable maner
59 public final function getStateName () {
60 return $this->stateName;
64 * Setter for state name
66 * @param $stateName Name of this state in a printable maner
69 protected final function setStateName ($stateName) {
70 $this->stateName = $stateName;
74 * Executes the state with given Executor instance
76 * @param $executorInstance An instance of a Executor class
78 * @throws UnsupportedOperationException This method should be overwritten
80 public function executeState (Executor $executorInstance) {
81 throw new UnsupportedOperationException(array($this, __FUNCTION__, $executorInstance), self::EXCEPTION_UNSPPORTED_OPERATION);