In case of non-blocking connections (and that is for 99.9999% the case here)
[hub.git] / application / hub / classes / crawler / class_BaseNodeCrawler.php
1 <?php
2 /**
3  * A general NodeCrawler class
4  *
5  * @author              Roland Haeder <webmaster@shipsimu.org>
6  * @version             0.0.0
7  * @copyright   Copyright (c) 2014 Crawler Developer Team
8  * @license             GNU GPL 3.0 or any newer version
9  * @link                http://www.shipsimu.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 BaseNodeCrawler extends BaseHubSystem {
25         /**
26          * Whether this Crawler is active
27          */
28         private $isActive = FALSE;
29
30         /**
31          * Protected constructor
32          *
33          * @param       $className      Name of the class
34          * @return      void
35          */
36         protected function __construct ($className) {
37                 // Call parent constructor
38                 parent::__construct($className);
39
40                 // Set this crawler instance in registry
41                 Registry::getRegistry()->addInstance('crawler', $this);
42
43                 // Init state which sets the state to 'init'
44                 $this->initState();
45         }
46
47         /**
48          * Initializes the node's state which sets it to 'init'
49          *
50          * @return      void
51          */
52         private function initState() {
53                 // Get the state factory and create the initial state.
54                 CrawlerStateFactory::createCrawlerStateInstanceByName('init');
55         }
56
57         /**
58          * Initializes this crawler instance
59          *
60          * @param       $stateInstance  An instance of a Stateable class
61          * @return      void
62          * @todo        0% done
63          */
64         public function initCrawler (Stateable $stateInstance) {
65                 // Please implement
66                 $this->partialStub('Unfinished method.');
67         }
68
69         /**
70          * Enables/disables the crawler (just sets a flag)
71          *
72          * @param       $version        Version number of this crawler
73          * @return      void
74          */
75         public final function enableIsActive ($isActive = TRUE) {
76                 $this->isActive = (bool) $isActive;
77         }
78
79         /**
80          * Determines whether the crawler is active
81          *
82          * @return      $isActive       Whether the crawler is active
83          */
84         public final function isActive () {
85                 return $this->isActive;
86         }
87 }
88
89 // [EOF]
90 ?>