]> git.mxchange.org Git - shipsimu.git/blobdiff - application/ship-simu/main/class_BaseSimulator.php
'public static final' is correct
[shipsimu.git] / application / ship-simu / main / class_BaseSimulator.php
index ec3fe30f342500500b6c8b66f9c16b27451f66a2..d26ea246fe2ed5e23f4165ff880bc52155a4f801 100644 (file)
@@ -4,9 +4,9 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright(c) 2007, 2008 Roland Haeder, this is free software
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Ship-Simu Developer Team
  * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.ship-simu.org
+ * @link               http://www.ship-simu.org
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -19,7 +19,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 class BaseSimulator extends BaseFrameworkSystem {
        // Schiffsteilinstanz
@@ -42,16 +42,9 @@ class BaseSimulator extends BaseFrameworkSystem {
        );
 
        // Konstruktor
-       private function __construct ($class) {
+       protected function __construct ($className) {
                // Call highest constructor
-               parent::constructor($class);
-
-               if ((defined('DEBUG_CORE')) && (defined('DEBUG_CONSTRUCT'))) $this->getDebugInstance()->output(sprintf("[%s:] Konstruktor erreicht.<br />\n",
-                       $this->__toString()
-               ));
-
-               // Set part description and class name
-               $this->setPartDescr("Simulator-Basis-Einheit");
+               parent::__construct($className);
 
                // Clean up a little, dies sollte ganz zum Schluss erfolgen!
                $this->removeResizeFactorArray();
@@ -59,76 +52,33 @@ class BaseSimulator extends BaseFrameworkSystem {
                $this->removeCurrShip();
        }
 
-       // Public constructor
-       public function constructor ($class) {
-               // Call real constructor
-               $this->__construct($class);
-       }
-
-       // Magic __isset method
-       private function __isset ($var) {
-               if (defined('DEBUG_CORE')) $this->getDebugInstance()->output(sprintf("[%s:] Checking <strong>%s</strong> in class.<br />\n",
-                       $this->__toString(), $var
-               ));
-               return isset($this->$var);
-       }
-
-       // Magic __unset method
-       private function __unset($var) {
-               if (defined('DEBUG_CORE')) $this->getDebugInstance()->output(sprintf("[%s:] Removing <strong>%s</strong> from class.<br />\n",
-                       $this->__toString(), $var
-               ));
-               unset($this->$var);
-       }
-
        // Setter-Methode fuer Laenge
        public final function setLength ($length) {
-               if (defined('DEBUG_CORE')) $this->getDebugInstance()->output(sprintf("[%s:] <strong>%dm</strong> L&auml;nge gesetzt.<br />\n",
-                       $this->__toString(),
-                       $length
-               ));
                $this->length = (float) $length;
        }
 
        // Setter-Methode fuer Breite
        public final function setWidth ($width) {
-               if (defined('DEBUG_CORE')) $this->getDebugInstance()->output(sprintf("[%s:] <strong>%dm</strong> Breite gesetzt.<br />\n",
-                       $this->__toString(),
-                       $width
-               ));
                $this->width = (float) $width;
        }
 
        // Setter-Methode fuer Hoehe
        public final function setHeight ($height) {
-               if (defined('DEBUG_CORE')) $this->getDebugInstance()->output(sprintf("[%s:] <strong>%dm</strong> H&ouml;he gesetzt.<br />\n",
-                       $this->__toString(),
-                       $height
-               ));
                $this->height = (float) $height;
        }
 
        // Getter-Methode fuer Laenge
        public final function getLength () {
-               if (defined('DEBUG_CORE')) $this->getDebugInstance()->output(sprintf("[%s:] L&auml;nge angefordert.<br />\n",
-                       $this->__toString()
-               ));
                return $this->length;
        }
 
        // Getter-Methode fuer Breite
        public final function getWidth () {
-               if (defined('DEBUG_CORE')) $this->getDebugInstance()->output(sprintf("[%s:] L&auml;nge angefordert.<br />\n",
-                       $this->__toString()
-               ));
                return $this->width;
        }
 
        // Getter-Methode fuer Hoehe
        public final function getHeight () {
-               if (defined('DEBUG_CORE')) $this->getDebugInstance()->output(sprintf("[%s:] H&ouml;he angefordert.<br />\n",
-                       $this->__toString()
-               ));
                return $this->height;
        }
 
@@ -147,18 +97,7 @@ class BaseSimulator extends BaseFrameworkSystem {
 
        // Remover-Methode fuer die Teil-Instanz
        public final function removePartInstance () {
-               if ($this->getPartInstance() !== null) {
-                       // Warnung ausgeben
-                       if (defined('DEBUG_CORE')) $this->getDebugInstance()->output(sprintf("[%s:] partInstance ist nicht null! Instanz-Attribut wird nicht entfernt.<br />\n",
-                               $this->__toString()
-                       ));
-               } else {
-                       // Leere Instanz kann entfernt werden
-                       if (defined('DEBUG_CORE')) $this->getDebugInstance()->output(sprintf("[%s:] partInstance wurde entfernt.<br />\n",
-                               $this->__toString()
-                       ));
-                       unset($this->partInstance);
-               }
+               unset($this->partInstance);
        }
 
        // Prueft ob all Umberechnungsfaktoren gesetzt sind
@@ -175,22 +114,8 @@ class BaseSimulator extends BaseFrameworkSystem {
                $this->currShip = $shipInstance;
                $this->currPart = $partInstance;
 
-               if (defined('DEBUG_CORE')) $this->getDebugInstance()->output(sprintf("[%s:] Maschinenraum mit Motor <strong>%s</strong> wird fuer das Schiff <strong>%s</strong> konstruiert.<br />\n",
-                       $this->__toString(),
-                       $this->getCurrPart()->getPartDescr(),
-                       $this->currShip->getShipName()
-               ));
-
                // Passt ueberhaupt das Schiffsteil in's Schiff?
                if ($this->isShipPartSizeValid()) {
-                       // Berechnungen fuer umliegendes Objekt anpassen
-                       if (defined('DEBUG_CORE')) $this->getDebugInstance()->output(sprintf("[%s:] Das Schiffsteil <strong>%s</strong> vom Typ <strong>%s</strong> passt in das Schiff <strong>%s</strong> hinein.<br />\n",
-                               $this->__toString(),
-                               $this->getCurrPart()->getPartDescr(),
-                               $this->getCurrPart()->__toString(),
-                               $this->currShip->getShipName()
-                       ));
-
                        // Muessen die Masse angepasst werden?
                        if ($this->isResizeFactorValid()) {
                                // Neue Angaben berechnen (wir lassen etwas Lust fuer Kabelbaeume, Roehren, Maschinisten, etc.)
@@ -201,11 +126,6 @@ class BaseSimulator extends BaseFrameworkSystem {
                                // Passt dies nun immer noch?
                                if ($this->isNewSizeValid()) {
                                        // Das passt auch, dann Werte setzen und Motor-Instanz merken
-                                       if (defined('DEBUG_CORE')) $this->getDebugInstance()->output(sprintf("[%s:] Das Schiffsteil <strong>%s</strong> passt in das Schiff <strong>%s</strong> hinein.<br />\n",
-                                               $this->__toString(),
-                                               $this->getPartDescr(),
-                                               $this->currShip->getShipName()
-                                       ));
                                        $this->setWidth($this->newWidth);
                                        $this->setHeight($this->newHeight);
                                        $this->setLength($this->newLength);
@@ -216,7 +136,7 @@ class BaseSimulator extends BaseFrameworkSystem {
                                        // Passt nicht! Also wieder Exception werfen...
                                        throw new StructureShipMismatchException(sprintf("[%s:] Das Schiffsteil <strong>%s</strong> vom Typ <strong>%s</strong> ist zu gross f&uuml;r das Schiff!",
                                                $this->getCurrPart()->__toString(),
-                                               $this->getCurrPart()->getPartDescr(),
+                                               $this->getCurrPart()->getObjectDescription(),
                                                $this->getCurrPart()->__toString()
                                        ), 2);
                                }
@@ -229,12 +149,6 @@ class BaseSimulator extends BaseFrameworkSystem {
 
                        // Existiert ein Schiffsteil?
                        if (!is_null($this->currPart)) {
-                               // Debug-Meldung ausgeben
-                               if (defined('DEBUG_CORE')) $this->getDebugInstance()->output(sprintf("[%s:] Schiffsteil <strong>%s</strong> gefunden.<br />\n",
-                                       $this->getCurrPart()->realClass,
-                                       $this->getCurrPart()->getPartDescr()
-                               ));
-
                                // Schiffsteil-Instanz setzen
                                $this->setPartInstance($this->currPart);
 
@@ -248,7 +162,7 @@ class BaseSimulator extends BaseFrameworkSystem {
                        // Exception werfen!
                        throw new StructureShipMismatchException(sprintf("[%s:] Das Schiffsteil <u>%s</u> vom Typ <u>%s</u> passt nicht in das Schiff!",
                                $this->getCurrPart()->realClass,
-                               $this->getCurrPart()->getPartDescr(),
+                               $this->getCurrPart()->getObjectDescription(),
                                $this->getCurrPart()->__toString()
                        ), 1);
                }
@@ -261,9 +175,6 @@ class BaseSimulator extends BaseFrameworkSystem {
 
        // Array fuer Umrechnungstabelle entfernen
        public final function removeResizeFactorArray () {
-               if (defined('DEBUG_CORE')) $this->getDebugInstance()->output(sprintf("[%s:] removeResizeFactor erreicht.<br />\n",
-                       $this->__toString()
-               ));
                unset($this->resizeFactorArray);
        }
 
@@ -284,82 +195,52 @@ class BaseSimulator extends BaseFrameworkSystem {
         * @return      void
         */
        public final function removeCurrShip () {
-               if (defined('DEBUG_CORE')) $this->getDebugInstance()->output(sprintf("[%s:] removeCurrShip erreicht.<br />\n",
-                       $this->__toString()
-               ));
                unset($this->currShip);
        }
 
        // Aktuelle Schiffsteil-Instanz entfernen
        public final function removeCurrPart () {
-               if (defined('DEBUG_CORE')) $this->getDebugInstance()->output(sprintf("[%s:] removeCurrPart erreicht.<br />\n",
-                       $this->__toString()
-               ));
                unset($this->currPart);
        }
 
        // Breite entfernen
        public final function removeWidth () {
-               if (defined('DEBUG_CORE')) $this->getDebugInstance()->output(sprintf("[%s:] Breite entfernt.<br />\n",
-                       $this->__toString()
-               ));
                unset($this->width);
        }
 
        // Hoehe entfernen
        public final function removeHeight () {
-               if (defined('DEBUG_CORE')) $this->getDebugInstance()->output(sprintf("[%s:] H&ouml;he entfernt.<br />\n",
-                       $this->__toString()
-               ));
                unset($this->height);
        }
 
        // Laenge entfernen
        public final function removeLength () {
-               if (defined('DEBUG_CORE')) $this->getDebugInstance()->output(sprintf("[%s:] L&auml;nge entfernt.<br />\n",
-                       $this->__toString()
-               ));
                unset($this->length);
        }
 
        // Tiefgang entfernen
        public final function removeDraught () {
-               if (defined('DEBUG_CORE')) $this->getDebugInstance()->output(sprintf("[%s:] Tiefgang entfernt.<br />\n",
-                       $this->__toString()
-               ));
                unset($this->draught);
        }
 
        // Getter-Methode fuer Element aus resizeFactor
        public final function getResizeFactorElement ($el) {
-               if (defined('DEBUG_CORE')) $this->getDebugInstance()->output(sprintf("[%s:] getResizeFactorElement erreicht. (element=%s)<br />\n",
-                       $this->__toString(),
-                       $el
-               ));
                if (isset($this->resizeFactorArray[$el])) {
                        // Element gefunden
                        return $this->resizeFactorArray[$el];
                } else {
                        // Element nicht gefunden!
-                       return 0;
+                       return null;
                }
        }
 
        // Setter-Methode fuer Element in resizeFactor
        public final function setResizeFactorElement ($el, $value) {
-               if (defined('DEBUG_CORE')) $this->getDebugInstance()->output(sprintf("[%s:] Umberechnungsfaktor <strong>%s</strong>=<strong>%s</strong> gesetzt.<br />\n",
-                       $this->__toString(),
-                       $el,
-                       $value
-               ));
                $this->resizeFactorArray[$el] = (float) $value;
        }
 
        // Kontrolliert, ob die Abmasse Schiffsteil->Schiff stimmen
        public function isShipPartSizeValid () {
-               if (defined('DEBUG_CORE')) $this->getDebugInstance()->output(sprintf("[%s:] isShipPartSizeValid erreicht.<br />\n",
-                       $this->__toString()
-               ));
                return (
                        (
                                ( // Already defined ship messurings
@@ -380,9 +261,6 @@ class BaseSimulator extends BaseFrameworkSystem {
 
        // Kontrolliert, ob die Abmasse Maschinenraum->Schiff stimmen
        public function isNewSizeValid () {
-               if (defined('DEBUG_CORE')) $this->getDebugInstance()->output(sprintf("[%s:] isNewSizeValid erreicht.<br />\n",
-                       $this->__toString()
-               ));
                return (
                        ( // Already defined ship messurings
                                         ($this->newWidth  < $this->currShip->getWidth())
@@ -398,11 +276,6 @@ class BaseSimulator extends BaseFrameworkSystem {
 
        // Masse extrahieren
        public function extractDimensions ($dim) {
-               if (defined('DEBUG_CORE')) $this->getDebugInstance()->output(sprintf("[%s:] extractDimensions erreicht f&uuml;r <strong>%s</strong>.<br />\n",
-                       $this->__toString(),
-                       $this->getPartDescr()
-               ));
-
                // Abmasse setzen
                if ((isset($dim)) && (is_array($dim)) && (count($dim) == 3)) {
                        // Abmasse aus Array holen