[2674] | 1 | /* |
---|
| 2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
---|
| 3 | * contributor license agreements. See the NOTICE file distributed with |
---|
| 4 | * this work for additional information regarding copyright ownership. |
---|
| 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
---|
| 6 | * (the "License"); you may not use this file except in compliance with |
---|
| 7 | * the License. You may obtain a copy of the License at |
---|
| 8 | * |
---|
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
---|
| 10 | * |
---|
| 11 | * Unless required by applicable law or agreed to in writing, software |
---|
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
---|
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
| 14 | * See the License for the specific language governing permissions and |
---|
| 15 | * limitations under the License. |
---|
| 16 | */ |
---|
| 17 | |
---|
| 18 | /* |
---|
| 19 | * $Id: FieldActivator.hpp 568078 2007-08-21 11:43:25Z amassari $ |
---|
| 20 | */ |
---|
| 21 | |
---|
| 22 | #if !defined(FIELDACTIVATOR_HPP) |
---|
| 23 | #define FIELDACTIVATOR_HPP |
---|
| 24 | |
---|
| 25 | /** |
---|
| 26 | * This class is responsible for activating fields within a specific scope; |
---|
| 27 | * the caller merely requests the fields to be activated. |
---|
| 28 | */ |
---|
| 29 | |
---|
| 30 | // --------------------------------------------------------------------------- |
---|
| 31 | // Includes |
---|
| 32 | // --------------------------------------------------------------------------- |
---|
| 33 | #include <xercesc/util/ValueHashTableOf.hpp> |
---|
| 34 | |
---|
| 35 | XERCES_CPP_NAMESPACE_BEGIN |
---|
| 36 | |
---|
| 37 | // --------------------------------------------------------------------------- |
---|
| 38 | // Forward Declaration |
---|
| 39 | // --------------------------------------------------------------------------- |
---|
| 40 | class IdentityConstraint; |
---|
| 41 | class XPathMatcher; |
---|
| 42 | class ValueStoreCache; |
---|
| 43 | class IC_Field; |
---|
| 44 | class XPathMatcherStack; |
---|
| 45 | |
---|
| 46 | |
---|
| 47 | class VALIDATORS_EXPORT FieldActivator : public XMemory |
---|
| 48 | { |
---|
| 49 | public: |
---|
| 50 | // ----------------------------------------------------------------------- |
---|
| 51 | // Constructors/Destructor |
---|
| 52 | // ----------------------------------------------------------------------- |
---|
| 53 | FieldActivator(ValueStoreCache* const valueStoreCache, |
---|
| 54 | XPathMatcherStack* const matcherStack, |
---|
| 55 | MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); |
---|
| 56 | FieldActivator(const FieldActivator& other); |
---|
| 57 | ~FieldActivator(); |
---|
| 58 | |
---|
| 59 | // ----------------------------------------------------------------------- |
---|
| 60 | // Operator methods |
---|
| 61 | // ----------------------------------------------------------------------- |
---|
| 62 | FieldActivator& operator =(const FieldActivator& other); |
---|
| 63 | |
---|
| 64 | // ----------------------------------------------------------------------- |
---|
| 65 | // Getter methods |
---|
| 66 | // ----------------------------------------------------------------------- |
---|
| 67 | bool getMayMatch(IC_Field* const field); |
---|
| 68 | |
---|
| 69 | // ----------------------------------------------------------------------- |
---|
| 70 | // Setter methods |
---|
| 71 | // ----------------------------------------------------------------------- |
---|
| 72 | void setValueStoreCache(ValueStoreCache* const other); |
---|
| 73 | void setMatcherStack(XPathMatcherStack* const matcherStack); |
---|
| 74 | void setMayMatch(IC_Field* const field, bool value); |
---|
| 75 | |
---|
| 76 | // ----------------------------------------------------------------------- |
---|
| 77 | // Activation methods |
---|
| 78 | // ----------------------------------------------------------------------- |
---|
| 79 | /** |
---|
| 80 | * Start the value scope for the specified identity constraint. This |
---|
| 81 | * method is called when the selector matches in order to initialize |
---|
| 82 | * the value store. |
---|
| 83 | */ |
---|
| 84 | void startValueScopeFor(const IdentityConstraint* const ic, const int initialDepth); |
---|
| 85 | |
---|
| 86 | /** |
---|
| 87 | * Request to activate the specified field. This method returns the |
---|
| 88 | * matcher for the field. |
---|
| 89 | */ |
---|
| 90 | XPathMatcher* activateField(IC_Field* const field, const int initialDepth); |
---|
| 91 | |
---|
| 92 | /** |
---|
| 93 | * Ends the value scope for the specified identity constraint. |
---|
| 94 | */ |
---|
| 95 | void endValueScopeFor(const IdentityConstraint* const ic, const int initialDepth); |
---|
| 96 | |
---|
| 97 | private: |
---|
| 98 | // ----------------------------------------------------------------------- |
---|
| 99 | // Data |
---|
| 100 | // ----------------------------------------------------------------------- |
---|
| 101 | ValueStoreCache* fValueStoreCache; |
---|
| 102 | XPathMatcherStack* fMatcherStack; |
---|
| 103 | ValueHashTableOf<bool>* fMayMatch; |
---|
| 104 | MemoryManager* fMemoryManager; |
---|
| 105 | }; |
---|
| 106 | |
---|
| 107 | |
---|
| 108 | // --------------------------------------------------------------------------- |
---|
| 109 | // FieldActivator: Getter methods |
---|
| 110 | // --------------------------------------------------------------------------- |
---|
| 111 | inline bool FieldActivator::getMayMatch(IC_Field* const field) { |
---|
| 112 | |
---|
| 113 | return fMayMatch->get(field); |
---|
| 114 | } |
---|
| 115 | |
---|
| 116 | // --------------------------------------------------------------------------- |
---|
| 117 | // FieldActivator: Setter methods |
---|
| 118 | // --------------------------------------------------------------------------- |
---|
| 119 | inline void FieldActivator::setValueStoreCache(ValueStoreCache* const other) { |
---|
| 120 | |
---|
| 121 | fValueStoreCache = other; |
---|
| 122 | } |
---|
| 123 | |
---|
| 124 | inline void |
---|
| 125 | FieldActivator::setMatcherStack(XPathMatcherStack* const matcherStack) { |
---|
| 126 | |
---|
| 127 | fMatcherStack = matcherStack; |
---|
| 128 | } |
---|
| 129 | |
---|
| 130 | inline void FieldActivator::setMayMatch(IC_Field* const field, bool value) { |
---|
| 131 | |
---|
| 132 | fMayMatch->put(field, value); |
---|
| 133 | } |
---|
| 134 | |
---|
| 135 | XERCES_CPP_NAMESPACE_END |
---|
| 136 | |
---|
| 137 | #endif |
---|
| 138 | |
---|
| 139 | /** |
---|
| 140 | * End of file FieldActivator.hpp |
---|
| 141 | */ |
---|
| 142 | |
---|