Source for file ServersMap.php
<?php
/**
* Servers map
*
*
@package
MAP
*
*/
if
(
0
>
version_compare
(
PHP_VERSION
,
'5'
))
{
die
(
'This file was generated for PHP 5'
)
;
}
/* user defined includes */
// section -64--88-1--106-4c67a877:12dbe634eaf:-8000:000000000000216F-includes begin
// section -64--88-1--106-4c67a877:12dbe634eaf:-8000:000000000000216F-includes end
/* user defined constants */
// section -64--88-1--106-4c67a877:12dbe634eaf:-8000:000000000000216F-constants begin
// section -64--88-1--106-4c67a877:12dbe634eaf:-8000:000000000000216F-constants end
/**
* Servers map
*
*
@package
MAP
*
*
@abstract
*
@access
public
*/
abstract
class
core_view_classes_ServersMap
{
// --- ASSOCIATIONS ---
// --- ATTRIBUTES ---
/**
* List instance class "className"
*
*
@access
private
*
@var
array
*/
private
$pull
=
array
(
)
;
/**
* Maximum number of users per server
*
*
@access
protected
*
@var
int
*/
protected
$maxUser
=
1000
;
/**
* A list of the parameters to connect to servers
*
*
@access
private
*
@var
array
*/
private
$serverList
=
array
(
)
;
/**
* The class name
*
*
@access
protected
*
@var
string
*/
protected
$className
=
''
;
// --- OPERATIONS ---
/**
* Constructor
*
*
@access
public
*
@param
array
serverList A list of the parameters to connect to servers
*
@return
mixed
*/
public
function
__construct
(
$serverList
=
array
(
))
{
// section -64--88-1--106-4c67a877:12dbe634eaf:-8000:0000000000002171 begin
$this
->
serverList
=
$serverList
;
// section -64--88-1--106-4c67a877:12dbe634eaf:-8000:0000000000002171 end
}
/**
* Get "className" instance
*
*
@access
public
*
@param
int
userId User id
*
@return
object
*/
public
function
Get
(
$userId
)
{
$returnValue
=
null
;
// section -64--88-1--106-4c67a877:12dbe634eaf:-8000:0000000000002178 begin
$server_num
=
$this
->
GetServerNum
(
$userId
)
;
$returnValue
=
$this
->
GetInstance
(
$server_num
)
;
// section -64--88-1--106-4c67a877:12dbe634eaf:-8000:0000000000002178 end
return
$returnValue
;
}
/**
* Short description of method GetServerNum
*
*
@access
protected
*
@param
int
userId
*
@return
int
*/
protected
function
GetServerNum
(
$userId
)
{
$returnValue
= (int)
0
;
// section -64--88-1--106--7d29545f:12e5ddbfa0f:-8000:0000000000002400 begin
$userId
= (int)
$userId
;
$returnValue
= (int)
(
$userId
/
$this
->
maxUser
)
;
// section -64--88-1--106--7d29545f:12e5ddbfa0f:-8000:0000000000002400 end
return
(int)
$returnValue
;
}
/**
* Short description of method GetInstance
*
*
@access
protected
*
@param
int
serverNum
*
@return
object
*/
protected
function
GetInstance
(
$serverNum
)
{
$returnValue
=
null
;
// section -64--88-1--106--7d29545f:12e5ddbfa0f:-8000:0000000000002402 begin
$returnValue
=
$this
->
GetInstanceClass
(
$serverNum
)
;
if
(
!
empty
(
$returnValue
))
{
$returnValue
=
$this
->
GetInstanceClass
(
0
)
;
}
// section -64--88-1--106--7d29545f:12e5ddbfa0f:-8000:0000000000002402 end
return
$returnValue
;
}
/**
* Create new intstance of "className" class or return exist intstance
*
*
@access
private
*
@param
int
serverNum Number of server
*
@return
object
*/
private
function
GetInstanceClass
(
$serverNum
=
0
)
{
$returnValue
=
null
;
// section -64--88-1--106-4c67a877:12dbe634eaf:-8000:000000000000217C begin
if
(
$this
->
className
)
{
if
(
!
isset
(
$this
->
pull
[
$serverNum
]
))
{
if
(
!
empty
(
$this
->
serverList
[
$serverNum
]
))
{
$server
=
$this
->
serverList
[
$serverNum
]
;
$this
->
pull
[
$serverNum
]
=
new
$this
->
className
(
$server
[
'host'
]
,
$server
[
'port'
]
,
$server
[
'prefix'
]
)
;
$returnValue
=
$this
->
pull
[
$serverNum
]
;
}
}
else
$returnValue
=
$this
->
pull
[
$serverNum
]
;
}
// section -64--88-1--106-4c67a877:12dbe634eaf:-8000:000000000000217C end
return
$returnValue
;
}
}
/* end of abstract class core_view_classes_ServersMap */
?>
Documentation generated on Thu, 03 Mar 2011 20:14:15 +0300 by
phpDocumentor 1.4.3