]> git.mxchange.org Git - hub.git/blob - application/hub/main/states/miner/booting/class_MinerBootingState.php
Updated 'core'.
[hub.git] / application / hub / main / states / miner / booting / class_MinerBootingState.php
1 <?php
2 /**
3  * A Booting miner state class
4  *
5  * @author              Roland Haeder <webmaster@ship-simu.org>
6  * @version             0.0.0
7  * @copyright   Copyright (c) 2014 Miner Developer Team
8  * @license             GNU GPL 3.0 or any newer version
9  * @link                http://www.ship-simu.org
10  *
11  * This program is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation, either version 3 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23  */
24 class MinerBootingState extends BaseMinerState implements Stateable {
25         /**
26          * Array of booted producers
27          */
28         private $bootedProducer = array();
29
30         /**
31          * Protected constructor
32          *
33          * @return      void
34          */
35         protected function __construct () {
36                 // Call parent constructor
37                 parent::__construct(__CLASS__);
38
39                 // Set state name
40                 $this->setStateName('booting');
41         }
42
43         /**
44          * Creates an instance of this class
45          *
46          * @return      $stateInstance  An instance of a Stateable class
47          */
48         public final static function createMinerBootingState () {
49                 // Get new instance
50                 $stateInstance = new MinerBootingState();
51
52                 // Debug message
53                 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('MINER-STATE: Has changed from ' . $minerInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.');
54
55                 // Return the prepared instance
56                 return $stateInstance;
57         }
58
59         /**
60          * Executes the state with given Executor instance
61          *
62          * @param       $executorInstance       An instance of a Executor class
63          * @return      void
64          */
65         public function executeState (Executor $executorInstance) {
66                 // Has this executor (producer) run?
67                 if (isset($this->bootedProducer[$executorInstance->__toString()])) {
68                         // Then silently skip this
69                         return;
70                 } // END - if
71
72                 // Debug message
73                 /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('MINER-STATE: Calling prepareBlockProduction() on ' . $executorInstance->__toString() . ' ...');
74
75                 // Now prepare the unit production to maybe become 'virgin' or 'active' if work/test units are there
76                 $executorInstance->prepareBlockProduction($this);
77
78                 // Mark producer as booted
79                 $this->bootedProducer[$executorInstance->__toString()] = TRUE;
80         }
81 }
82
83 // [EOF]
84 ?>