1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/xul/templates/src/nsRDFConMemberTestNode.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,77 @@ 1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef nsRDFConMemberTestNode_h__ 1.10 +#define nsRDFConMemberTestNode_h__ 1.11 + 1.12 +#include "mozilla/Attributes.h" 1.13 +#include "nscore.h" 1.14 +#include "nsRDFTestNode.h" 1.15 +#include "nsIRDFDataSource.h" 1.16 +#include "nsXULTemplateQueryProcessorRDF.h" 1.17 + 1.18 +/** 1.19 + * Rule network node that test if a resource is a member of an RDF 1.20 + * container, or is ``contained'' by another resource that refers to 1.21 + * it using a ``containment'' attribute. 1.22 + */ 1.23 +class nsRDFConMemberTestNode : public nsRDFTestNode 1.24 +{ 1.25 +public: 1.26 + nsRDFConMemberTestNode(TestNode* aParent, 1.27 + nsXULTemplateQueryProcessorRDF* aProcessor, 1.28 + nsIAtom* aContainerVariable, 1.29 + nsIAtom* aMemberVariable); 1.30 + 1.31 + virtual nsresult FilterInstantiations(InstantiationSet& aInstantiations, 1.32 + bool* aCantHandleYet) const MOZ_OVERRIDE; 1.33 + 1.34 + virtual bool 1.35 + CanPropagate(nsIRDFResource* aSource, 1.36 + nsIRDFResource* aProperty, 1.37 + nsIRDFNode* aTarget, 1.38 + Instantiation& aInitialBindings) const MOZ_OVERRIDE; 1.39 + 1.40 + virtual void 1.41 + Retract(nsIRDFResource* aSource, 1.42 + nsIRDFResource* aProperty, 1.43 + nsIRDFNode* aTarget) const MOZ_OVERRIDE; 1.44 + 1.45 + class Element : public MemoryElement { 1.46 + public: 1.47 + Element(nsIRDFResource* aContainer, 1.48 + nsIRDFNode* aMember) 1.49 + : mContainer(aContainer), 1.50 + mMember(aMember) { 1.51 + MOZ_COUNT_CTOR(nsRDFConMemberTestNode::Element); } 1.52 + 1.53 + virtual ~Element() { MOZ_COUNT_DTOR(nsRDFConMemberTestNode::Element); } 1.54 + 1.55 + virtual const char* Type() const MOZ_OVERRIDE { 1.56 + return "nsRDFConMemberTestNode::Element"; } 1.57 + 1.58 + virtual PLHashNumber Hash() const MOZ_OVERRIDE { 1.59 + return PLHashNumber(NS_PTR_TO_INT32(mContainer.get())) ^ 1.60 + (PLHashNumber(NS_PTR_TO_INT32(mMember.get())) >> 12); } 1.61 + 1.62 + virtual bool Equals(const MemoryElement& aElement) const MOZ_OVERRIDE { 1.63 + if (aElement.Type() == Type()) { 1.64 + const Element& element = static_cast<const Element&>(aElement); 1.65 + return mContainer == element.mContainer && mMember == element.mMember; 1.66 + } 1.67 + return false; } 1.68 + 1.69 + protected: 1.70 + nsCOMPtr<nsIRDFResource> mContainer; 1.71 + nsCOMPtr<nsIRDFNode> mMember; 1.72 + }; 1.73 + 1.74 +protected: 1.75 + nsXULTemplateQueryProcessorRDF* mProcessor; 1.76 + nsCOMPtr<nsIAtom> mContainerVariable; 1.77 + nsCOMPtr<nsIAtom> mMemberVariable; 1.78 +}; 1.79 + 1.80 +#endif // nsRDFConMemberTestNode_h__