Public Member Functions
RAIN.Action.ActionContext Class Reference

ActionContext serves as a kind of shared memory context, or "blackboard", for Actions that work together to complete a task. ActionContext works as a typed name/value pair, with only one value allowed per name. More...

Inheritance diagram for RAIN.Action.ActionContext:
RAIN.Action.NestedActionContext

List of all members.

Public Member Functions

void AddDependency (string itemName, string dependsOnItemName)
 Adds a dependency between itemName and dependsOnItemName. Whenever "dependsOnItemName" changes in the ActionContext, itemName will be removed.
void RemoveDependency (string itemName, string dependsOnItemName)
 Removes a dependeny previously added between itemName and dependsOnItemName.
void ClearDependencies ()
 Remove all tracked dependencies.
virtual T GetContextItem< T > (string itemName)
 GetContextItem retrieves a value from the ActionContext based on its key itemName.
void AddContextItem< T > (string itemName, T value, bool replaceIfExists)
 AddContextItem adds the value to the context associated with the key itemName. If a key/value pair with key itemName already exists in the ActionContext, it is replaced with the new value/Type only if replaceIfExists is true. If there are any other context items dependent on itemName, they are removed from the ActionContext.
void SetContextItem< T > (string itemName, T value)
 SetContextItem adds the value to the context associated with the key itemName. If a key/value pair with key itemName already exists in the ActionContext, it is replaced with the new value/Type. If there are any other context items dependent on itemName, they are removed from the ActionContext.
void AddContextItem< T > (string itemName, T value)
 AddContextItem adds the value to the context associated with the key itemName. If a key/value pair with key itemName already exists in the ActionContext, it is replaced with the new value/Type. If there are any other context items dependent on itemName, they are removed from the ActionContext.
void RemoveContextItem (string itemName)
 Remove an item from the ActionContext. If there are any other context items dependent on itemName, they are removed from the ActionContext.
virtual bool ContextItemExists (string itemName)
 Check to see if any item exists with the given itemName.
void Assign (string toItemName, string fromItemName)
 Assign will retrieve the value of fromItemName and assign it to toItemNAme If fromItemName is not in the context, this is a noop.
void Clear ()
 Clear will reset the ActionContext to an empty state, with no current key/value pairs. Dependencies are retained.

Detailed Description

ActionContext serves as a kind of shared memory context, or "blackboard", for Actions that work together to complete a task. ActionContext works as a typed name/value pair, with only one value allowed per name.

ActionContexts may define dependencies betwen variables, which cause dependent variables to be removed from the context whenever its corresponding variable changes.


Member Function Documentation

void RAIN.Action.ActionContext.AddContextItem< T > ( string  itemName,
value,
bool  replaceIfExists 
)

AddContextItem adds the value to the context associated with the key itemName. If a key/value pair with key itemName already exists in the ActionContext, it is replaced with the new value/Type only if replaceIfExists is true. If there are any other context items dependent on itemName, they are removed from the ActionContext.

Template Parameters:
TThe type of the value being added
Parameters:
itemNameThe key to associate with the value
valueThe value to store
replaceIfExistsif false, only add if the value doesn't already exists
void RAIN.Action.ActionContext.AddContextItem< T > ( string  itemName,
value 
)

AddContextItem adds the value to the context associated with the key itemName. If a key/value pair with key itemName already exists in the ActionContext, it is replaced with the new value/Type. If there are any other context items dependent on itemName, they are removed from the ActionContext.

Template Parameters:
TThe type of the value being added
Parameters:
itemNameThe key to associate with the value
valueThe value to store
void RAIN.Action.ActionContext.AddDependency ( string  itemName,
string  dependsOnItemName 
)

Adds a dependency between itemName and dependsOnItemName. Whenever "dependsOnItemName" changes in the ActionContext, itemName will be removed.

Parameters:
itemNameThe key of the key value pair to remove on a dependency change
dependsOnItemNameThe key of the key value pair variable to watch for changes
void RAIN.Action.ActionContext.Assign ( string  toItemName,
string  fromItemName 
)

Assign will retrieve the value of fromItemName and assign it to toItemNAme If fromItemName is not in the context, this is a noop.

Parameters:
toItemNameitem to assign to
fromItemNameitem to retrieve value from

Clear will reset the ActionContext to an empty state, with no current key/value pairs. Dependencies are retained.

Remove all tracked dependencies.

virtual bool RAIN.Action.ActionContext.ContextItemExists ( string  itemName) [virtual]

Check to see if any item exists with the given itemName.

Parameters:
itemNameThe key to search for
Returns:
true if any item exists with key itemName, false otherwise

Reimplemented in RAIN.Action.NestedActionContext.

virtual T RAIN.Action.ActionContext.GetContextItem< T > ( string  itemName) [virtual]

GetContextItem retrieves a value from the ActionContext based on its key itemName.

Template Parameters:
TThe Type of the item to retrieve
Parameters:
itemNameThe Name of the item to retrieve
Returns:
If a value is found of type T with key name itemName, that value is returned. If a value is found matching itemName but of a different type, null is returned. If the itemName does not exist in the context, null is returned.

Reimplemented in RAIN.Action.NestedActionContext.

Remove an item from the ActionContext. If there are any other context items dependent on itemName, they are removed from the ActionContext.

Parameters:
itemNameThe name of the item to remove
void RAIN.Action.ActionContext.RemoveDependency ( string  itemName,
string  dependsOnItemName 
)

Removes a dependeny previously added between itemName and dependsOnItemName.

Parameters:
itemNamethe itemName to match
dependsOnItemNamethe dependsOnItemName to match
void RAIN.Action.ActionContext.SetContextItem< T > ( string  itemName,
value 
)

SetContextItem adds the value to the context associated with the key itemName. If a key/value pair with key itemName already exists in the ActionContext, it is replaced with the new value/Type. If there are any other context items dependent on itemName, they are removed from the ActionContext.

Template Parameters:
TThe type of the value being added
Parameters:
itemNameThe key to associate with the value
valueThe value to store