|
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 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 MOZ_OVERRIDE; |
|
30 |
|
31 virtual bool |
|
32 CanPropagate(nsIRDFResource* aSource, |
|
33 nsIRDFResource* aProperty, |
|
34 nsIRDFNode* aTarget, |
|
35 Instantiation& aInitialBindings) const MOZ_OVERRIDE; |
|
36 |
|
37 virtual void |
|
38 Retract(nsIRDFResource* aSource, |
|
39 nsIRDFResource* aProperty, |
|
40 nsIRDFNode* aTarget) const MOZ_OVERRIDE; |
|
41 |
|
42 class Element : public MemoryElement { |
|
43 public: |
|
44 Element(nsIRDFResource* aContainer, |
|
45 nsIRDFNode* aMember) |
|
46 : mContainer(aContainer), |
|
47 mMember(aMember) { |
|
48 MOZ_COUNT_CTOR(nsRDFConMemberTestNode::Element); } |
|
49 |
|
50 virtual ~Element() { MOZ_COUNT_DTOR(nsRDFConMemberTestNode::Element); } |
|
51 |
|
52 virtual const char* Type() const MOZ_OVERRIDE { |
|
53 return "nsRDFConMemberTestNode::Element"; } |
|
54 |
|
55 virtual PLHashNumber Hash() const MOZ_OVERRIDE { |
|
56 return PLHashNumber(NS_PTR_TO_INT32(mContainer.get())) ^ |
|
57 (PLHashNumber(NS_PTR_TO_INT32(mMember.get())) >> 12); } |
|
58 |
|
59 virtual bool Equals(const MemoryElement& aElement) const MOZ_OVERRIDE { |
|
60 if (aElement.Type() == Type()) { |
|
61 const Element& element = static_cast<const Element&>(aElement); |
|
62 return mContainer == element.mContainer && mMember == element.mMember; |
|
63 } |
|
64 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__ |