content/xul/templates/src/nsRDFPropertyTestNode.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/xul/templates/src/nsRDFPropertyTestNode.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,104 @@
     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 nsRDFPropertyTestNode_h__
    1.10 +#define nsRDFPropertyTestNode_h__
    1.11 +
    1.12 +#include "mozilla/Attributes.h"
    1.13 +#include "nscore.h"
    1.14 +#include "nsRDFTestNode.h"
    1.15 +#include "nsIRDFDataSource.h"
    1.16 +#include "nsIRDFResource.h"
    1.17 +#include "nsXULTemplateQueryProcessorRDF.h"
    1.18 +
    1.19 +class nsRDFPropertyTestNode : public nsRDFTestNode
    1.20 +{
    1.21 +public:
    1.22 +    /**
    1.23 +     * Both source and target unbound (?source ^property ?target)
    1.24 +     */
    1.25 +    nsRDFPropertyTestNode(TestNode* aParent,
    1.26 +                          nsXULTemplateQueryProcessorRDF* aProcessor,
    1.27 +                          nsIAtom* aSourceVariable,
    1.28 +                          nsIRDFResource* aProperty,
    1.29 +                          nsIAtom* aTargetVariable);
    1.30 +
    1.31 +    /**
    1.32 +     * Source bound, target unbound (source ^property ?target)
    1.33 +     */
    1.34 +    nsRDFPropertyTestNode(TestNode* aParent,
    1.35 +                          nsXULTemplateQueryProcessorRDF* aProcessor,
    1.36 +                          nsIRDFResource* aSource,
    1.37 +                          nsIRDFResource* aProperty,
    1.38 +                          nsIAtom* aTargetVariable);
    1.39 +
    1.40 +    /**
    1.41 +     * Source unbound, target bound (?source ^property target)
    1.42 +     */
    1.43 +    nsRDFPropertyTestNode(TestNode* aParent,
    1.44 +                          nsXULTemplateQueryProcessorRDF* aProcessor,
    1.45 +                          nsIAtom* aSourceVariable,
    1.46 +                          nsIRDFResource* aProperty,
    1.47 +                          nsIRDFNode* aTarget);
    1.48 +
    1.49 +    virtual nsresult FilterInstantiations(InstantiationSet& aInstantiations,
    1.50 +                                          bool* aCantHandleYet) const MOZ_OVERRIDE;
    1.51 +
    1.52 +    virtual bool
    1.53 +    CanPropagate(nsIRDFResource* aSource,
    1.54 +                 nsIRDFResource* aProperty,
    1.55 +                 nsIRDFNode* aTarget,
    1.56 +                 Instantiation& aInitialBindings) const MOZ_OVERRIDE;
    1.57 +
    1.58 +    virtual void
    1.59 +    Retract(nsIRDFResource* aSource,
    1.60 +            nsIRDFResource* aProperty,
    1.61 +            nsIRDFNode* aTarget) const MOZ_OVERRIDE;
    1.62 +
    1.63 +
    1.64 +    class Element : public MemoryElement {
    1.65 +    public:
    1.66 +        Element(nsIRDFResource* aSource,
    1.67 +                nsIRDFResource* aProperty,
    1.68 +                nsIRDFNode* aTarget)
    1.69 +            : mSource(aSource),
    1.70 +              mProperty(aProperty),
    1.71 +              mTarget(aTarget) {
    1.72 +            MOZ_COUNT_CTOR(nsRDFPropertyTestNode::Element); }
    1.73 +
    1.74 +        virtual ~Element() { MOZ_COUNT_DTOR(nsRDFPropertyTestNode::Element); }
    1.75 +
    1.76 +        virtual const char* Type() const MOZ_OVERRIDE {
    1.77 +            return "nsRDFPropertyTestNode::Element"; }
    1.78 +
    1.79 +        virtual PLHashNumber Hash() const MOZ_OVERRIDE {
    1.80 +            return mozilla::HashGeneric(mSource.get(), mProperty.get(), mTarget.get());
    1.81 +        }
    1.82 +
    1.83 +        virtual bool Equals(const MemoryElement& aElement) const MOZ_OVERRIDE {
    1.84 +            if (aElement.Type() == Type()) {
    1.85 +                const Element& element = static_cast<const Element&>(aElement);
    1.86 +                return mSource == element.mSource
    1.87 +                    && mProperty == element.mProperty
    1.88 +                    && mTarget == element.mTarget;
    1.89 +            }
    1.90 +            return false; }
    1.91 +
    1.92 +    protected:
    1.93 +        nsCOMPtr<nsIRDFResource> mSource;
    1.94 +        nsCOMPtr<nsIRDFResource> mProperty;
    1.95 +        nsCOMPtr<nsIRDFNode> mTarget;
    1.96 +    };
    1.97 +
    1.98 +protected:
    1.99 +    nsXULTemplateQueryProcessorRDF* mProcessor;
   1.100 +    nsCOMPtr<nsIAtom>        mSourceVariable;
   1.101 +    nsCOMPtr<nsIRDFResource> mSource;
   1.102 +    nsCOMPtr<nsIRDFResource> mProperty;
   1.103 +    nsCOMPtr<nsIAtom>        mTargetVariable;
   1.104 +    nsCOMPtr<nsIRDFNode>     mTarget;
   1.105 +};
   1.106 +
   1.107 +#endif // nsRDFPropertyTestNode_h__

mercurial