Continued:
[core.git] / framework / main / classes / registry / generic / class_GenericRegistry.php
1 <?php
2 // Own namespace
3 namespace Org\Mxchange\CoreFramework\Registry;
4
5 /**
6  * A registry for several data types and objects. Objects should be added by
7  * addInstance() and therefore must implement the interface Registerable.
8  *
9  * @author              Roland Haeder <webmaster@shipsimu.org>
10  * @version             0.0.0
11  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2019 Core Developer Team
12  * @license             GNU GPL 3.0 or any newer version
13  * @link                http://www.shipsimu.org
14  *
15  * This program is free software: you can redistribute it and/or modify
16  * it under the terms of the GNU General Public License as published by
17  * the Free Software Foundation, either version 3 of the License, or
18  * (at your option) any later version.
19  *
20  * This program is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23  * GNU General Public License for more details.
24  *
25  * You should have received a copy of the GNU General Public License
26  * along with this program. If not, see <http://www.gnu.org/licenses/>.
27  */
28 class GenericRegistry extends BaseRegistry implements Register {
29         /**
30          * Instance of this class
31          */
32         private static $registryInstance = NULL;
33
34         /**
35          * Protected constructor
36          *
37          * @return      void
38          */
39         protected function __construct () {
40                 // Call parent constructor
41                 parent::__construct(__CLASS__);
42         }
43
44         /**
45          * Singleton getter for self instance. This class has no factory pattern
46          * because here is no need for special parameters.
47          *
48          * @return      $registryInstance       Instance of this class
49          */
50         public static final function getRegistry () {
51                 // Is an instance there?
52                 if (is_null(self::$registryInstance)) {
53                         // Not yet, so create one
54                         self::$registryInstance = new GenericRegistry();
55                 } // END - if
56
57                 // Return the instance
58                 return self::$registryInstance;
59         }
60
61 }