Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Attributes
nsRDFTestNode Class Reference

An abstract base class for all of the RDF-related tests. More...

#include <nsRDFTestNode.h>

Inheritance diagram for nsRDFTestNode:
Inheritance graph
[legend]
Collaboration diagram for nsRDFTestNode:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsRDFTestNode (InnerNode *aParent)
virtual PRBool CanPropagate (nsIRDFResource *aSource, nsIRDFResource *aProperty, nsIRDFNode *aTarget, Instantiation &aInitialBindings) const =0
 Determine wether the node can propagate an assertion with the specified source, property, and target.
virtual void Retract (nsIRDFResource *aSource, nsIRDFResource *aProperty, nsIRDFNode *aTarget, nsTemplateMatchSet &aFirings, nsTemplateMatchSet &aRetractions) const =0
 
  

InnerNodeGetParent () const
 Retrieve the test node's parent.
virtual nsresult Propagate (const InstantiationSet &aInstantiations, void *aClosure)
 Calls FilterInstantiations() on the instantiation set, and if the resulting set isn't empty, propagates the new set down to each of the test node's children.
virtual nsresult Constrain (InstantiationSet &aInstantiations, void *aClosure)
 Calls FilterInstantiations() on the instantiation set, and if the resulting set isn't empty, propagates the new set up to the test node's parent.
virtual nsresult FilterInstantiations (InstantiationSet &aInstantiations, void *aClosure) const =0
 Given a set of instantiations, filter out any that are inconsistent with the test node's test, and append variable-to-value assignments and memory element support for those which do pass the test node's test.
virtual nsresult GetAncestorVariables (VariableSet &aVariables) const
 Retrieve the set of variables that are introduced by this node and any of its ancestors.
virtual PRBool HasAncestor (const ReteNode *aNode) const
 Determine if this node has another node as its direct ancestor.
nsresult AddChild (ReteNode *aNode)
 Add another node as a child of this node.
nsresult RemoveAllChildren ()
 Remove all the children of this node.

Protected Attributes

InnerNodemParent
ReteNodeSet mKids

Detailed Description

An abstract base class for all of the RDF-related tests.

This interface allows us to iterate over all of the RDF tests to find the one in the network that is apropos for a newly-added assertion.

Definition at line 52 of file nsRDFTestNode.h.


Constructor & Destructor Documentation

nsRDFTestNode::nsRDFTestNode ( InnerNode aParent) [inline]

Definition at line 55 of file nsRDFTestNode.h.

        : TestNode(aParent) {}

Member Function Documentation

nsresult InnerNode::AddChild ( ReteNode aNode) [inline, inherited]

Add another node as a child of this node.

Parameters:
aNodethe node to add.
Returns:
NS_OK if no errors occur.

Definition at line 973 of file nsRuleNetwork.h.

{ return mKids.Add(aNode); }

Here is the call graph for this function:

Here is the caller graph for this function:

virtual PRBool nsRDFTestNode::CanPropagate ( nsIRDFResource aSource,
nsIRDFResource aProperty,
nsIRDFNode aTarget,
Instantiation aInitialBindings 
) const [pure virtual]

Determine wether the node can propagate an assertion with the specified source, property, and target.

If the assertion can be propagated, aInitialBindings will be initialized with appropriate variable-to-value assignments to allow the rule network to start a constrain and propagate search from this node in the network.

Returns:
PR_TRUE if the node can propagate the specified assertion.

Implemented in nsRDFPropertyTestNode, nsRDFConInstanceTestNode, and nsRDFConMemberTestNode.

Here is the caller graph for this function:

nsresult TestNode::Constrain ( InstantiationSet aInstantiations,
void aClosure 
) [virtual, inherited]

Calls FilterInstantiations() on the instantiation set, and if the resulting set isn't empty, propagates the new set up to the test node's parent.

Implements InnerNode.

Definition at line 1065 of file nsRuleNetwork.cpp.

{
    nsresult rv;

    PR_LOG(gXULTemplateLog, PR_LOG_DEBUG,
           ("TestNode[%p]: Constrain() begin", this));

    rv = FilterInstantiations(aInstantiations, aClosure);
    if (NS_FAILED(rv)) return rv;

    if (! aInstantiations.Empty()) {
        // if we still have instantiations, then ride 'em on up to the
        // parent to narrow them.

        PR_LOG(gXULTemplateLog, PR_LOG_DEBUG,
               ("TestNode[%p]: Constrain() passing to parent %p", this, mParent));

        rv = mParent->Constrain(aInstantiations, aClosure);
    }
    else {
        PR_LOG(gXULTemplateLog, PR_LOG_DEBUG,
               ("TestNode[%p]: Constrain() failed", this));

        rv = NS_OK;
    }

    PR_LOG(gXULTemplateLog, PR_LOG_DEBUG,
           ("TestNode[%p]: Constrain() end", this));

    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

virtual nsresult TestNode::FilterInstantiations ( InstantiationSet aInstantiations,
void aClosure 
) const [pure virtual, inherited]

Given a set of instantiations, filter out any that are inconsistent with the test node's test, and append variable-to-value assignments and memory element support for those which do pass the test node's test.

Parameters:
aInstantiationsthe set of instantiations to be filtered
aClosureapplication-specific data that is to be passed through the network.
Returns:
NS_OK if no errors occurred.

Implemented in nsRDFPropertyTestNode, nsRDFConInstanceTestNode, nsRDFConMemberTestNode, nsContentTestNode, nsTreeRowTestNode, and nsContentTagTestNode.

Here is the caller graph for this function:

nsresult TestNode::GetAncestorVariables ( VariableSet aVariables) const [virtual, inherited]

Retrieve the set of variables that are introduced by this node and any of its ancestors.

To correctly implement this method, a node must add any variables that it introduces to the variable set, and then recursively call GetAncestorVariables() on its parent (or parents).

Parameters:
aVariablesThe variable set to which the callee will add its variables, and its ancestors variables.
Returns:
NS_OK if no errors occur.

Implements InnerNode.

Reimplemented in nsRDFPropertyTestNode, nsRDFConInstanceTestNode, nsContentTestNode, nsRDFConMemberTestNode, nsTreeRowTestNode, and nsContentTagTestNode.

Definition at line 1099 of file nsRuleNetwork.cpp.

{
    return mParent->GetAncestorVariables(aVariables);
}

Here is the call graph for this function:

InnerNode* TestNode::GetParent ( ) const [inline, inherited]

Retrieve the test node's parent.

Returns:
the test node's parent

Definition at line 1065 of file nsRuleNetwork.h.

{ return mParent; }

Here is the caller graph for this function:

PRBool TestNode::HasAncestor ( const ReteNode aNode) const [virtual, inherited]

Determine if this node has another node as its direct ancestor.

Parameters:
aNodethe node to look for.
Returns:
PR_TRUE if aNode is a direct ancestor of this node, PR_FALSE otherwise.

Implements InnerNode.

Definition at line 1106 of file nsRuleNetwork.cpp.

{
    return aNode == this ? PR_TRUE : mParent->HasAncestor(aNode);
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult TestNode::Propagate ( const InstantiationSet aInstantiations,
void aClosure 
) [virtual, inherited]

Calls FilterInstantiations() on the instantiation set, and if the resulting set isn't empty, propagates the new set down to each of the test node's children.

Implements ReteNode.

Definition at line 1036 of file nsRuleNetwork.cpp.

{
    nsresult rv;

    PR_LOG(gXULTemplateLog, PR_LOG_DEBUG,
           ("TestNode[%p]: Propagate() begin", this));

    InstantiationSet instantiations = aInstantiations;
    rv = FilterInstantiations(instantiations, aClosure);
    if (NS_FAILED(rv)) return rv;

    if (! instantiations.Empty()) {
        ReteNodeSet::Iterator last = mKids.Last();
        for (ReteNodeSet::Iterator kid = mKids.First(); kid != last; ++kid) {
            PR_LOG(gXULTemplateLog, PR_LOG_DEBUG,
                   ("TestNode[%p]: Propagate() passing to child %p", this, kid.operator->()));

            kid->Propagate(instantiations, aClosure);
        }
    }

    PR_LOG(gXULTemplateLog, PR_LOG_DEBUG,
           ("TestNode[%p]: Propagate() end", this));

    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult InnerNode::RemoveAllChildren ( ) [inline, inherited]

Remove all the children of this node.

Returns:
NS_OK if no errors occur.

Definition at line 979 of file nsRuleNetwork.h.

{ return mKids.Clear(); }

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void nsRDFTestNode::Retract ( nsIRDFResource aSource,
nsIRDFResource aProperty,
nsIRDFNode aTarget,
nsTemplateMatchSet aFirings,
nsTemplateMatchSet aRetractions 
) const [pure virtual]

  

Implemented in nsRDFPropertyTestNode, nsRDFConInstanceTestNode, and nsRDFConMemberTestNode.

Here is the caller graph for this function:


Member Data Documentation

ReteNodeSet InnerNode::mKids [protected, inherited]

Definition at line 982 of file nsRuleNetwork.h.

InnerNode* TestNode::mParent [protected, inherited]

Definition at line 1100 of file nsRuleNetwork.h.


The documentation for this class was generated from the following file: