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