GME
13
|
00001 /* 00002 * Licensed to the Apache Software Foundation (ASF) under one or more 00003 * contributor license agreements. See the NOTICE file distributed with 00004 * this work for additional information regarding copyright ownership. 00005 * The ASF licenses this file to You under the Apache License, Version 2.0 00006 * (the "License"); you may not use this file except in compliance with 00007 * the License. You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 00018 /* 00019 * $Id: FieldActivator.cpp 679340 2008-07-24 10:28:29Z borisk $ 00020 */ 00021 00022 // --------------------------------------------------------------------------- 00023 // Includes 00024 // --------------------------------------------------------------------------- 00025 #include <xercesc/validators/schema/identity/FieldActivator.hpp> 00026 #include <xercesc/validators/schema/identity/ValueStore.hpp> 00027 #include <xercesc/validators/schema/identity/ValueStoreCache.hpp> 00028 #include <xercesc/validators/schema/identity/XPathMatcherStack.hpp> 00029 00030 XERCES_CPP_NAMESPACE_BEGIN 00031 00032 // --------------------------------------------------------------------------- 00033 // FieldActivator: Constructors and Destructor 00034 // --------------------------------------------------------------------------- 00035 FieldActivator::FieldActivator(ValueStoreCache* const valueStoreCache, 00036 XPathMatcherStack* const matcherStack, 00037 MemoryManager* const manager) 00038 : fValueStoreCache(valueStoreCache) 00039 , fMatcherStack(matcherStack) 00040 , fMayMatch(0) 00041 , fMemoryManager(manager) 00042 { 00043 fMayMatch = new (manager) ValueHashTableOf<bool, PtrHasher>(29, manager); 00044 } 00045 00046 FieldActivator::FieldActivator(const FieldActivator& other) 00047 : XMemory(other) 00048 , fValueStoreCache(other.fValueStoreCache) 00049 , fMatcherStack(other.fMatcherStack) 00050 , fMayMatch(0) 00051 , fMemoryManager(other.fMemoryManager) 00052 { 00053 fMayMatch = new (fMemoryManager) ValueHashTableOf<bool, PtrHasher>(29, fMemoryManager); 00054 ValueHashTableOfEnumerator<bool, PtrHasher> mayMatchEnum(other.fMayMatch, false, fMemoryManager); 00055 00056 // Build key set 00057 while (mayMatchEnum.hasMoreElements()) 00058 { 00059 IC_Field* field = (IC_Field*) mayMatchEnum.nextElementKey(); 00060 fMayMatch->put(field, other.fMayMatch->get(field)); 00061 } 00062 } 00063 00064 00065 FieldActivator::~FieldActivator() 00066 { 00067 delete fMayMatch; 00068 } 00069 00070 // --------------------------------------------------------------------------- 00071 // FieldActivator: Operator methods 00072 // --------------------------------------------------------------------------- 00073 FieldActivator& FieldActivator::operator =(const FieldActivator& other) { 00074 00075 if (this == &other) { 00076 return *this; 00077 } 00078 00079 fValueStoreCache = other.fValueStoreCache; 00080 fMatcherStack = other.fMatcherStack; 00081 return *this; 00082 } 00083 00084 // --------------------------------------------------------------------------- 00085 // FieldActivator: Operator methods 00086 // --------------------------------------------------------------------------- 00087 XPathMatcher* FieldActivator::activateField(IC_Field* const field, const int initialDepth) { 00088 00089 ValueStore* valueStore = fValueStoreCache->getValueStoreFor(field, initialDepth); 00090 XPathMatcher* matcher = field->createMatcher(this, valueStore, fMemoryManager); 00091 00092 setMayMatch(field, true); 00093 fMatcherStack->addMatcher(matcher); 00094 matcher->startDocumentFragment(); 00095 00096 return matcher; 00097 } 00098 00099 void FieldActivator::startValueScopeFor(const IdentityConstraint* const ic, 00100 const int initialDepth) { 00101 00102 XMLSize_t fieldCount = ic->getFieldCount(); 00103 00104 for(XMLSize_t i=0; i<fieldCount; i++) { 00105 00106 const IC_Field* field = ic->getFieldAt(i); 00107 ValueStore* valueStore = fValueStoreCache->getValueStoreFor(field, initialDepth); 00108 00109 valueStore->startValueScope(); 00110 } 00111 } 00112 00113 void FieldActivator::endValueScopeFor(const IdentityConstraint* const ic, const int initialDepth) { 00114 00115 ValueStore* valueStore = fValueStoreCache->getValueStoreFor(ic, initialDepth); 00116 00117 valueStore->endValueScope(); 00118 } 00119 00120 XERCES_CPP_NAMESPACE_END 00121