content/xul/templates/src/nsRDFPropertyTestNode.h

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:ea318dcfd1ba
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 nsRDFPropertyTestNode_h__
7 #define nsRDFPropertyTestNode_h__
8
9 #include "mozilla/Attributes.h"
10 #include "nscore.h"
11 #include "nsRDFTestNode.h"
12 #include "nsIRDFDataSource.h"
13 #include "nsIRDFResource.h"
14 #include "nsXULTemplateQueryProcessorRDF.h"
15
16 class nsRDFPropertyTestNode : public nsRDFTestNode
17 {
18 public:
19 /**
20 * Both source and target unbound (?source ^property ?target)
21 */
22 nsRDFPropertyTestNode(TestNode* aParent,
23 nsXULTemplateQueryProcessorRDF* aProcessor,
24 nsIAtom* aSourceVariable,
25 nsIRDFResource* aProperty,
26 nsIAtom* aTargetVariable);
27
28 /**
29 * Source bound, target unbound (source ^property ?target)
30 */
31 nsRDFPropertyTestNode(TestNode* aParent,
32 nsXULTemplateQueryProcessorRDF* aProcessor,
33 nsIRDFResource* aSource,
34 nsIRDFResource* aProperty,
35 nsIAtom* aTargetVariable);
36
37 /**
38 * Source unbound, target bound (?source ^property target)
39 */
40 nsRDFPropertyTestNode(TestNode* aParent,
41 nsXULTemplateQueryProcessorRDF* aProcessor,
42 nsIAtom* aSourceVariable,
43 nsIRDFResource* aProperty,
44 nsIRDFNode* aTarget);
45
46 virtual nsresult FilterInstantiations(InstantiationSet& aInstantiations,
47 bool* aCantHandleYet) const MOZ_OVERRIDE;
48
49 virtual bool
50 CanPropagate(nsIRDFResource* aSource,
51 nsIRDFResource* aProperty,
52 nsIRDFNode* aTarget,
53 Instantiation& aInitialBindings) const MOZ_OVERRIDE;
54
55 virtual void
56 Retract(nsIRDFResource* aSource,
57 nsIRDFResource* aProperty,
58 nsIRDFNode* aTarget) const MOZ_OVERRIDE;
59
60
61 class Element : public MemoryElement {
62 public:
63 Element(nsIRDFResource* aSource,
64 nsIRDFResource* aProperty,
65 nsIRDFNode* aTarget)
66 : mSource(aSource),
67 mProperty(aProperty),
68 mTarget(aTarget) {
69 MOZ_COUNT_CTOR(nsRDFPropertyTestNode::Element); }
70
71 virtual ~Element() { MOZ_COUNT_DTOR(nsRDFPropertyTestNode::Element); }
72
73 virtual const char* Type() const MOZ_OVERRIDE {
74 return "nsRDFPropertyTestNode::Element"; }
75
76 virtual PLHashNumber Hash() const MOZ_OVERRIDE {
77 return mozilla::HashGeneric(mSource.get(), mProperty.get(), mTarget.get());
78 }
79
80 virtual bool Equals(const MemoryElement& aElement) const MOZ_OVERRIDE {
81 if (aElement.Type() == Type()) {
82 const Element& element = static_cast<const Element&>(aElement);
83 return mSource == element.mSource
84 && mProperty == element.mProperty
85 && mTarget == element.mTarget;
86 }
87 return false; }
88
89 protected:
90 nsCOMPtr<nsIRDFResource> mSource;
91 nsCOMPtr<nsIRDFResource> mProperty;
92 nsCOMPtr<nsIRDFNode> mTarget;
93 };
94
95 protected:
96 nsXULTemplateQueryProcessorRDF* mProcessor;
97 nsCOMPtr<nsIAtom> mSourceVariable;
98 nsCOMPtr<nsIRDFResource> mSource;
99 nsCOMPtr<nsIRDFResource> mProperty;
100 nsCOMPtr<nsIAtom> mTargetVariable;
101 nsCOMPtr<nsIRDFNode> mTarget;
102 };
103
104 #endif // nsRDFPropertyTestNode_h__

mercurial