]> git.mxchange.org Git - core.git/blob - framework/main/classes/visitor/tasks/class_ShutdownTaskVisitor.php
144357be44e3ea9f00a195693c75037e7932039b
[core.git] / framework / main / classes / visitor / tasks / class_ShutdownTaskVisitor.php
1 <?php
2 // Own namespace
3 namespace CoreFramework\Visitor\Task\Shutdown;
4
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;
15
16 /**
17  * An ShutdownTask visitor
18  *
19  * @author              Roland Haeder <webmaster@shipsimu.org>
20  * @version             0.0.0
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
24  *
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.
29  *
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.
34  *
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/>.
37  */
38 class ShutdownTaskVisitor extends BaseVisitor implements TaskVisitor, PoolVisitor, ListenerVisitor, DecoratorVisitor {
39         /**
40          * Protected constructor
41          *
42          * @return      void
43          */
44         protected function __construct () {
45                 // Call parent constructor
46                 parent::__construct(__CLASS__);
47
48                 // Set visitor mode
49                 $this->setVisitorMode('task');
50         }
51
52         /**
53          * Creates an instance of this class
54          *
55          * @return      $visitorInstance                An instance a Visitorable class
56          */
57         public static final function createShutdownTaskVisitor () {
58                 // Get new instance
59                 $visitorInstance = new ShutdownTaskVisitor();
60
61                 // Return the prepared instance
62                 return $visitorInstance;
63         }
64
65         /**
66          * Visits the given task instance
67          *
68          * @param       $taskInstance   A Taskable instance
69          * @return      void
70          */
71         public function visitTask (Taskable $taskInstance) {
72                 // Shutdown the task instance
73                 $taskInstance->doShutdown();
74         }
75
76         /**
77          * Pool visitor method for active tasks
78          *
79          * @param       $poolInstance   A Poolable instance
80          * @return      void
81          */
82         public function visitPool (Poolable $poolInstance) {
83                 // Shutdown the pool instance
84                 $poolInstance->doShutdown();
85         }
86
87         /**
88          * Visits the given listener instance
89          *
90          * @param       $listenerInstance       A Listenable instance
91          * @return      void
92          */
93         public function visitListener (Listenable $listenerInstance) {
94                 // Shutdown the listener instance
95                 $listenerInstance->doShutdown();
96         }
97
98         /**
99          * Visits the given decorator instance
100          *
101          * @param       $decoratorInstance      A decorator instance
102          * @return      void
103          */
104         public function visitDecorator (BaseDecorator $decoratorInstance) {
105                 // Shutdown the decorator instance
106                 $decoratorInstance->doShutdown();
107         }
108
109 }