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