class ComputedAssoc

Base class for deriving classes to represent relationships that can be computed from values of attributes of the monitored parent and child Item(s). More...

Contains pure virtuals
Definition#include <sysadm/ComputedAssoc.h>
InheritsAssociation
Inherited byChildAttrAssoc, ClustersAssocWithMachine, MachinesAssocWithCluster, ParentAttrAssoc
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Members

Protected Methods

Protected Members


Detailed Description

Base class for deriving classes to represent relationships that can be computed from values of attributes of the monitored parent and child Item(s). This class monitors the parent Item and Item(s) in the child Category that are potential children. The Item(s) that are potential children are indicated by a NotificationFilter that comes in effect when the parent Item is obtained. The NotificationFilter can be changed when the parent Item changes or at any arbitrary time.

Subclasses must override the isChild() method to provide logic that determines if the Item of the child Category passed to isChild() is a child of the parent Item.

This class calls isChild() anytime there is a change to the parent or the monitored child Item(s) and forwards notifications about changes in its list of child Item(s) to the listeners on this Association. When the parent Item changes, it gets the current list of child items and checks if any child Item(s) need to be added/removed from its list based on the computation performed by isChild(). When an Item of the child Category is added, removed or changed, it checks if the Item should be added/removed/updated in its list of child Item(s) based on isChild().

Sub-classes can fine-tune this behaviour by overriding the methods that are called upon notifications related to the parent and child Item(s). For example, subclass ChildAttrAssoc overrides parentChanged() to turn off computation of the list of child Item(s) when the parent Item changes and only does so on changes in the Item(s) of the child category.

static const char* NAME

Used internally for logging.

 ComputedAssoc (Category& parentCategory, const String& parentSelector, Category& childCategory)

[protected]

Constructor.

ComputedAssoc ()

[protected virtual]

Destructor.

bool  isChild (const Item& potentialChildItem)

[protected pure virtual]

Called when an Item in the child category is added/changed. Also called when the parent Item changes. Subclasses should override this and return true if "potentialChildItem" is a child of the parent Item of this Association. False otherwise.

void  parentAdded (const Item& item)

[protected virtual]

In addition to the semantics provided by Association::parentAdded it starts monitoring of Item(s) of the child category. Calls createAddedChildNotificationFilter() to determine the Items of child category that must be monitored.

Reimplemented from Association.

NotificationFilter*  createAddedChildNotificationFilter (const Item& parentItem)

[protected virtual]

Called by parentAdded() to determine the Item(s) of child category that must be monitored. Defined to return a filter that specifies monitoring of all Item(s) of the child category. Subclasses can override to provide different behavior. The return value cannot be NULL. The ComputedAssoc class owns the memory returned.

void  parentChanged (const Item& oldItem, const Item& newItem)

[protected virtual]

Called when parent Item changes. Gets the current list of child Item(s) and checks if any child Item(s) need to be added/removed from its list by calling isChild() for each Item. Forwards notifications of changes to the registered listeners.

Calls createChangedChildNotificationFilter() to determine the Items of child category that must be monitored based on the changes to the parent Item. If that returns NULL, no change is made to the list of Items of child category that are being monitored (since the most recent call to createAddedChildNotificationFilter() or createChangedChildNotificationFilter() or adoptAndReplaceChildNotificationFilter()) If that does not return NULL, recomputes the list of items from the universe of child Item(s) that match the filter specified in the return value.

Reimplemented from Association.

NotificationFilter*  createChangedChildNotificationFilter (const Item& oldItem, const Item& newItem)

[protected virtual]

Called by parentChanged() to determine the Item(s) of child category that must be monitored. A return value of NULL indicates no change is required to the list of Items of child category that are being monitored (since the most recent call to createAddedChildNotificationFilter() or createChangedChildNotificationFilter() or adoptAndReplaceChildNotificationFilter()). Defined to return a filter that specifies the monitoring of all items of the child category. Subclasses can override to provide different behavior. The ComputedAssoc class owns the memory returned.

void  parentRemoved ()

[protected virtual]

Provides the semantics of Association::parentRemoved().

Reimplemented from Association.

bool  hasParentExistedPreviously ()

[protected virtual]

Returns true if the parent Item existed and was removed during the lifecycle of this Association instance. Returns false, if the parent Item never existed during the lifecycle of this Association instance.

void  childCategoryItemAdded (const Item& item)

[protected virtual]

Called when a monitored Item of child category is determined to exist in the system at the time monitoring is started and if it is added later to the system. Calls isChild() and if it returns true, adds "item" to the list of child Item(s). Listeners are notified of any changes.

void  childCategoryItemChanged (const Item& oldItem, const Item& newItem)

[protected virtual]

Called when a monitored Item of child category changes to update the list of child Item(s). Calls isChild() and if it returns true, checks if "oldItem" was previously in the list. If it was not, "newItem" is added. If it was, "oldItem" is replaced by "newItem". If isChild() returns false, checks if "oldItem" was previously in the list and if so, removes "oldItem". Listeners are notified of any changes.

void  childCategoryItemRemoved (const String& selector)

[protected virtual]

Called when a monitored Item of child category is removed. Removes the Item corresponding to "selector" from our list of child Item(s), if it is present.

void  adoptAndReplaceChildNotificationFilter (NotificationFilter* filter)

[protected virtual]

This is a hook that can be called by subclasses at any time to change the list of child Item(s) that are currently being monitored. Recomputes the list of children from the universe of child Item(s) that match filter.

friend class ChildCategoryListener

[protected]

Allow ChildCategoryListener to invoke our protected methods.


Generated by: rusty@irem on Mon Sep 18 18:07:52 2000, using kdoc 2.0a36.