classes/phing/system/util/Register.php

Static class to handle a slot-listening system.

Unlike the slots/signals Qt model, this class manages something that is more like a simple hashtable, where each slot has only one value. For that reason "Registers" makes more sense, the reference being to CPU registers.

This could be used for anything, but it's been built for a pretty specific phing need, and that is to allow access to dynamic values that are set by logic that is not represented in a build file. For exampe, we need a system for getting the current resource (file) that is being processed by a filterchain in a fileset.

Each slot corresponds to only one read-only, dynamic-value RegisterSlot object. In a build.xml register slots are expressed using a syntax similar to variables:

The task/type must provide a supporting setter for the attribute:

function setListeningReplace(RegisterSlot $slot) { $this->replace = $slot; }

// in main() if ($this->replace instanceof RegisterSlot) { $this->regexp->setReplace($this->replace->getValue()); } else { $this->regexp->setReplace($this->replace); }

author
Hans Lellelid
package
phing.system.util
version
$Revision: 1084 $

\Register

Static class to handle a slot-listening system.

Unlike the slots/signals Qt model, this class manages something that is more like a simple hashtable, where each slot has only one value. For that reason "Registers" makes more sense, the reference being to CPU registers.

This could be used for anything, but it's been built for a pretty specific phing need, and that is to allow access to dynamic values that are set by logic that is not represented in a build file. For exampe, we need a system for getting the current resource (file) that is being processed by a filterchain in a fileset.

Each slot corresponds to only one read-only, dynamic-value RegisterSlot object. In a build.xml register slots are expressed using a syntax similar to variables:

The task/type must provide a supporting setter for the attribute:

function setListeningReplace(RegisterSlot $slot) { $this->replace = $slot; }

// in main() if ($this->replace instanceof RegisterSlot) { $this->regexp->setReplace($this->replace->getValue()); } else { $this->regexp->setReplace($this->replace); }

author
Hans Lellelid
package
phing.system.util
version
$Revision: 1084 $

Properties

Propertyprivate  $slots= 'array'
static

Slots that have been registered

Default valuearrayDetails
Type

Methods

methodpublic  getSlot( string $key ) : \RegisterSlot
staticReturns RegisterSlot for specified key.

If not slot exists a new one is created for key.

Parameters
Name Type Description
$key string
Returns
Type Description
\RegisterSlot

\RegisterSlot

Represents a slot in the register.

package
phing.system.util

Properties

Propertyprivate  $key= ''

The name of this slot.

Details
Type
Propertyprivate  $value= ''

The value for this slot.

Details
Type

Methods

methodpublic  __construct( string $key ) :
Constructs a new RegisterSlot, setting the key to passed param.
Parameters
Name Type Description
$key string
methodpublic  __toString( ) : string
Returns the value at this slot as a string value.
Returns
Type Description
string
methodpublic  getKey( ) : string
Gets the key / name for this slot.
Returns
Type Description
string
methodpublic  getValue( ) : mixed
Returns the value at this slot.
Returns
Type Description
mixed
methodprivate  implodeArray( array $arr ) : string
Recursively implodes an array to a comma-separated string
Parameters
Name Type Description
$arr array
Returns
Type Description
string
methodpublic  setKey( string $k ) :
Sets the key / name for this slot.
Parameters
Name Type Description
$k string
methodpublic  setValue(  $v ) :
Sets the value for this slot.
Parameters
Name Type Description
$v mixed
Documentation was generated by DocBlox 0.13.1.