class_Registry.php

Go to the documentation of this file.
00001 <?php
00024 class Registry extends BaseFrameworkSystem implements Register {
00028         private static $selfInstance = null;
00029 
00033         private static $initialized = false;
00034 
00038         private $instanceRegistry = array();
00039 
00045         protected function __construct () {
00046                 // Call parent constructor
00047                 parent::__construct(__CLASS__);
00048 
00049                 // Clean up a little
00050                 $this->removeNumberFormaters();
00051                 $this->removeSystemArray();
00052         }
00053 
00059         public final static function getRegistry () {
00060                 // Is an instance there?
00061                 if (is_null(self::$selfInstance)) {
00062                         // Not yet, so create one
00063                         self::$selfInstance = new Registry();
00064                 }
00065 
00066                 // Return the instance
00067                 return self::$selfInstance;
00068         }
00069 
00076         public final static function isInitialized ($initialized = null) {
00077                 if (is_null($initialized)) {
00078                         // Get status if initialized
00079                         return self::$initialized;
00080                 } elseif (!is_null($initialized)) {
00081                         // Registry is initialized!
00082                         self::$initialized = true;
00083                 }
00084         }
00085 
00092         public function instanceExists ($instanceKey) {
00093                 // Does this key exists?
00094                 $exists = (isset($this->instanceRegistry[$instanceKey]));
00095 
00096                 // Return the result
00097                 return $exists;
00098         }
00099 
00107         public function addInstance ($instanceKey, Registerable $objectInstance) {
00108                 $this->instanceRegistry[$instanceKey] = $objectInstance;
00109         }
00110 
00117         public function getInstance ($instanceKey) {
00118                 // By default the instance is not in registry
00119                 $objectInstance = null;
00120 
00121                 // Is the instance there?
00122                 if ($this->instanceExists($instanceKey)) {
00123                         $objectInstance = $this->instanceRegistry[$instanceKey];
00124                 }
00125 
00126                 // Return the result
00127                 return $objectInstance;
00128         }
00129 }
00130 
00131 // [EOF]
00132 ?>

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