content/xul/templates/src/nsXULTemplateResultRDF.h

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

mercurial