3 * A local query connector class
5 * @author Roland Haeder <webmaster@ship-simu.org>
7 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009, 2010 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()
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.
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.
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/>.
25 class LocalQueryConnector extends BaseQueryConnector implements Connectable, Visitable {
27 * The query class instance
29 private $queryInstance = null;
32 * Protected constructor
36 protected function __construct () {
37 // Call parent constructor
38 parent::__construct(__CLASS__);
40 // Init query instance
41 $this->queryInstance = ObjectFactory::createObjectByConfiguredName('local_query_class');
45 * Creates an instance of this query connector class
47 * @param $nodeInstance An instance of a node
48 * @return $connectorInstance An instance of this query connector class
50 public final static function createLocalQueryConnector (NodeHelper $nodeInstance) {
51 // Create the instance
52 $connectorInstance = new LocalQueryConnector();
54 // Set the node instance
55 $connectorInstance->setNodeInstance($nodeInstance);
57 // Get a list instance
58 $listInstance = ObjectFactory::createObjectByConfiguredName('local_query_list_class');
60 // Set it in the connector
61 $connectorInstance->setListInstance($listInstance);
63 // Prepare iterator instance
64 $iteratorInstance = ObjectFactory::createObjectByConfiguredName('query_iterator_class', array($listInstance));
67 $connectorInstance->setIteratorInstance($iteratorInstance);
69 // Finally return the connector
70 return $connectorInstance;
74 * Accepts the visitor to process the visit "request"
76 * @param $visitorInstance An instance of a Visitor class
79 public function accept (Visitor $visitorInstance) {
80 // Visit the query connector
81 $visitorInstance->visitQueryConnector($this);
83 // Visit the query as well
84 $this->queryInstance->accept($visitorInstance);
88 * Processes all pending queries. This method should be called by the
89 * ActiveTaskVisitor class and should use an iterator on all pending
94 public function processAllPendingQueries () {
95 $this->partialStub('Please implement this method.');