Back to index

lightning-sunbird  0.9+nobinonly
Classes | Public Types | Public Member Functions | Protected Attributes
nsTreeRowTestNode Class Reference

#include <nsTreeRowTestNode.h>

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

List of all members.

Classes

class  Element

Public Types

enum  { kRoot = -1 }

Public Member Functions

 nsTreeRowTestNode (InnerNode *aParent, nsConflictSet &aConflictSet, nsTreeRows &aRows, PRInt32 aIdVariable)
virtual nsresult FilterInstantiations (InstantiationSet &aInstantiations, void *aClosure) const
 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.
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 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

nsConflictSetmConflictSet
nsTreeRowsmRows
PRInt32 mIdVariable
InnerNodemParent
ReteNodeSet mKids

Detailed Description

Definition at line 49 of file nsTreeRowTestNode.h.


Member Enumeration Documentation

anonymous enum
Enumerator:
kRoot 

Definition at line 52 of file nsTreeRowTestNode.h.

{ kRoot = -1 };

Constructor & Destructor Documentation

nsTreeRowTestNode::nsTreeRowTestNode ( InnerNode aParent,
nsConflictSet aConflictSet,
nsTreeRows aRows,
PRInt32  aIdVariable 
)

Definition at line 50 of file nsTreeRowTestNode.cpp.

    : TestNode(aParent),
      mConflictSet(aConflictSet),
      mRows(aRows),
      mIdVariable(aIdVariable)
{
    PR_LOG(gXULTemplateLog, PR_LOG_DEBUG,
           ("nsTreeRowTestNode[%p]: parent=%p id-var=%d",
            this, aParent, aIdVariable));
}

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:

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:

nsresult nsTreeRowTestNode::FilterInstantiations ( InstantiationSet aInstantiations,
void aClosure 
) const [virtual]

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.

Implements TestNode.

Definition at line 65 of file nsTreeRowTestNode.cpp.

{
    InstantiationSet::Iterator last = aInstantiations.Last();
    for (InstantiationSet::Iterator inst = aInstantiations.First(); inst != last; ++inst) {
        Value idValue;
        PRBool hasIdBinding =
            inst->mAssignments.GetAssignmentFor(mIdVariable, &idValue);

#ifdef PR_LOGGING
        if (PR_LOG_TEST(gXULTemplateLog, PR_LOG_DEBUG)) {
            const char* id = "(unbound)";
            if (hasIdBinding)
                VALUE_TO_IRDFRESOURCE(idValue)->GetValueConst(&id);

            PR_LOG(gXULTemplateLog, PR_LOG_DEBUG,
                   ("nsTreeRowTestNode[%p]: FilterInstantiations() id=[%s]",
                    this, id));
        }
#endif

        if (hasIdBinding) {
            nsIRDFResource* container = VALUE_TO_IRDFRESOURCE(idValue);

            // Is the row in the tree?
            if ((container == mRows.GetRootResource()) ||
                (mRows.Find(mConflictSet, container) != mRows.Last())) {

                PR_LOG(gXULTemplateLog, PR_LOG_DEBUG, ("    => passed"));
                Element* element =
                    nsTreeRowTestNode::Element::Create(mConflictSet.GetPool(), container);

                if (! element)
                    return NS_ERROR_OUT_OF_MEMORY;

                inst->AddSupportingElement(element);

                continue;
            }
        }

        PR_LOG(gXULTemplateLog, PR_LOG_DEBUG, ("    => failed"));
        aInstantiations.Erase(inst--);
    }

    return NS_OK;
}

Here is the call graph for this function:

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.

Reimplemented from TestNode.

Definition at line 113 of file nsTreeRowTestNode.cpp.

{
    aVariables.Add(mIdVariable);
    return TestNode::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:


Member Data Documentation

Definition at line 110 of file nsTreeRowTestNode.h.

Definition at line 112 of file nsTreeRowTestNode.h.

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.

Definition at line 111 of file nsTreeRowTestNode.h.


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