bb329f90370ad4711f999ea87bb4b4fda3faec75
[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\Task\Taskable;
7 use CoreFramework\Visitor\BaseVisitor;
8 use CoreFramework\Visitor\Pool\PoolVisitor;
9 use CoreFramework\Visitor\Task\TaskVisitor;
10
11 /**
12  * An ShutdownTask visitor
13  *
14  * @author              Roland Haeder <webmaster@shipsimu.org>
15  * @version             0.0.0
16  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
17  * @license             GNU GPL 3.0 or any newer version
18  * @link                http://www.shipsimu.org
19  *
20  * This program is free software: you can redistribute it and/or modify
21  * it under the terms of the GNU General Public License as published by
22  * the Free Software Foundation, either version 3 of the License, or
23  * (at your option) any later version.
24  *
25  * This program is distributed in the hope that it will be useful,
26  * but WITHOUT ANY WARRANTY; without even the implied warranty of
27  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28  * GNU General Public License for more details.
29  *
30  * You should have received a copy of the GNU General Public License
31  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
32  */
33 class ShutdownTaskVisitor extends BaseVisitor implements TaskVisitor, PoolVisitor, ListenerVisitor, DecoratorVisitor {
34         /**
35          * Protected constructor
36          *
37          * @return      void
38          */
39         protected function __construct () {
40                 // Call parent constructor
41                 parent::__construct(__CLASS__);
42
43                 // Set visitor mode
44                 $this->setVisitorMode('task');
45         }
46
47         /**
48          * Creates an instance of this class
49          *
50          * @return      $visitorInstance                An instance a Visitorable class
51          */
52         public static final function createShutdownTaskVisitor () {
53                 // Get new instance
54                 $visitorInstance = new ShutdownTaskVisitor();
55
56                 // Return the prepared instance
57                 return $visitorInstance;
58         }
59
60         /**
61          * Visits the given task instance
62          *
63          * @param       $taskInstance   A Taskable instance
64          * @return      void
65          */
66         public function visitTask (Taskable $taskInstance) {
67                 // Shutdown the task instance
68                 $taskInstance->doShutdown();
69         }
70
71         /**
72          * Pool visitor method for active tasks
73          *
74          * @param       $poolInstance   A Poolable instance
75          * @return      void
76          */
77         public function visitPool (Poolable $poolInstance) {
78                 // Shutdown the pool instance
79                 $poolInstance->doShutdown();
80         }
81
82         /**
83          * Visits the given listener instance
84          *
85          * @param       $listenerInstance       A Listenable instance
86          * @return      void
87          */
88         public function visitListener (Listenable $listenerInstance) {
89                 // Shutdown the listener instance
90                 $listenerInstance->doShutdown();
91         }
92
93         /**
94          * Visits the given decorator instance
95          *
96          * @param       $decoratorInstance      A decorator instance
97          * @return      void
98          */
99         public function visitDecorator (BaseDecorator $decoratorInstance) {
100                 // Shutdown the decorator instance
101                 $decoratorInstance->doShutdown();
102         }
103
104 }