3 * A general Producer class
5 * @author Roland Haeder <webmaster@ship-simu.org>
7 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Hub Developer Team
8 * @license GNU GPL 3.0 or any newer version
9 * @link http://www.ship-simu.org
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.
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.
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/>.
24 abstract class BaseProducer extends BaseFrameworkSystem {
26 * Out-going work-queue
28 private $outgoingQueueInstance = null;
31 * Every procuded item/unit/etc. usually have a source
33 private $sourceInstance = null;
36 * Protected constructor
38 * @param $className Name of the class
41 protected function __construct ($className) {
42 // Call parent constructor
43 parent::__construct($className);
45 // Initialize all producers
46 $this->initProducer();
48 // Initialize work queue (out-going, produced items)
49 $this->initWorkQueue();
53 * Setter for out-going work queue
55 * @param $outgoingQueueInstance The out-going work queue instance
58 private function setOutgoingQueueInstance (Stackable $outgoingQueueInstance) {
59 $this->outgoingQueueInstance = $outgoingQueueInstance;
63 * Getter for out-going work queue
65 * @param $outgoingQueueInstance The out-going work queue instance
67 protected function getOutgoingQueueInstance () {
68 return $this->outgoingQueueInstance;
72 * Setter for a Sourceable instance
74 * @param $sourceInstance The Sourceable instance
77 protected function setSourceInstance (Sourceable $sourceInstance) {
78 $this->sourceInstance = $sourceInstance;
82 * Getter for a Sourceable instance
84 * @param $sourceInstance The Sourceable instance
86 protected function getSourceInstance () {
87 return $this->sourceInstance;
91 * Initializes this producer, this method must be overwritten.
95 abstract protected function initProducer();
98 * Initializes the work queue which is being used for out-going, produced
103 protected function initWorkQueue () {
104 // Get an instance and set it in this producer
105 $this->setOutgoingQueueInstance(ObjectFactory::createObjectByConfiguredName('producer_outgoing_work_queue'));
108 $this->getOutgoingQueueInstance()->initStacker('work_queue');
111 $this->debugOutput('PRODUCER: Out-going work queue initialized.');