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