Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /* This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : #ifndef nsRDFConMemberTestNode_h__
7 : #define nsRDFConMemberTestNode_h__
8 :
9 : #include "mozilla/Attributes.h"
10 : #include "nscore.h"
11 : #include "nsRDFTestNode.h"
12 : #include "nsIRDFDataSource.h"
13 : #include "nsXULTemplateQueryProcessorRDF.h"
14 :
15 : /**
16 : * Rule network node that test if a resource is a member of an RDF
17 : * container, or is ``contained'' by another resource that refers to
18 : * it using a ``containment'' attribute.
19 : */
20 0 : class nsRDFConMemberTestNode : public nsRDFTestNode
21 : {
22 : public:
23 : nsRDFConMemberTestNode(TestNode* aParent,
24 : nsXULTemplateQueryProcessorRDF* aProcessor,
25 : nsIAtom* aContainerVariable,
26 : nsIAtom* aMemberVariable);
27 :
28 : virtual nsresult FilterInstantiations(InstantiationSet& aInstantiations,
29 : bool* aCantHandleYet) const override;
30 :
31 : virtual bool
32 : CanPropagate(nsIRDFResource* aSource,
33 : nsIRDFResource* aProperty,
34 : nsIRDFNode* aTarget,
35 : Instantiation& aInitialBindings) const override;
36 :
37 : virtual void
38 : Retract(nsIRDFResource* aSource,
39 : nsIRDFResource* aProperty,
40 : nsIRDFNode* aTarget) const override;
41 :
42 : class Element : public MemoryElement {
43 : public:
44 0 : Element(nsIRDFResource* aContainer,
45 : nsIRDFNode* aMember)
46 0 : : mContainer(aContainer),
47 0 : mMember(aMember) {
48 0 : MOZ_COUNT_CTOR(nsRDFConMemberTestNode::Element); }
49 :
50 0 : virtual ~Element() { MOZ_COUNT_DTOR(nsRDFConMemberTestNode::Element); }
51 :
52 0 : virtual const char* Type() const override {
53 0 : return "nsRDFConMemberTestNode::Element"; }
54 :
55 0 : virtual PLHashNumber Hash() const override {
56 0 : return PLHashNumber(NS_PTR_TO_INT32(mContainer.get())) ^
57 0 : (PLHashNumber(NS_PTR_TO_INT32(mMember.get())) >> 12); }
58 :
59 0 : virtual bool Equals(const MemoryElement& aElement) const override {
60 0 : if (aElement.Type() == Type()) {
61 0 : const Element& element = static_cast<const Element&>(aElement);
62 0 : return mContainer == element.mContainer && mMember == element.mMember;
63 : }
64 0 : return false; }
65 :
66 : protected:
67 : nsCOMPtr<nsIRDFResource> mContainer;
68 : nsCOMPtr<nsIRDFNode> mMember;
69 : };
70 :
71 : protected:
72 : nsXULTemplateQueryProcessorRDF* mProcessor;
73 : nsCOMPtr<nsIAtom> mContainerVariable;
74 : nsCOMPtr<nsIAtom> mMemberVariable;
75 : };
76 :
77 : #endif // nsRDFConMemberTestNode_h__
|