3 namespace CoreFramework\Visitor\Task\Shutdown;
5 // Import framework stuff
6 use CoreFramework\Generic\BaseDecorator;
7 use CoreFramework\Listener\Listenable;
8 use CoreFramework\Pool\Poolable;
9 use CoreFramework\Task\Taskable;
10 use CoreFramework\Visitor\BaseVisitor;
11 use CoreFramework\Visitor\Decorator\DecoratorVisitor;
12 use CoreFramework\Visitor\Listener\ListenerVisitor;
13 use CoreFramework\Visitor\Pool\PoolVisitor;
14 use CoreFramework\Visitor\Task\TaskVisitor;
17 * An ShutdownTask visitor
19 * @author Roland Haeder <webmaster@shipsimu.org>
21 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
22 * @license GNU GPL 3.0 or any newer version
23 * @link http://www.shipsimu.org
25 * This program is free software: you can redistribute it and/or modify
26 * it under the terms of the GNU General Public License as published by
27 * the Free Software Foundation, either version 3 of the License, or
28 * (at your option) any later version.
30 * This program is distributed in the hope that it will be useful,
31 * but WITHOUT ANY WARRANTY; without even the implied warranty of
32 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 * GNU General Public License for more details.
35 * You should have received a copy of the GNU General Public License
36 * along with this program. If not, see <http://www.gnu.org/licenses/>.
38 class ShutdownTaskVisitor extends BaseVisitor implements TaskVisitor, PoolVisitor, ListenerVisitor, DecoratorVisitor {
40 * Protected constructor
44 protected function __construct () {
45 // Call parent constructor
46 parent::__construct(__CLASS__);
49 $this->setVisitorMode('task');
53 * Creates an instance of this class
55 * @return $visitorInstance An instance a Visitorable class
57 public static final function createShutdownTaskVisitor () {
59 $visitorInstance = new ShutdownTaskVisitor();
61 // Return the prepared instance
62 return $visitorInstance;
66 * Visits the given task instance
68 * @param $taskInstance A Taskable instance
71 public function visitTask (Taskable $taskInstance) {
72 // Shutdown the task instance
73 $taskInstance->doShutdown();
77 * Pool visitor method for active tasks
79 * @param $poolInstance A Poolable instance
82 public function visitPool (Poolable $poolInstance) {
83 // Shutdown the pool instance
84 $poolInstance->doShutdown();
88 * Visits the given listener instance
90 * @param $listenerInstance A Listenable instance
93 public function visitListener (Listenable $listenerInstance) {
94 // Shutdown the listener instance
95 $listenerInstance->doShutdown();
99 * Visits the given decorator instance
101 * @param $decoratorInstance A decorator instance
104 public function visitDecorator (BaseDecorator $decoratorInstance) {
105 // Shutdown the decorator instance
106 $decoratorInstance->doShutdown();