LCOV - code coverage report
Current view: top level - dom/xul/templates - nsRDFQuery.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 23 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 19 0.0 %
Legend: Lines: hit not hit

          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 nsRDFQuery_h__
       7             : #define nsRDFQuery_h__
       8             : 
       9             : #include "nsISimpleEnumerator.h"
      10             : #include "nsCycleCollectionParticipant.h"
      11             : #include "mozilla/Attributes.h"
      12             : 
      13             : #define NS_ITEMPLATERDFQUERY_IID \
      14             :   {0x8929ff60, 0x1c9c, 0x4d87, \
      15             :     { 0xac, 0x02, 0x09, 0x14, 0x15, 0x3b, 0x48, 0xc4 }}
      16             : 
      17             : class nsXULTemplateQueryProcessorRDF;
      18             : 
      19             : /**
      20             :  * A compiled query in the RDF query processor. This interface should not be
      21             :  * used directly outside of the RDF query processor.
      22             :  */
      23           0 : class nsITemplateRDFQuery : public nsISupports
      24             : {
      25             : public:
      26             :     NS_DECLARE_STATIC_IID_ACCESSOR(NS_ITEMPLATERDFQUERY_IID)
      27             : 
      28             :     // return the processor the query was created from
      29             :     virtual nsXULTemplateQueryProcessorRDF* Processor() = 0;  // not addrefed
      30             : 
      31             :     // return the member variable for the query
      32             :     virtual nsIAtom* GetMemberVariable() = 0; // not addrefed
      33             : 
      34             :     // return the <query> node the query was compiled from
      35             :     virtual void GetQueryNode(nsIDOMNode** aQueryNode) = 0;
      36             : 
      37             :     // remove any results that are cached by the query
      38             :     virtual void ClearCachedResults() = 0;
      39             : };
      40             : 
      41             : class nsRDFQuery final : public nsITemplateRDFQuery
      42             : {
      43           0 :     ~nsRDFQuery() { Finish(); }
      44             : 
      45             : public:
      46             : 
      47           0 :     explicit nsRDFQuery(nsXULTemplateQueryProcessorRDF* aProcessor)
      48           0 :       : mProcessor(aProcessor),
      49             :         mSimple(false),
      50             :         mRoot(nullptr),
      51           0 :         mCachedResults(nullptr)
      52           0 :     { }
      53             : 
      54             :     NS_DECL_CYCLE_COLLECTING_ISUPPORTS
      55           0 :     NS_DECL_CYCLE_COLLECTION_CLASS(nsRDFQuery)
      56             : 
      57             :     /**
      58             :      * Retrieve the root node in the rule network
      59             :      * @return the root node in the rule network
      60             :      */
      61           0 :     TestNode* GetRoot() { return mRoot; }
      62             : 
      63           0 :     void SetRoot(TestNode* aRoot) { mRoot = aRoot; }
      64             : 
      65           0 :     void GetQueryNode(nsIDOMNode** aQueryNode) override
      66             :     {
      67           0 :        *aQueryNode = mQueryNode;
      68           0 :        NS_IF_ADDREF(*aQueryNode);
      69           0 :     }
      70             : 
      71           0 :     void SetQueryNode(nsIDOMNode* aQueryNode)
      72             :     {
      73           0 :        mQueryNode = aQueryNode;
      74           0 :     }
      75             : 
      76             :     // an optimization is used when several queries all use the simple query
      77             :     // syntax. Since simple queries can only generate one possible set of
      78             :     // results, they only need to be calculated once and reused for every
      79             :     // simple query. The results may be cached in the query for this purpose.
      80             :     // If successful, this method takes ownership of aInstantiations.
      81             :     nsresult SetCachedResults(nsXULTemplateQueryProcessorRDF* aProcessor,
      82             :                               const InstantiationSet& aInstantiations);
      83             : 
      84             :     // grab the cached results, if any, causing the caller to take ownership
      85             :     // of them. This also has the effect of setting the cached results in this
      86             :     // nsRDFQuery to null.
      87             :     void UseCachedResults(nsISimpleEnumerator** aResults);
      88             : 
      89             :     // clear the cached results
      90           0 :     void ClearCachedResults() override
      91             :     {
      92           0 :         mCachedResults = nullptr;
      93           0 :     }
      94             : 
      95           0 :     nsXULTemplateQueryProcessorRDF* Processor() override { return mProcessor; }
      96             : 
      97           0 :     nsIAtom* GetMemberVariable() override { return mMemberVariable; }
      98             : 
      99           0 :     bool IsSimple() { return mSimple; }
     100             : 
     101           0 :     void SetSimple() { mSimple = true; }
     102             : 
     103             :     // the reference and member variables for the query
     104             :     nsCOMPtr<nsIAtom> mRefVariable;
     105             :     nsCOMPtr<nsIAtom> mMemberVariable;
     106             : 
     107             : protected:
     108             : 
     109             :     nsXULTemplateQueryProcessorRDF* mProcessor;
     110             : 
     111             :     // true if the query is a simple rule (one with a default query)
     112             :     bool mSimple;
     113             : 
     114             :     /**
     115             :      * The root node in the network for this query
     116             :      */
     117             :     TestNode *mRoot;
     118             : 
     119             :     // the <query> node
     120             :     nsCOMPtr<nsIDOMNode> mQueryNode;
     121             : 
     122             :     // used for simple rules since their results are all determined in one step
     123             :     nsCOMPtr<nsISimpleEnumerator> mCachedResults;
     124             : 
     125             :     void Finish();
     126             : };
     127             : 
     128             : NS_DEFINE_STATIC_IID_ACCESSOR(nsITemplateRDFQuery, NS_ITEMPLATERDFQUERY_IID)
     129             : 
     130             : #endif // nsRDFQuery_h__

Generated by: LCOV version 1.13