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