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 nsRDFConInstanceTestNode_h__
7 : #define nsRDFConInstanceTestNode_h__
8 :
9 : #include "mozilla/Attributes.h"
10 : #include "nscore.h"
11 : #include "nsRDFTestNode.h"
12 : #include "nsIRDFResource.h"
13 : #include "nsIRDFDataSource.h"
14 : #include "nsXULTemplateQueryProcessorRDF.h"
15 :
16 : /**
17 : * Rule network node that tests if a resource is an RDF container, or
18 : * uses multi-attributes to ``contain'' other elements.
19 : */
20 0 : class nsRDFConInstanceTestNode : public nsRDFTestNode
21 : {
22 : public:
23 : enum Test { eFalse, eTrue, eDontCare };
24 :
25 : nsRDFConInstanceTestNode(TestNode* aParent,
26 : nsXULTemplateQueryProcessorRDF* aProcessor,
27 : nsIAtom* aContainerVariable,
28 : Test aContainer,
29 : Test aEmpty);
30 :
31 : virtual nsresult FilterInstantiations(InstantiationSet& aInstantiations,
32 : bool* aCantHandleYet) const override;
33 :
34 : virtual bool
35 : CanPropagate(nsIRDFResource* aSource,
36 : nsIRDFResource* aProperty,
37 : nsIRDFNode* aTarget,
38 : Instantiation& aInitialBindings) const override;
39 :
40 : virtual void
41 : Retract(nsIRDFResource* aSource,
42 : nsIRDFResource* aProperty,
43 : nsIRDFNode* aTarget) const override;
44 :
45 :
46 : class Element : public MemoryElement {
47 : public:
48 0 : Element(nsIRDFResource* aContainer,
49 : Test aContainerTest,
50 : Test aEmptyTest)
51 0 : : mContainer(aContainer),
52 : mContainerTest(aContainerTest),
53 0 : mEmptyTest(aEmptyTest) {
54 0 : MOZ_COUNT_CTOR(nsRDFConInstanceTestNode::Element); }
55 :
56 0 : virtual ~Element() { MOZ_COUNT_DTOR(nsRDFConInstanceTestNode::Element); }
57 :
58 0 : virtual const char* Type() const override {
59 0 : return "nsRDFConInstanceTestNode::Element"; }
60 :
61 0 : virtual PLHashNumber Hash() const override {
62 0 : return mozilla::HashGeneric(mContainerTest, mEmptyTest, mContainer.get());
63 : }
64 :
65 0 : virtual bool Equals(const MemoryElement& aElement) const override {
66 0 : if (aElement.Type() == Type()) {
67 0 : const Element& element = static_cast<const Element&>(aElement);
68 0 : return mContainer == element.mContainer
69 0 : && mContainerTest == element.mContainerTest
70 0 : && mEmptyTest == element.mEmptyTest;
71 : }
72 0 : return false; }
73 :
74 : protected:
75 : nsCOMPtr<nsIRDFResource> mContainer;
76 : Test mContainerTest;
77 : Test mEmptyTest;
78 : };
79 :
80 : protected:
81 : nsXULTemplateQueryProcessorRDF* mProcessor;
82 : nsCOMPtr<nsIAtom> mContainerVariable;
83 : Test mContainer;
84 : Test mEmpty;
85 : };
86 :
87 : #endif // nsRDFConInstanceTestNode_h__
88 :
|