nsRDFPropertyTestNode.h 3.6 KB

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