Back to index

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

A match "cluster" is a group of matches that all share the same values for their "container" (or parent) and "member" (or child) variables. More...

#include <nsClusterKey.h>

Collaboration diagram for nsClusterKey:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsClusterKey ()
 nsClusterKey (const Instantiation &aInstantiation, const nsTemplateRule *aRule)
 Construct a nsClusterKey from an instantiation and a rule.
 nsClusterKey (PRInt32 aContainerVariable, const Value &aContainerValue, PRInt32 aMemberVariable, const Value &aMemberValue)
 nsClusterKey (const nsClusterKey &aKey)
 ~nsClusterKey ()
nsClusterKeyoperator= (const nsClusterKey &aKey)
PRBool operator== (const nsClusterKey &aKey) const
PRBool operator!= (const nsClusterKey &aKey) const
PLHashNumber Hash () const

Static Public Member Functions

static PLHashNumber PR_CALLBACK HashClusterKey (const void *aKey)
static PRIntn PR_CALLBACK CompareClusterKeys (const void *aLeft, const void *aRight)

Public Attributes

PRInt32 mContainerVariable
Value mContainerValue
PRInt32 mMemberVariable
Value mMemberValue

Protected Member Functions

PRBool Equals (const nsClusterKey &aKey) const

Detailed Description

A match "cluster" is a group of matches that all share the same values for their "container" (or parent) and "member" (or child) variables.

Only one match in a cluster can be "active": the active match is the match that is used to generate content for the content model. The matches in a cluster "compete" amongst each other; specifically, the match that corresponds to the rule that is declared first wins, and becomes active.

The nsClusterKey is a hashtable key into the set of matches that are currently competing: it consists of the container variable, its value, the member variable, and its value.

Definition at line 62 of file nsClusterKey.h.


Constructor & Destructor Documentation

Definition at line 64 of file nsClusterKey.h.

nsClusterKey::nsClusterKey ( const Instantiation aInstantiation,
const nsTemplateRule aRule 
)

Construct a nsClusterKey from an instantiation and a rule.

This will use the rule to identify the container and member variables, and then pull out their assignments from the instantiation.

Parameters:
aInstantiationthe instantiation to use to determine variable values
aRulethe rule to use to determine the member and container variables.

Definition at line 42 of file nsClusterKey.cpp.

{
    PRBool hasassignment;

    mContainerVariable = aRule->GetContainerVariable();
    hasassignment = aInstantiation.mAssignments.GetAssignmentFor(mContainerVariable, &mContainerValue);
    NS_ASSERTION(hasassignment, "no assignment for container variable");

    mMemberVariable = aRule->GetMemberVariable();
    hasassignment = aInstantiation.mAssignments.GetAssignmentFor(mMemberVariable, &mMemberValue);
    NS_ASSERTION(hasassignment, "no assignment for member variable");

    MOZ_COUNT_CTOR(nsClusterKey);
}

Here is the call graph for this function:

nsClusterKey::nsClusterKey ( PRInt32  aContainerVariable,
const Value aContainerValue,
PRInt32  aMemberVariable,
const Value aMemberValue 
) [inline]

Definition at line 77 of file nsClusterKey.h.

        : mContainerVariable(aContainerVariable),
          mContainerValue(aContainerValue),
          mMemberVariable(aMemberVariable),
          mMemberValue(aMemberValue) {
        MOZ_COUNT_CTOR(nsClusterKey); }

Definition at line 94 of file nsClusterKey.h.


Member Function Documentation

PRIntn PR_CALLBACK nsClusterKey::CompareClusterKeys ( const void aLeft,
const void aRight 
) [static]

Definition at line 66 of file nsClusterKey.cpp.

{
    const nsClusterKey* left  = NS_STATIC_CAST(const nsClusterKey*, aLeft);
    const nsClusterKey* right = NS_STATIC_CAST(const nsClusterKey*, aRight);
    return *left == *right;
}

Here is the caller graph for this function:

PRBool nsClusterKey::Equals ( const nsClusterKey aKey) const [inline, protected]

Definition at line 129 of file nsClusterKey.h.

Here is the caller graph for this function:

PLHashNumber nsClusterKey::Hash ( ) const [inline]

Definition at line 114 of file nsClusterKey.h.

                              {
        PLHashNumber temp1;
        temp1 = mContainerValue.Hash();
        temp1 &= 0xffff;
        temp1 |= PLHashNumber(mContainerVariable) << 16;
        PLHashNumber temp2;
        temp2 = mMemberValue.Hash();
        temp2 &= 0xffff;
        temp2 |= PLHashNumber(mMemberVariable) << 16;
        return temp1 ^ temp2; }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 59 of file nsClusterKey.cpp.

{
    const nsClusterKey* key = NS_STATIC_CAST(const nsClusterKey*, aKey);
    return key->Hash();
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsClusterKey::operator!= ( const nsClusterKey aKey) const [inline]

Definition at line 106 of file nsClusterKey.h.

                                                      {
        return !Equals(aKey); }

Here is the call graph for this function:

nsClusterKey& nsClusterKey::operator= ( const nsClusterKey aKey) [inline]
PRBool nsClusterKey::operator== ( const nsClusterKey aKey) const [inline]

Definition at line 103 of file nsClusterKey.h.

                                                      {
        return Equals(aKey); }

Here is the call graph for this function:


Member Data Documentation

Definition at line 110 of file nsClusterKey.h.

Definition at line 109 of file nsClusterKey.h.

Definition at line 112 of file nsClusterKey.h.

Definition at line 111 of file nsClusterKey.h.


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