]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/cruncher/mcrypt/class_HubMcryptCruncher.php
Introduced experimental apt-proxy sub project (a connector for apt-proxy usage into...
[hub.git] / application / hub / main / cruncher / mcrypt / class_HubMcryptCruncher.php
index 5d31bf53bd1e539f9340d7a172c1e43d7ec3c034..51d6224442f671581f004e7a5df9bd8f09e59c6d 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Hub Developer Team
+ * @copyright  Copyright (c) 2011 - 2012 Cruncher Developer Team
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.ship-simu.org
  *
@@ -38,16 +38,12 @@ class HubMcryptCruncher extends BaseHubCruncher implements CruncherHelper, Regis
        /**
         * Creates an instance of this hub-cruncher class
         *
-        * @param       $requestInstance        An instance of a Requestable class
         * @return      $cruncherInstance       An instance of this hub-cruncher class
         */
-       public final static function createHubMcryptCruncher (Requestable $requestInstance) {
+       public final static function createHubMcryptCruncher () {
                // Get a new instance
                $cruncherInstance = new HubMcryptCruncher();
 
-               // Set the request instance
-               $cruncherInstance->setRequestInstance($requestInstance);
-
                // Return the instance
                return $cruncherInstance;
        }
@@ -64,7 +60,26 @@ class HubMcryptCruncher extends BaseHubCruncher implements CruncherHelper, Regis
         * @return      void
         */
        protected function fillInBufferQueueWithTestUnits () {
-               $this->partialStub('Please implement this method.');
+               // Are test units enabled?
+               if ($this->getConfigInstance()->getConfigEntry('cruncher_test_units_enabled') == 'N') {
+                       // They are disabled, so skip any further steps
+                       return;
+               } elseif ($this->getStateInstance()->isCruncherStateVirgin()) {
+                       // No virgin crunchers please, because they usually have no test units ready for crunching
+                       return;
+               }
+
+               // Get a test-unit generator instance
+               $generatorInstance = ObjectFactory::createObjectByConfiguredName('cruncher_test_unit_generator_class');
+
+               // We don't need an iterator here because we just need to generate some test units
+               for ($idx = 0; $idx < $this->getConfigInstance()->getConfigEntry('cruncher_max_text_unit_amount'); $idx++) {
+                       // Get a test unit from it
+                       $unitInstance = $generatorInstance->generateNextUnitInstance();
+
+                       // ... and finally queue it to the in-buffer queue
+                       $this->queueUnitInstanceToInBuffer($unitInstance);
+               } // END - for
        }
 
        /**
@@ -74,6 +89,13 @@ class HubMcryptCruncher extends BaseHubCruncher implements CruncherHelper, Regis
         * @return      void
         */
        protected function fillInBufferQueueWithWorkUnits () {
+               // This cruncher's state must not be one of these: 'virgin'
+               if ($this->getStateInstance()->isCruncherStateVirgin()) {
+                       // We can silently skip here, until the generation is finished
+                       return;
+               } // END - if
+
+               // @TODO Implement this method
                $this->partialStub('Please implement this method.');
        }
 
@@ -97,14 +119,14 @@ class HubMcryptCruncher extends BaseHubCruncher implements CruncherHelper, Regis
         */
        public function outputConsoleTeaser () {
                // Output all lines
-               $this->debugOutput(' ');
-               $this->debugOutput('MCrypt Cruncher v' . $this->getVersion() . ' is starting ...');
-               $this->debugOutput('Copyright (c) 2011 MCrypt Cruncher Developer Team');
-               $this->debugOutput(' ');
-               $this->debugOutput('This program comes with ABSOLUTELY NO WARRANTY; for details see docs/COPYING.');
-               $this->debugOutput('This is free software, and you are welcome to redistribute it under certain');
-               $this->debugOutput('conditions; see docs/COPYING for details.');
-               $this->debugOutput(' ');
+               self::createDebugInstance(__CLASS__)->debugOutput(' ');
+               self::createDebugInstance(__CLASS__)->debugOutput('MCrypt Cruncher v' . $this->getVersion() . ' is starting ...');
+               self::createDebugInstance(__CLASS__)->debugOutput('Copyright (c) 2011 Cruncher Developer Team');
+               self::createDebugInstance(__CLASS__)->debugOutput(' ');
+               self::createDebugInstance(__CLASS__)->debugOutput('This program comes with ABSOLUTELY NO WARRANTY; for details see docs/COPYING.');
+               self::createDebugInstance(__CLASS__)->debugOutput('This is free software, and you are welcome to redistribute it under certain');
+               self::createDebugInstance(__CLASS__)->debugOutput('conditions; see docs/COPYING for details.');
+               self::createDebugInstance(__CLASS__)->debugOutput(' ');
        }
 
        /**