Cascade Core  v0.12-1-g22cbbeb
 All Classes Namespaces Functions Variables Pages
Public Member Functions | Public Attributes | Static Public Attributes | Protected Attributes | List of all members
Block Class Reference

Base block infrastructure common to all blocks. More...

Inheritance diagram for Block:
Inheritance graph

Public Member Functions

 main ()
 Body of the block. More...
 
 id ()
 Get block id without namespaces.
 
 fullId ()
 Get full block id (including all parent namespaces).
 
 blockName ()
 Get block type.
 
 status ()
 Get block state.
 
 statusMessage ()
 Get status message - usually contains an error message why block failed.
 
 getCascadeController ()
 Get CascadeController which owns this block.
 
 getTimestamps ()
 Get profiler data. More...
 
 visibleBlockNames ()
 List all visible block names already in cascade (for debugging only) More...
 

Public Attributes

const force_exec = false
 Default value of 'force_exec' flag. More...
 

Static Public Attributes

static $STATUS_NAMES
 Map block state constants to strings. More...
 

Protected Attributes

 $inputs
 List of inputs and their default values. More...
 
 $connections
 List of default input connections (all inputs mentioned here must be present in $inputs array too) More...
 
 $outputs
 List of outputs (no default values) More...
 
 $context
 Global context. More...
 

Block states

block-states.png
const QUEUED = 0x00
 The block is waiting for execution.
 
const RUNNING = 0x01
 The block or its dependencies are being evaluated.
 
const ZOMBIE = 0x02
 The block is finished, exist only to maintain its outputs.
 
const DISABLED = 0x04
 The block is disabled, its 'enable' input is false.
 
const FAILED = 0x08
 The block has failed, because its inputs cannot be connected, or its dependencies cannot be solved, or it threw an exception. More...
 

Part of Cascade Controller

These methods should not be used by anything except the CascadeController.

Consider them private.

 cc_init ($parent, $id, $full_id, $cascade_controller, $block_name, $context, $initial_status=self::QUEUED, $initial_status_message=null)
 
 cc_connect (array $in_connections, array $in_values)
 
 cc_registerBlock ($block)
 
 cc_resolveBlockName ($block_name)
 
 cc_execute ()
 
 cc_getOutput ($name)
 
 cc_connections ()
 
 cc_outputs ()
 
 cc_outputCache ()
 
 cc_forwardedOutputs ()
 
 cc_outputExists ($name, $accept_wildcard=true)
 
 cc_getNamespace ()
 
 cc_executionTime ()
 
 cc_dumpNamespace ($level=1)
 
 cc_describeBlock ()
 

Inputs and outputs

 getOutput ($name)
 Calculate output value on demand. More...
 
 in ($name)
 Get value from input.
 
 inAll ()
 Get values from all inputs.
 
 inputNames ()
 Get all input names, excluding common inputs (enable and *)
 
 collectNumericInputs ()
 Collect values from numeric inputs - works well with vsprintf() More...
 
 out ($name, $value)
 Set value to output.
 
 outAll ($values)
 Set all output values. More...
 
 outForward ($name, $source_block, $source_name=null)
 Forward output from another block. More...
 

Template helpers

 templateAdd ($id_suffix, $template, $data=array())
 Add output object to template subsystem.
 
 templateAddToSlot ($id_suffix, $slot, $weight, $template, $data=array())
 Add output object to template subsystem (with slot and weight)
 
 templateSetPageTitle ($title, $format=null)
 Set page title.
 
 templateSetType ($type)
 Set output type.
 
 templateOptionSet ($slot, $option, $value)
 Set slot option.
 
 templateOptionAppend ($slot, $option, $value)
 Append value to slot option (which is list)
 

Cascade manipulation helpers

 cascadeAdd ($id, $block, $force_exec=null, $in_connections=array(), $in_values=array(), $context=null)
 Add block to cascade.
 
 cascadeAddFromArray ($array_of_blocks, $context=null)
 Add array of blocks to cascade (calls cascadeAdd() for each item). More...
 
 cascadeGetErrors ()
 Get errors from cascade controller (errors can occur when cascade_add or cascade_add_from_ini is called)
 

Authentication & Authorization helpers

 auth ()
 Get auth object from cascade controller.
 
 authIsBlockAllowed ($block_name, &$details=null)
 Check if block is allowed before cascade controller loads it.
 

Detailed Description

Base block infrastructure common to all blocks.

Member Function Documentation

main ( )
abstract

Body of the block.

The method called when block is evaluated.

Here is the caller graph for this function:

getTimestamps ( )
final

Get profiler data.

Returns array of timestams, when block has been created, started and finished.

visibleBlockNames ( )
final

List all visible block names already in cascade (for debugging only)

Bug:
This does not really work. It is only hotfix for Graphviz diagrams.
cc_execute ( )
final
Todo:
Lze spoustet zavislosti az na vyzadani a ne predem vse ?
Todo:
  • nebylo by lepsi to udelat az na pozadani ?

Here is the call graph for this function:

collectNumericInputs ( )
finalprotected

Collect values from numeric inputs - works well with vsprintf()

Deprecated:
Use template_format and inAll instead.

Here is the call graph for this function:

outAll (   $values)
finalprotected

Set all output values.

Keys are output names. Outputs missing in $values are unset.

outForward (   $name,
  $source_block,
  $source_name = null 
)
finalprotected

Forward output from another block.

Output value of $source_block:$source_name output is copied to local output $name.

Here is the call graph for this function:

Here is the caller graph for this function:

cascadeAddFromArray (   $array_of_blocks,
  $context = null 
)
finalprotected

Add array of blocks to cascade (calls cascadeAdd() for each item).

Items in $array_of_blocks look like this:

array(
    'block' => 'block/type',
    'force_exec' => true/false/null,
    'in_con' => array( ... like Block::$connections ... ),
    'in_val' => array( ... like Block::$inputs ... ),
),

Unknown keys are ignored.

Here is the caller graph for this function:

public function getOutput (   $name)

Calculate output value on demand.

If some output is not always used and is hard to compute, do not set output value in main(). Implement this method instead.

Member Data Documentation

const FAILED = 0x08

The block has failed, because its inputs cannot be connected, or its dependencies cannot be solved, or it threw an exception.

const force_exec = false

Default value of 'force_exec' flag.

It is used only when adding this block into cascade (not when calling CascadeController::addBlock() from this class). This is used when force_exec arg. is null (or not set at all).

$STATUS_NAMES
static
Initial value:
= array(
self::QUEUED => 'queued',
self::RUNNING => 'running',
self::ZOMBIE => 'zombie',
self::DISABLED => 'disabled',
self::FAILED => 'failed',
)

Map block state constants to strings.

$inputs
protected
Initial value:
= array(
)

List of inputs and their default values.

$connections
protected
Initial value:
= array(
)

List of default input connections (all inputs mentioned here must be present in $inputs array too)

$outputs
protected
Initial value:
= array(
)

List of outputs (no default values)

$context
protected

Global context.

A not-so-ugly way to make global things nice.