]> git.mxchange.org Git - hub.git/blob - application/hub/main/connectors/query/local/class_LocalQueryConnector.php
Self-test added, interfaces/classes extended:
[hub.git] / application / hub / main / connectors / query / local / class_LocalQueryConnector.php
1 <?php
2 /**
3  * A local query connector class
4  *
5  * @author              Roland Haeder <webmaster@ship-simu.org>
6  * @version             0.0.0
7  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
8  * @license             GNU GPL 3.0 or any newer version
9  * @link                http://www.ship-simu.org
10  * @todo                Find an interface for: handleAllQueries()
11  *
12  * This program is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation, either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
24  */
25 class LocalQueryConnector extends BaseQueryConnector implements Connectable, Visitable {
26         /**
27          * The query class instance
28          */
29         private $queryInstance = null;
30
31         /**
32          * Protected constructor
33          *
34          * @return      void
35          */
36         protected function __construct () {
37                 // Call parent constructor
38                 parent::__construct(__CLASS__);
39
40                 // Init query instance
41                 $this->queryInstance = ObjectFactory::createObjectByConfiguredName('local_query_class');
42         }
43
44         /**
45          * Creates an instance of this query connector class
46          *
47          * @param       $nodeInstance           An instance of a node
48          * @return      $connectorInstance      An instance of this query connector class
49          */
50         public final static function createLocalQueryConnector (NodeHelper $nodeInstance) {
51                 // Create the instance
52                 $connectorInstance = new LocalQueryConnector();
53
54                 // Set the node instance
55                 $connectorInstance->setNodeInstance($nodeInstance);
56
57                 // Get a list instance
58                 $listInstance = ObjectFactory::createObjectByConfiguredName('local_query_list_class');
59
60                 // Set it in the connector
61                 $connectorInstance->setListInstance($listInstance);
62
63                 // Prepare iterator instance
64                 $iteratorInstance = ObjectFactory::createObjectByConfiguredName('query_iterator_class', array($listInstance));
65
66                 // Set it, too
67                 $connectorInstance->setIteratorInstance($iteratorInstance);
68
69                 // Finally return the connector
70                 return $connectorInstance;
71         }
72
73         /**
74          * Accepts the visitor to rpocess the visit "request"
75          *
76          * @param       $visitorInstance        An instance of a Visitor class
77          * @return      void
78          */
79         public function accept (Visitor $visitorInstance) {
80                 // Visit the query connector
81                 $visitorInstance->visitQueryConnector($this);
82
83                 // Visit the query as well
84                 $this->queryInstance->accept($visitorInstance);
85         }
86
87         /**
88          * Processes all pending queries. This method should be called by the
89          * ActiveTaskVisitor class and should use an iterator on all pending
90          * queries.
91          *
92          * @return      void
93          */
94         public function processAllPendingQueries () {
95                 $this->partialStub('Please implement this method.');
96         }
97 }
98
99 // [EOF]
100 ?>