nsXULTemplateResultRDF.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 nsXULTemplateResultRDF_h__
  6. #define nsXULTemplateResultRDF_h__
  7. #include "nsCOMPtr.h"
  8. #include "nsIRDFResource.h"
  9. #include "nsXULTemplateQueryProcessorRDF.h"
  10. #include "nsRDFQuery.h"
  11. #include "nsRuleNetwork.h"
  12. #include "nsIXULTemplateResult.h"
  13. #include "nsRDFBinding.h"
  14. #include "mozilla/Attributes.h"
  15. /**
  16. * A single result of a query on an RDF graph
  17. */
  18. class nsXULTemplateResultRDF final : public nsIXULTemplateResult
  19. {
  20. public:
  21. NS_DECL_CYCLE_COLLECTING_ISUPPORTS
  22. NS_DECL_CYCLE_COLLECTION_CLASS(nsXULTemplateResultRDF)
  23. NS_DECL_NSIXULTEMPLATERESULT
  24. explicit nsXULTemplateResultRDF(nsIRDFResource* aNode);
  25. nsXULTemplateResultRDF(nsRDFQuery* aQuery,
  26. const Instantiation& aInst,
  27. nsIRDFResource* aNode);
  28. nsITemplateRDFQuery* Query() { return mQuery; }
  29. nsXULTemplateQueryProcessorRDF* GetProcessor()
  30. {
  31. return (mQuery ? mQuery->Processor() : nullptr);
  32. }
  33. /**
  34. * Get the value of a variable, first by looking in the assignments and
  35. * then the bindings
  36. */
  37. void
  38. GetAssignment(nsIAtom* aVar, nsIRDFNode** aValue);
  39. /**
  40. * Synchronize the bindings after a change in the RDF graph. Bindings that
  41. * would be affected will be assigned appropriately based on the change.
  42. */
  43. bool
  44. SyncAssignments(nsIRDFResource* aSubject,
  45. nsIRDFResource* aPredicate,
  46. nsIRDFNode* aTarget);
  47. /**
  48. * Return true if the result has an instantiation involving a particular
  49. * memory element.
  50. */
  51. bool
  52. HasMemoryElement(const MemoryElement& aMemoryElement);
  53. protected:
  54. ~nsXULTemplateResultRDF();
  55. // query that generated the result
  56. nsCOMPtr<nsITemplateRDFQuery> mQuery;
  57. // resource node
  58. nsCOMPtr<nsIRDFResource> mNode;
  59. // data computed from query
  60. Instantiation mInst;
  61. // extra assignments made by rules (<binding> tags)
  62. nsBindingValues mBindingValues;
  63. };
  64. #endif // nsXULTemplateResultRDF_h__