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