Back to index

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

A leaf-level node in the rule network. More...

#include <nsInstantiationNode.h>

Inheritance diagram for nsInstantiationNode:
Inheritance graph
Collaboration diagram for nsInstantiationNode:
Collaboration graph

List of all members.

Public Member Functions

 nsInstantiationNode (nsConflictSet &aConflictSet, nsTemplateRule *aRule, nsIRDFDataSource *aDataSource)
 ~nsInstantiationNode ()
virtual nsresult Propagate (const InstantiationSet &aInstantiations, void *aClosure)
 Propagate a set of instantiations "down" through the network.

Protected Attributes

 The rule that the node instantiates.

Detailed Description

A leaf-level node in the rule network.

If any instantiations propagate to this node, then we know we've matched a rule.

Definition at line 51 of file nsInstantiationNode.h.

Constructor & Destructor Documentation

nsInstantiationNode::nsInstantiationNode ( nsConflictSet aConflictSet,
nsTemplateRule aRule,
nsIRDFDataSource aDataSource 

Definition at line 49 of file nsInstantiationNode.cpp.

        : mConflictSet(aConflictSet),
    PR_LOG(gXULTemplateLog, PR_LOG_DEBUG,
           ("nsInstantiationNode[%p] rule=%p", this, aRule));

Definition at line 62 of file nsInstantiationNode.cpp.

    delete mRule;

Member Function Documentation

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

Propagate a set of instantiations "down" through the network.

Each instantiation is a partial set of variable-to-value assignments, along with the memory elements that support it.

The node must evaluate each instantiation, and either 1) extend it with additional assignments and memory-element support, or 2) remove it from the set because it is inconsistent with the constraints that this node applies.

The node must then pass the resulting instantiation set along to any of its children in the network. (In other words, the node must recursively call Propagate() on its children. We should fix this to make the algorithm interruptable.)

aInstantiationsthe set of instantiations to propagate down through the network.
aClosureany application-specific information that needs to be passed through the network.
NS_OK if no errors occurred.

Implements ReteNode.

Definition at line 68 of file nsInstantiationNode.cpp.

    // If we get here, we've matched the rule associated with this
    // node. Extend it with any <bindings> that we might have, add it
    // to the conflict set, and the set of new <content, member>
    // pairs.
    nsClusterKeySet* newkeys = NS_STATIC_CAST(nsClusterKeySet*, aClosure);

    InstantiationSet::ConstIterator last = aInstantiations.Last();
    for (InstantiationSet::ConstIterator inst = aInstantiations.First(); inst != last; ++inst) {
        nsAssignmentSet assignments = inst->mAssignments;

        nsTemplateMatch* match =
            nsTemplateMatch::Create(mConflictSet.GetPool(), mRule, *inst, assignments);

        if (! match)
            return NS_ERROR_OUT_OF_MEMORY;

        // Temporarily AddRef() to keep the match alive.

        mRule->InitBindings(mConflictSet, match);


        // Give back our "local" reference. The conflict set will have
        // taken what it needs.

        newkeys->Add(nsClusterKey(*inst, mRule));
    return NS_OK;

Here is the call graph for this function:

Member Data Documentation

Definition at line 64 of file nsInstantiationNode.h.

The rule that the node instantiates.

The instantiation node assumes ownership of the rule in its ctor, and will destroy the rule in its dtor.

Definition at line 71 of file nsInstantiationNode.h.

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