3 namespace Org\Mxchange\City\Daemon\Task\Expander\Map;
5 // Import application-specific stuff
6 use Org\Mxchange\City\Daemon\Factory\CityDaemonFactory;
7 use Org\Mxchange\City\Task\BaseCityTask;
9 // Import framework stuff
10 use Org\Mxchange\CoreFramework\Task\Taskable;
11 use Org\Mxchange\CoreFramework\Visitor\Visitable;
12 use Org\Mxchange\CoreFramework\Visitor\Visitor;
15 * A map expander task for the daemon
17 * @author Roland Haeder <webmaster@ship-simu.org>
19 * @copyright Copyright (c) 2015, 2016 City Developer Team
20 * @license GNU GPL 3.0 or any newer version
21 * @link http://www.ship-simu.org
23 * This program is free software: you can redistribute it and/or modify
24 * it under the terms of the GNU General Public License as published by
25 * the Free Software Foundation, either version 3 of the License, or
26 * (at your option) any later version.
28 * This program is distributed in the hope that it will be useful,
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 * GNU General Public License for more details.
33 * You should have received a copy of the GNU General Public License
34 * along with this program. If not, see <http://www.gnu.org/licenses/>.
36 class CityDaemonMapExpanderTask extends BaseCityTask implements Taskable, Visitable {
38 * Protected constructor
42 protected function __construct () {
43 // Call parent constructor
44 parent::__construct(__CLASS__);
48 * Creates an instance of this class
50 * @return $taskInstance An instance of a Visitable class
52 public final static function createCityDaemonMapExpanderTask () {
54 $taskInstance = new CityDaemonMapExpanderTask();
56 // Get city daemon instance
57 $cityInstance = CityDaemonFactory::createCityDaemonInstance();
59 // Set it here for "caching" it
60 $taskInstance->setCityInstance($cityInstance);
62 // Return the prepared instance
67 * Accepts the visitor to process the visitor
69 * @param $visitorInstance An instance of a Visitor class
71 * @todo Maybe visit some sub-objects
73 public function accept (Visitor $visitorInstance) {
75 $visitorInstance->visitTask($this);
84 public function executeTask () {
85 // Get daemon instance
86 $cityInstance = $this->getCityInstance();
88 // Is there at least one map to expand?
89 if ($cityInstance->isMapPendingExpansion()) {
91 $cityInstance->expandMaps();
101 public function doShutdown () {
102 self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...');