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 nsRDFPropertyTestNode_h__ michael@0: #define nsRDFPropertyTestNode_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 "nsIRDFResource.h" michael@0: #include "nsXULTemplateQueryProcessorRDF.h" michael@0: michael@0: class nsRDFPropertyTestNode : public nsRDFTestNode michael@0: { michael@0: public: michael@0: /** michael@0: * Both source and target unbound (?source ^property ?target) michael@0: */ michael@0: nsRDFPropertyTestNode(TestNode* aParent, michael@0: nsXULTemplateQueryProcessorRDF* aProcessor, michael@0: nsIAtom* aSourceVariable, michael@0: nsIRDFResource* aProperty, michael@0: nsIAtom* aTargetVariable); michael@0: michael@0: /** michael@0: * Source bound, target unbound (source ^property ?target) michael@0: */ michael@0: nsRDFPropertyTestNode(TestNode* aParent, michael@0: nsXULTemplateQueryProcessorRDF* aProcessor, michael@0: nsIRDFResource* aSource, michael@0: nsIRDFResource* aProperty, michael@0: nsIAtom* aTargetVariable); michael@0: michael@0: /** michael@0: * Source unbound, target bound (?source ^property target) michael@0: */ michael@0: nsRDFPropertyTestNode(TestNode* aParent, michael@0: nsXULTemplateQueryProcessorRDF* aProcessor, michael@0: nsIAtom* aSourceVariable, michael@0: nsIRDFResource* aProperty, michael@0: nsIRDFNode* aTarget); 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: michael@0: class Element : public MemoryElement { michael@0: public: michael@0: Element(nsIRDFResource* aSource, michael@0: nsIRDFResource* aProperty, michael@0: nsIRDFNode* aTarget) michael@0: : mSource(aSource), michael@0: mProperty(aProperty), michael@0: mTarget(aTarget) { michael@0: MOZ_COUNT_CTOR(nsRDFPropertyTestNode::Element); } michael@0: michael@0: virtual ~Element() { MOZ_COUNT_DTOR(nsRDFPropertyTestNode::Element); } michael@0: michael@0: virtual const char* Type() const MOZ_OVERRIDE { michael@0: return "nsRDFPropertyTestNode::Element"; } michael@0: michael@0: virtual PLHashNumber Hash() const MOZ_OVERRIDE { michael@0: return mozilla::HashGeneric(mSource.get(), mProperty.get(), mTarget.get()); michael@0: } 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 mSource == element.mSource michael@0: && mProperty == element.mProperty michael@0: && mTarget == element.mTarget; michael@0: } michael@0: return false; } michael@0: michael@0: protected: michael@0: nsCOMPtr mSource; michael@0: nsCOMPtr mProperty; michael@0: nsCOMPtr mTarget; michael@0: }; michael@0: michael@0: protected: michael@0: nsXULTemplateQueryProcessorRDF* mProcessor; michael@0: nsCOMPtr mSourceVariable; michael@0: nsCOMPtr mSource; michael@0: nsCOMPtr mProperty; michael@0: nsCOMPtr mTargetVariable; michael@0: nsCOMPtr mTarget; michael@0: }; michael@0: michael@0: #endif // nsRDFPropertyTestNode_h__