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