class_DebugMiddleware.php

Go to the documentation of this file.
00001 <?php
00026 class DebugMiddleware extends BaseMiddleware implements Registerable {
00030         private $outputInstance = null;
00031 
00035         private static $thisInstance = null;
00036 
00042         protected function __construct () {
00043                 // Call parent constructor
00044                 parent::__construct(__CLASS__);
00045 
00046                 // Set own instance
00047                 self::$thisInstance = $this;
00048         }
00049 
00059         public final static function createDebugMiddleware ($debuggerClass) {
00060                 // Create an instance if this middleware
00061                 $debugInstance = new DebugMiddleware();
00062 
00063                 // Is there a valid output instance provided?
00064                 if ((!is_null($debuggerClass)) && (is_object($debuggerClass)) && ($debuggerClass instanceof OutputStreamer)) {
00065                         // Use the given output instance
00066                         $debugInstance->setOutputInstance($debuggerClass);
00067                 } elseif ((!is_null($debuggerClass)) && (is_string($debuggerClass)) && (class_exists($debuggerClass))) {
00068                         // A name for a debug output class has been provided so we try to get it
00069                         $debuggerInstance = ObjectFactory::createObjectByName($debuggerClass);
00070 
00071                         // Set this as output class
00072                         $debugInstance->setOutputInstance($debuggerInstance);
00073                 }
00074 
00075                 // Return instance
00076                 return $debugInstance;
00077         }
00078 
00084         public final static function getInstance() {
00085                 return self::$thisInstance;
00086         }
00087 
00094         public final function setOutputInstance (OutputStreamer $outputInstance) {
00095                 $this->outputInstance = $outputInstance;
00096         }
00097 
00106         public final function output ($outStream) {
00107                 // Is the output stream set
00108                 if (empty($outStream)) {
00109                         // Initialization phase
00110                         return;
00111                 } // END - if
00112 
00113                 // Use the output instance
00114                 $this->outputInstance->outputStream($outStream);
00115         }
00116 }
00117 
00118 // [EOF]
00119 ?>

Generated on Mon Dec 8 01:06:46 2008 for Ship-Simulator by  doxygen 1.5.6