]> git.mxchange.org Git - hub.git/blob - application/hub/main/connectors/query/local/class_LocalQueryConnector.php
23989f4bdbea01c32edbe676ce497b021bcccdfd
[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                 // Finally return the connector
64                 return $connectorInstance;
65         }
66
67         /**
68          * Accepts the visitor to rpocess the visit "request"
69          *
70          * @param       $visitorInstance        An instance of a Visitor class
71          * @return      void
72          */
73         public function accept (Visitor $visitorInstance) {
74                 // Visit the query connector
75                 $visitorInstance->visitQueryConnector($this);
76
77                 // Visit the query as well
78                 $this->queryInstance->accept($visitorInstance);
79         }
80 }
81
82 // [EOF]
83 ?>