Continued:
[core.git] / framework / main / classes / states / class_BaseState.php
1 <?php
2 // Own namespace
3 namespace Org\Mxchange\CoreFramework\State;
4
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;
11
12 /**
13  * A general state class
14  *
15  * @author              Roland Haeder <webmaster@shipsimu.org>
16  * @version             0.0.0
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
20  *
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.
25  *
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.
30  *
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/>.
33  */
34 abstract class BaseState extends BaseFrameworkSystem implements Stateable {
35         // Exception code constants
36         const EXCEPTION_INVALID_STATE = 0xc00;
37
38         /**
39          * State name for printing out (except debug output where you want to use
40          * $stateInstance->__toString() instead of this).
41          */
42         private $stateName = '';
43
44         /**
45          * Protected constructor
46          *
47          * @param       $className      Name of the class
48          * @return      void
49          */
50         protected function __construct (string $className) {
51                 // Call parent constructor
52                 parent::__construct($className);
53         }
54
55         /**
56          * Getter for state name
57          *
58          * @return      $stateName      Name of this state in a printable maner
59          */
60         public final function getStateName () {
61                 return $this->stateName;
62         }
63
64         /**
65          * Setter for state name
66          *
67          * @param       $stateName      Name of this state in a printable maner
68          * @return      void
69          */
70         protected final function setStateName (string $stateName) {
71                 $this->stateName = $stateName;
72         }
73
74         /**
75          * Executes the state with given Executor instance
76          *
77          * @param       $executorInstance       An instance of a Executor class
78          * @return      void
79          * @throws      UnsupportedOperationException   This method should be overwritten
80          */
81         public function executeState (Executor $executorInstance) {
82                 throw new UnsupportedOperationException(array($this, __FUNCTION__, $executorInstance), FrameworkInterface::EXCEPTION_UNSPPORTED_OPERATION);
83         }
84
85 }