system/util/Register.php

Show: inherited
Table of Contents

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
$Id$  

\Register

Package: phing\system\util

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  
Version
$Id$  

Properties

Propertyprivate  $slots= 'array()'
static

Slots that have been registered

Default valuearray()Details
Type
n/a

Methods

methodpublicgetSlot( string $key ) : \RegisterSlot
static

Returns 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

Package: phing\system\util

Represents a slot in the register.

Properties

Propertyprivate  $key= ''

The name of this slot.

Details
Type
n/a
Propertyprivate  $value= ''

The value for this slot.

Details
Type
n/a

Methods

methodpublic__construct( string $key ) : void

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
methodpublicgetKey( ) : string

Gets the key / name for this slot.

Returns
Type Description
string
methodpublicgetValue( ) : mixed

Returns the value at this slot.

Returns
Type Description
mixed
methodprivateimplodeArray( array $arr ) : string

Recursively implodes an array to a comma-separated string

Parameters
Name Type Description
$arr array
Returns
Type Description
string
methodpublicsetKey( string $k ) : void

Sets the key / name for this slot.

Parameters
Name Type Description
$k string
methodpublicsetValue(  $v ) : void

Sets the value for this slot.

Parameters
Name Type Description
$v

mixed

Documentation was generated by DocBlox 0.18.1.