1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/xul/templates/src/nsXULTemplateResultRDF.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,82 @@ 1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef nsXULTemplateResultRDF_h__ 1.10 +#define nsXULTemplateResultRDF_h__ 1.11 + 1.12 +#include "nsCOMPtr.h" 1.13 +#include "nsIRDFResource.h" 1.14 +#include "nsXULTemplateQueryProcessorRDF.h" 1.15 +#include "nsRDFQuery.h" 1.16 +#include "nsRuleNetwork.h" 1.17 +#include "nsIXULTemplateResult.h" 1.18 +#include "nsRDFBinding.h" 1.19 +#include "mozilla/Attributes.h" 1.20 + 1.21 +/** 1.22 + * A single result of a query on an RDF graph 1.23 + */ 1.24 +class nsXULTemplateResultRDF MOZ_FINAL : public nsIXULTemplateResult 1.25 +{ 1.26 +public: 1.27 + NS_DECL_CYCLE_COLLECTING_ISUPPORTS 1.28 + NS_DECL_CYCLE_COLLECTION_CLASS(nsXULTemplateResultRDF) 1.29 + 1.30 + NS_DECL_NSIXULTEMPLATERESULT 1.31 + 1.32 + nsXULTemplateResultRDF(nsIRDFResource* aNode); 1.33 + 1.34 + nsXULTemplateResultRDF(nsRDFQuery* aQuery, 1.35 + const Instantiation& aInst, 1.36 + nsIRDFResource* aNode); 1.37 + 1.38 + ~nsXULTemplateResultRDF(); 1.39 + 1.40 + nsITemplateRDFQuery* Query() { return mQuery; } 1.41 + 1.42 + nsXULTemplateQueryProcessorRDF* GetProcessor() 1.43 + { 1.44 + return (mQuery ? mQuery->Processor() : nullptr); 1.45 + } 1.46 + 1.47 + /** 1.48 + * Get the value of a variable, first by looking in the assignments and 1.49 + * then the bindings 1.50 + */ 1.51 + void 1.52 + GetAssignment(nsIAtom* aVar, nsIRDFNode** aValue); 1.53 + 1.54 + /** 1.55 + * Synchronize the bindings after a change in the RDF graph. Bindings that 1.56 + * would be affected will be assigned appropriately based on the change. 1.57 + */ 1.58 + bool 1.59 + SyncAssignments(nsIRDFResource* aSubject, 1.60 + nsIRDFResource* aPredicate, 1.61 + nsIRDFNode* aTarget); 1.62 + 1.63 + /** 1.64 + * Return true if the result has an instantiation involving a particular 1.65 + * memory element. 1.66 + */ 1.67 + bool 1.68 + HasMemoryElement(const MemoryElement& aMemoryElement); 1.69 + 1.70 +protected: 1.71 + 1.72 + // query that generated the result 1.73 + nsCOMPtr<nsITemplateRDFQuery> mQuery; 1.74 + 1.75 + // resource node 1.76 + nsCOMPtr<nsIRDFResource> mNode; 1.77 + 1.78 + // data computed from query 1.79 + Instantiation mInst; 1.80 + 1.81 + // extra assignments made by rules (<binding> tags) 1.82 + nsBindingValues mBindingValues; 1.83 +}; 1.84 + 1.85 +#endif // nsXULTemplateResultRDF_h__