michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsRDFConMemberTestNode_h__ michael@0: #define nsRDFConMemberTestNode_h__ michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "nscore.h" michael@0: #include "nsRDFTestNode.h" michael@0: #include "nsIRDFDataSource.h" michael@0: #include "nsXULTemplateQueryProcessorRDF.h" michael@0: michael@0: /** michael@0: * Rule network node that test if a resource is a member of an RDF michael@0: * container, or is ``contained'' by another resource that refers to michael@0: * it using a ``containment'' attribute. michael@0: */ michael@0: class nsRDFConMemberTestNode : public nsRDFTestNode michael@0: { michael@0: public: michael@0: nsRDFConMemberTestNode(TestNode* aParent, michael@0: nsXULTemplateQueryProcessorRDF* aProcessor, michael@0: nsIAtom* aContainerVariable, michael@0: nsIAtom* aMemberVariable); michael@0: michael@0: virtual nsresult FilterInstantiations(InstantiationSet& aInstantiations, michael@0: bool* aCantHandleYet) const MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: CanPropagate(nsIRDFResource* aSource, michael@0: nsIRDFResource* aProperty, michael@0: nsIRDFNode* aTarget, michael@0: Instantiation& aInitialBindings) const MOZ_OVERRIDE; michael@0: michael@0: virtual void michael@0: Retract(nsIRDFResource* aSource, michael@0: nsIRDFResource* aProperty, michael@0: nsIRDFNode* aTarget) const MOZ_OVERRIDE; michael@0: michael@0: class Element : public MemoryElement { michael@0: public: michael@0: Element(nsIRDFResource* aContainer, michael@0: nsIRDFNode* aMember) michael@0: : mContainer(aContainer), michael@0: mMember(aMember) { michael@0: MOZ_COUNT_CTOR(nsRDFConMemberTestNode::Element); } michael@0: michael@0: virtual ~Element() { MOZ_COUNT_DTOR(nsRDFConMemberTestNode::Element); } michael@0: michael@0: virtual const char* Type() const MOZ_OVERRIDE { michael@0: return "nsRDFConMemberTestNode::Element"; } michael@0: michael@0: virtual PLHashNumber Hash() const MOZ_OVERRIDE { michael@0: return PLHashNumber(NS_PTR_TO_INT32(mContainer.get())) ^ michael@0: (PLHashNumber(NS_PTR_TO_INT32(mMember.get())) >> 12); } michael@0: michael@0: virtual bool Equals(const MemoryElement& aElement) const MOZ_OVERRIDE { michael@0: if (aElement.Type() == Type()) { michael@0: const Element& element = static_cast(aElement); michael@0: return mContainer == element.mContainer && mMember == element.mMember; michael@0: } michael@0: return false; } michael@0: michael@0: protected: michael@0: nsCOMPtr mContainer; michael@0: nsCOMPtr mMember; michael@0: }; michael@0: michael@0: protected: michael@0: nsXULTemplateQueryProcessorRDF* mProcessor; michael@0: nsCOMPtr mContainerVariable; michael@0: nsCOMPtr mMemberVariable; michael@0: }; michael@0: michael@0: #endif // nsRDFConMemberTestNode_h__