Source for file ServersMap.php

  1. <?php
  2.  
  3. /**
  4.  * Servers map
  5.  *
  6.  * @package MAP
  7.  *
  8.  */
  9.  
  10. if (version_compare(PHP_VERSION'5')) {
  11.     die('This file was generated for PHP 5');
  12. }
  13.  
  14. /* user defined includes */
  15. // section -64--88-1--106-4c67a877:12dbe634eaf:-8000:000000000000216F-includes begin
  16. // section -64--88-1--106-4c67a877:12dbe634eaf:-8000:000000000000216F-includes end
  17.  
  18. /* user defined constants */
  19. // section -64--88-1--106-4c67a877:12dbe634eaf:-8000:000000000000216F-constants begin
  20. // section -64--88-1--106-4c67a877:12dbe634eaf:-8000:000000000000216F-constants end
  21.  
  22. /**
  23.  * Servers map
  24.  *
  25.  * @package MAP
  26.  *
  27.  * @abstract
  28.  * @access public
  29.  */
  30. abstract class core_view_classes_ServersMap 
  31. {
  32.     // --- ASSOCIATIONS ---
  33.  
  34.  
  35.     // --- ATTRIBUTES ---
  36.  
  37.     /**
  38.      * List instance class "className"
  39.      *
  40.      * @access private
  41.      * @var array 
  42.      */
  43.     private $pull array();
  44.  
  45.     /**
  46.      * Maximum number of users per server
  47.      *
  48.      * @access protected
  49.      * @var int 
  50.      */
  51.     protected $maxUser = 1000;
  52.  
  53.     /**
  54.      * A list of the parameters to connect to servers
  55.      *
  56.      * @access private
  57.      * @var array 
  58.      */
  59.     private $serverList array();
  60.  
  61.     /**
  62.      * The class name
  63.      *
  64.      * @access protected
  65.      * @var string 
  66.      */
  67.     protected $className = '';
  68.  
  69.     // --- OPERATIONS ---
  70.  
  71.     /**
  72.      * Constructor
  73.      *
  74.      * @access public
  75.      * @param  array serverList A list of the parameters to connect to servers
  76.      * @return mixed 
  77.      */
  78.     public function __construct($serverList array()) {
  79.         // section -64--88-1--106-4c67a877:12dbe634eaf:-8000:0000000000002171 begin
  80.  
  81.         $this->serverList $serverList;
  82.  
  83.         // section -64--88-1--106-4c67a877:12dbe634eaf:-8000:0000000000002171 end
  84.     }
  85.  
  86.     /**
  87.      * Get "className" instance
  88.      *
  89.      * @access public
  90.      * @param  int userId User id
  91.      * @return object 
  92.      */
  93.     public function Get($userId{
  94.         $returnValue null;
  95.  
  96.         // section -64--88-1--106-4c67a877:12dbe634eaf:-8000:0000000000002178 begin
  97.         
  98.         $server_num  $this->GetServerNum($userId);
  99.         $returnValue $this->GetInstance($server_num);
  100.         
  101.         // section -64--88-1--106-4c67a877:12dbe634eaf:-8000:0000000000002178 end
  102.  
  103.         return $returnValue;
  104.     }
  105.  
  106.     /**
  107.      * Short description of method GetServerNum
  108.      *
  109.      * @access protected
  110.      * @param  int userId
  111.      * @return int 
  112.      */
  113.     protected function GetServerNum($userId{
  114.         $returnValue = (int) 0;
  115.  
  116.         // section -64--88-1--106--7d29545f:12e5ddbfa0f:-8000:0000000000002400 begin
  117.         
  118.         $userId     = (int)$userId;
  119.         $returnValue= (int)($userId/$this->maxUser);
  120.         
  121.         // section -64--88-1--106--7d29545f:12e5ddbfa0f:-8000:0000000000002400 end
  122.  
  123.         return (int) $returnValue;
  124.     }
  125.  
  126.     /**
  127.      * Short description of method GetInstance
  128.      *
  129.      * @access protected
  130.      * @param  int serverNum
  131.      * @return object 
  132.      */
  133.     protected function GetInstance($serverNum{
  134.         $returnValue null;
  135.  
  136.         // section -64--88-1--106--7d29545f:12e5ddbfa0f:-8000:0000000000002402 begin
  137.         
  138.         $returnValue $this->GetInstanceClass($serverNum);
  139.         
  140.         if (!empty($returnValue)) {
  141.             $returnValue $this->GetInstanceClass(0);
  142.         }
  143.         
  144.         // section -64--88-1--106--7d29545f:12e5ddbfa0f:-8000:0000000000002402 end
  145.  
  146.         return $returnValue;
  147.     }
  148.  
  149.     /**
  150.      * Create new intstance of "className" class or return exist intstance
  151.      *
  152.      * @access private
  153.      * @param  int serverNum Number of server
  154.      * @return object 
  155.      */
  156.     private function GetInstanceClass($serverNum 0{
  157.         $returnValue null;
  158.  
  159.         // section -64--88-1--106-4c67a877:12dbe634eaf:-8000:000000000000217C begin
  160.         
  161.         if ($this->className{
  162.             if (!isset($this->pull[$serverNum])) {
  163.                 if (!empty($this->serverList[$serverNum])) {
  164.                     $server $this->serverList[$serverNum];
  165.                     $this->pull[$serverNumnew $this->className(
  166.                         $server['host'],
  167.                         $server['port'],
  168.                         $server['prefix']
  169.                     );
  170.                     $returnValue $this->pull[$serverNum];
  171.                 }
  172.             else  $returnValue $this->pull[$serverNum];
  173.         }
  174.         
  175.         // section -64--88-1--106-4c67a877:12dbe634eaf:-8000:000000000000217C end
  176.  
  177.         return $returnValue;
  178.     }
  179.  
  180. /* end of abstract class core_view_classes_ServersMap */
  181.  
  182. ?>

Documentation generated on Thu, 03 Mar 2011 20:14:15 +0300 by phpDocumentor 1.4.3