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;
11 * A general state class
13 * @author Roland Haeder <webmaster@shipsimu.org>
15 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
16 * @license GNU GPL 3.0 or any newer version
17 * @link http://www.shipsimu.org
19 * This program is free software: you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation, either version 3 of the License, or
22 * (at your option) any later version.
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
29 * You should have received a copy of the GNU General Public License
30 * along with this program. If not, see <http://www.gnu.org/licenses/>.
32 class BaseState extends BaseFrameworkSystem implements Stateable {
33 // Exception code constants
34 const EXCEPTION_INVALID_STATE = 0xc00;
37 * State name for printing out (except debug output where you want to use
38 * $stateInstance->__toString() instead of this).
40 private $stateName = '';
43 * Protected constructor
45 * @param $className Name of the class
48 protected function __construct ($className) {
49 // Call parent constructor
50 parent::__construct($className);
54 * Getter for state name
56 * @return $stateName Name of this state in a printable maner
58 public final function getStateName () {
59 return $this->stateName;
63 * Setter for state name
65 * @param $stateName Name of this state in a printable maner
68 protected final function setStateName ($stateName) {
69 $this->stateName = $stateName;
73 * Executes the state with given Executor instance
75 * @param $executorInstance An instance of a Executor class
77 * @throws UnsupportedOperationException This method should be overwritten
79 public function executeState (Executor $executorInstance) {
80 throw new UnsupportedOperationException(array($this, __FUNCTION__, $executorInstance), self::EXCEPTION_UNSPPORTED_OPERATION);