Vanilla 1 Documentation Archive


~~NOTOC~~ ====== Class Library: Framework ====== ===== Class Delegation ===== ==== Overview: ==== ---- The Delegation class provides a means for extending the functionality of a class without using inheritance. It works by allowing clients to register callback functions (delegates) that are called by the Delegation instance. Subclasses define the name of each delegate and where it is called. The delegate has access to all public members of the calling object. ==== Fields: ==== ---- === Context === The handle to the [[Vanilla/Context.html|Context]] object. Required for fetching globally registered delegates. === Name === The class name. === Delegates === The array of delegates (callbacks) registered to a Delegation instance. === DelegateParameters === An associative array that is available to the delegate functions. Use of this array is the preferred method for passing parameters to delegates. ==== Methods: ==== ---- === Delegation [constructor] === == Signature: == <code php>$Delegation = $Context->ObjectFactory->NewContextObject($Context, 'Delegation');</code> == Description: == Constructs a Delegation instance with the given [[Vanilla/Context.html|Context]] handle. This class does not set a value in the 'Name' field, as it is not used directly (but could be). === AddToDelegate === == Signature: == <code php>[void] AddToDelegate($DelegateName, $FunctionName)</code> <code php>[void] $Context->AddToDelegate($ClassName, $DelegateName, $FunctionName)</code> == Description: == There are two methods for registering a delegate. The first method listed above has local scope: the delegate is only registered to a specific Delegation instance. The second has global scope: the delegate is automatically registered to every Delegation instance (as long as it is created by the [[Vanilla/Context.html|Context]] [[Vanilla/ObjectFactory.html|ObjectFactory]]) whose 'Name' field matches the first parameter. === CallDelegate === == Signature: == <code php>[void] CallDelegate($DelegateName)</code> == Description: == Calls each function registered under the given delegate name. === GetDelegatesFromContext === == Signature: == <code php>[void] GetDelegatesFromContext()</code> == Description: == This method fetches the list of global delegates registered to the class, using the value of the 'Name' variable as the key.

vanilla/vanilla_delegation.html.txt · Last modified: 2009/03/28 14:10
Vanilla 1 Documentation archive (Wiki by DokuWiki)