content/xul/templates/src/nsRDFConInstanceTestNode.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/xul/templates/src/nsRDFConInstanceTestNode.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,88 @@
     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 nsRDFConInstanceTestNode_h__
    1.10 +#define nsRDFConInstanceTestNode_h__
    1.11 +
    1.12 +#include "mozilla/Attributes.h"
    1.13 +#include "nscore.h"
    1.14 +#include "nsRDFTestNode.h"
    1.15 +#include "nsIRDFResource.h"
    1.16 +#include "nsIRDFDataSource.h"
    1.17 +#include "nsXULTemplateQueryProcessorRDF.h"
    1.18 +
    1.19 +/**
    1.20 + * Rule network node that tests if a resource is an RDF container, or
    1.21 + * uses multi-attributes to ``contain'' other elements.
    1.22 + */
    1.23 +class nsRDFConInstanceTestNode : public nsRDFTestNode
    1.24 +{
    1.25 +public:
    1.26 +    enum Test { eFalse, eTrue, eDontCare };
    1.27 +
    1.28 +    nsRDFConInstanceTestNode(TestNode* aParent,
    1.29 +                             nsXULTemplateQueryProcessorRDF* aProcessor,
    1.30 +                             nsIAtom* aContainerVariable,
    1.31 +                             Test aContainer,
    1.32 +                             Test aEmpty);
    1.33 +
    1.34 +    virtual nsresult FilterInstantiations(InstantiationSet& aInstantiations,
    1.35 +                                          bool* aCantHandleYet) const MOZ_OVERRIDE;
    1.36 +
    1.37 +    virtual bool
    1.38 +    CanPropagate(nsIRDFResource* aSource,
    1.39 +                 nsIRDFResource* aProperty,
    1.40 +                 nsIRDFNode* aTarget,
    1.41 +                 Instantiation& aInitialBindings) const MOZ_OVERRIDE;
    1.42 +
    1.43 +    virtual void
    1.44 +    Retract(nsIRDFResource* aSource,
    1.45 +            nsIRDFResource* aProperty,
    1.46 +            nsIRDFNode* aTarget) const MOZ_OVERRIDE;
    1.47 +
    1.48 +
    1.49 +    class Element : public MemoryElement {
    1.50 +    public:
    1.51 +        Element(nsIRDFResource* aContainer,
    1.52 +                Test aContainerTest,
    1.53 +                Test aEmptyTest)
    1.54 +            : mContainer(aContainer),
    1.55 +              mContainerTest(aContainerTest),
    1.56 +              mEmptyTest(aEmptyTest) {
    1.57 +            MOZ_COUNT_CTOR(nsRDFConInstanceTestNode::Element); }
    1.58 +
    1.59 +        virtual ~Element() { MOZ_COUNT_DTOR(nsRDFConInstanceTestNode::Element); }
    1.60 +
    1.61 +        virtual const char* Type() const MOZ_OVERRIDE {
    1.62 +            return "nsRDFConInstanceTestNode::Element"; }
    1.63 +
    1.64 +        virtual PLHashNumber Hash() const MOZ_OVERRIDE {
    1.65 +            return mozilla::HashGeneric(mContainerTest, mEmptyTest, mContainer.get());
    1.66 +        }
    1.67 +
    1.68 +        virtual bool Equals(const MemoryElement& aElement) const MOZ_OVERRIDE {
    1.69 +            if (aElement.Type() == Type()) {
    1.70 +                const Element& element = static_cast<const Element&>(aElement);
    1.71 +                return mContainer == element.mContainer
    1.72 +                    && mContainerTest == element.mContainerTest
    1.73 +                    && mEmptyTest == element.mEmptyTest;
    1.74 +            }
    1.75 +            return false; }
    1.76 +
    1.77 +    protected:
    1.78 +        nsCOMPtr<nsIRDFResource> mContainer;
    1.79 +        Test mContainerTest;
    1.80 +        Test mEmptyTest;
    1.81 +    };
    1.82 +
    1.83 +protected:
    1.84 +    nsXULTemplateQueryProcessorRDF* mProcessor;
    1.85 +    nsCOMPtr<nsIAtom> mContainerVariable;
    1.86 +    Test mContainer;
    1.87 +    Test mEmpty;
    1.88 +};
    1.89 +
    1.90 +#endif // nsRDFConInstanceTestNode_h__
    1.91 +

mercurial