]> git.mxchange.org Git - hub.git/blob - application/hub/main/factories/package/class_NetworkPackageFactory.php
Package class renamed, continued (sorry for lame description)
[hub.git] / application / hub / main / factories / package / class_NetworkPackageFactory.php
1 <?php
2 /**
3  * A factory class for network packages
4  *
5  * @author              Roland Haeder <webmaster@ship-simu.org>
6  * @version             0.0.0
7  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009, 2010 Hub Developer Team
8  * @license             GNU GPL 3.0 or any newer version
9  * @link                http://www.ship-simu.org
10  *
11  * This program is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation, either version 3 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program. If not, see <http://www.gnu.org/licenses/>.
23  */
24 class NetworkPackageFactory extends ObjectFactory {
25         /**
26          * Returns a singleton network package instance. If an instance is found in
27          * the registry it will be returned, else a new instance is created and
28          * stored in the same registry entry.
29          *
30          * @return      $packageInstance        A network package instance
31          */
32         public static final function createNetworkPackageInstance () {
33                 // Do we have an instance in the registry?
34                 if (Registry::getRegistry()->instanceExists('network_package')) {
35                         // Then use this instance
36                         $packageInstance = Registry::getRegistry()->getInstance('network_package');
37                 } else {
38                         /**
39                          * Prepare the compressor for our package, GZIP should be fine but we
40                          * keep it open here so you can experiment with the settings and don't
41                          * need to touch any code.
42                          */
43                         $compressorInstance = ObjectFactory::createObjectByConfiguredName('raw_package_compressor_class');
44
45                         // Prepare the decorator compressor (for later flawless and easy updates)
46                         $compressorInstance = ObjectFactory::createObjectByConfiguredName('deco_package_compressor_class', array($compressorInstance));
47
48                         // Now prepare the network package for delivery so only need to do this
49                         // once just before the "big announcement loop".
50                         $packageInstance = ObjectFactory::createObjectByConfiguredName('network_package_class', array($compressorInstance));
51
52                         // Set the instance in registry for further use
53                         Registry::getRegistry()->addInstance('network_package', $packageInstance);
54                 }
55
56                 // Return the instance
57                 return $packageInstance;
58         }
59
60         /**
61          * Protected constructor
62          *
63          * @return      void
64          */
65         protected function __construct () {
66                 // Call parent constructor
67                 parent::__construct(__CLASS__);
68         }
69 }
70 ?>