knoaman 2003/12/16 10:41:15 Modified: c/src/xercesc/validators/schema/identity FieldActivator.cpp FieldActivator.hpp IC_Field.cpp IC_Field.hpp ValueStore.cpp ValueStore.hpp Log: Make IC_Field stateless Revision Changes Path 1.6 +18 -2 xml-xerces/c/src/xercesc/validators/schema/identity/FieldActivator.cpp Index: FieldActivator.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/identity/FieldActivator.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- FieldActivator.cpp 22 May 2003 02:10:52 -0000 1.5 +++ FieldActivator.cpp 16 Dec 2003 18:41:15 -0000 1.6 @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.6 2003/12/16 18:41:15 knoaman + * Make IC_Field stateless + * * Revision 1.5 2003/05/22 02:10:52 knoaman * Default the memory manager. * @@ -83,6 +86,7 @@ #include <xercesc/validators/schema/identity/ValueStore.hpp> #include <xercesc/validators/schema/identity/ValueStoreCache.hpp> #include <xercesc/validators/schema/identity/XPathMatcherStack.hpp> +#include <xercesc/util/HashPtr.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -94,15 +98,27 @@ MemoryManager* const manager) : fValueStoreCache(valueStoreCache) , fMatcherStack(matcherStack) + , fMayMatch(0) , fMemoryManager(manager) { + fMayMatch = new (manager) ValueHashTableOf<bool>(29, new (manager) HashPtr(), manager); } FieldActivator::FieldActivator(const FieldActivator& other) : fValueStoreCache(other.fValueStoreCache) , fMatcherStack(other.fMatcherStack) + , fMayMatch(0) , fMemoryManager(other.fMemoryManager) { + fMayMatch = new (fMemoryManager) ValueHashTableOf<bool>(29, new (fMemoryManager) HashPtr(), fMemoryManager); + ValueHashTableOfEnumerator<bool> mayMatchEnum(other.fMayMatch); + + // Build key set + while (mayMatchEnum.hasMoreElements()) + { + IC_Field* field = (IC_Field*) mayMatchEnum.nextElementKey(); + fMayMatch->put(field, other.fMayMatch->get(field)); + } } @@ -130,9 +146,9 @@ XPathMatcher* FieldActivator::activateField(IC_Field* const field, const int initialDepth) { ValueStore* valueStore = fValueStoreCache->getValueStoreFor(field, initialDepth); - XPathMatcher* matcher = field->createMatcher(valueStore, fMemoryManager); + XPathMatcher* matcher = field->createMatcher(this, valueStore, fMemoryManager); - field->setMayMatch(true); + setMayMatch(field, true); fMatcherStack->addMatcher(matcher); matcher->startDocumentFragment(); 1.6 +25 -5 xml-xerces/c/src/xercesc/validators/schema/identity/FieldActivator.hpp Index: FieldActivator.hpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/identity/FieldActivator.hpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- FieldActivator.hpp 16 May 2003 21:43:22 -0000 1.5 +++ FieldActivator.hpp 16 Dec 2003 18:41:15 -0000 1.6 @@ -69,7 +69,7 @@ // --------------------------------------------------------------------------- // Includes // --------------------------------------------------------------------------- -#include <xercesc/util/PlatformUtils.hpp> +#include <xercesc/util/ValueHashTableOf.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -101,10 +101,16 @@ FieldActivator& operator =(const FieldActivator& other); // ----------------------------------------------------------------------- + // Getter methods + // ----------------------------------------------------------------------- + bool getMayMatch(IC_Field* const field); + + // ----------------------------------------------------------------------- // Setter methods // ----------------------------------------------------------------------- void setValueStoreCache(ValueStoreCache* const other); void setMatcherStack(XPathMatcherStack* const matcherStack); + void setMayMatch(IC_Field* const field, bool value); // ----------------------------------------------------------------------- // Activation methods @@ -131,13 +137,22 @@ // ----------------------------------------------------------------------- // Data // ----------------------------------------------------------------------- - ValueStoreCache* fValueStoreCache; - XPathMatcherStack* fMatcherStack; - MemoryManager* fMemoryManager; + ValueStoreCache* fValueStoreCache; + XPathMatcherStack* fMatcherStack; + ValueHashTableOf<bool>* fMayMatch; + MemoryManager* fMemoryManager; }; // --------------------------------------------------------------------------- +// FieldActivator: Getter methods +// --------------------------------------------------------------------------- +inline bool FieldActivator::getMayMatch(IC_Field* const field) { + + return fMayMatch->get(field); +} + +// --------------------------------------------------------------------------- // FieldActivator: Setter methods // --------------------------------------------------------------------------- inline void FieldActivator::setValueStoreCache(ValueStoreCache* const other) { @@ -149,6 +164,11 @@ FieldActivator::setMatcherStack(XPathMatcherStack* const matcherStack) { fMatcherStack = matcherStack; +} + +inline void FieldActivator::setMayMatch(IC_Field* const field, bool value) { + + fMayMatch->put(field, value); } XERCES_CPP_NAMESPACE_END 1.6 +16 -6 xml-xerces/c/src/xercesc/validators/schema/identity/IC_Field.cpp Index: IC_Field.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/identity/IC_Field.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- IC_Field.cpp 14 Oct 2003 15:24:23 -0000 1.5 +++ IC_Field.cpp 16 Dec 2003 18:41:15 -0000 1.6 @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.6 2003/12/16 18:41:15 knoaman + * Make IC_Field stateless + * * Revision 1.5 2003/10/14 15:24:23 peiyongz * Implementation of Serialization/Deserialization * @@ -82,10 +85,10 @@ // --------------------------------------------------------------------------- // Includes // --------------------------------------------------------------------------- +#include <xercesc/validators/schema/identity/FieldActivator.hpp> #include <xercesc/validators/schema/identity/IC_Field.hpp> #include <xercesc/validators/schema/identity/ValueStore.hpp> #include <xercesc/validators/schema/identity/XercesXPath.hpp> - #include <xercesc/validators/schema/identity/IdentityConstraint.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -96,10 +99,12 @@ FieldMatcher::FieldMatcher(XercesXPath* const xpath, IC_Field* const aField, ValueStore* const valueStore, + FieldActivator* const fieldActivator, MemoryManager* const manager) : XPathMatcher(xpath, (IdentityConstraint*) 0, manager) , fField(aField) , fValueStore(valueStore) + , fFieldActivator(fieldActivator) { } @@ -114,12 +119,12 @@ fValueStore->reportNilError(fField->getIdentityConstraint()); } - fValueStore->addValue(fField, dv, content); + fValueStore->addValue(fFieldActivator, fField, dv, content); // once we've stored the value for this field, we set the mayMatch // member to false so that, in the same scope, we don't match any more // values (and throw an error instead). - fField->setMayMatch(false); + fFieldActivator->setMayMatch(fField, false); } // --------------------------------------------------------------------------- @@ -157,7 +162,14 @@ XPathMatcher* IC_Field::createMatcher(ValueStore* const valueStore, MemoryManager* const manager) { - return new (manager) FieldMatcher(fXPath, this, valueStore, manager); + return 0; +} + +XPathMatcher* IC_Field::createMatcher(FieldActivator* const fieldActivator, + ValueStore* const valueStore, + MemoryManager* const manager) +{ + return new (manager) FieldMatcher(fXPath, this, valueStore, fieldActivator, manager); } /*** @@ -171,14 +183,12 @@ if (serEng.isStoring()) { - serEng<<fMayMatch; serEng<<fXPath; IdentityConstraint::storeIC(serEng, fIdentityConstraint); } else { - serEng>>fMayMatch; serEng>>fXPath; fIdentityConstraint = IdentityConstraint::loadIC(serEng); 1.6 +28 -9 xml-xerces/c/src/xercesc/validators/schema/identity/IC_Field.hpp Index: IC_Field.hpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/identity/IC_Field.hpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- IC_Field.hpp 14 Oct 2003 15:24:23 -0000 1.5 +++ IC_Field.hpp 16 Dec 2003 18:41:15 -0000 1.6 @@ -75,6 +75,7 @@ // Forward Declaration // --------------------------------------------------------------------------- class ValueStore; +class FieldActivator; class VALIDATORS_EXPORT IC_Field : public XSerializable, public XMemory @@ -93,21 +94,38 @@ bool operator== (const IC_Field& other) const; bool operator!= (const IC_Field& other) const; - // ----------------------------------------------------------------------- + // ----------------------------------------------------------------------- // Getter methods // ----------------------------------------------------------------------- - bool getMayMatch() const { return fMayMatch; } XercesXPath* getXPath() const { return fXPath; } IdentityConstraint* getIdentityConstraint() const { return fIdentityConstraint; } - // ----------------------------------------------------------------------- + /** + * @deprecated + */ + bool getMayMatch() const { return false; } + + // ----------------------------------------------------------------------- // Setter methods // ----------------------------------------------------------------------- - void setMayMatch(const bool other) { fMayMatch = other; } + /** + * @deprecated + */ + void setMayMatch(const bool) {} - // ----------------------------------------------------------------------- + // ----------------------------------------------------------------------- // Factory methods // ----------------------------------------------------------------------- + XPathMatcher* createMatcher + ( + FieldActivator* const fieldActivator + , ValueStore* const valueStore + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager + ); + + /** + * @deprecated + */ XPathMatcher* createMatcher(ValueStore* const valueStore, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); @@ -128,7 +146,6 @@ // ----------------------------------------------------------------------- // Data members // ----------------------------------------------------------------------- - bool fMayMatch; XercesXPath* fXPath; IdentityConstraint* fIdentityConstraint; }; @@ -161,6 +178,7 @@ FieldMatcher(XercesXPath* const anXPath, IC_Field* const aField, ValueStore* const valueStore, + FieldActivator* const fieldActivator, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); // ----------------------------------------------------------------------- @@ -177,8 +195,9 @@ // ----------------------------------------------------------------------- // Data members // ----------------------------------------------------------------------- - ValueStore* fValueStore; - IC_Field* fField; + ValueStore* fValueStore; + IC_Field* fField; + FieldActivator* fFieldActivator; }; XERCES_CPP_NAMESPACE_END 1.8 +12 -1 xml-xerces/c/src/xercesc/validators/schema/identity/ValueStore.cpp Index: ValueStore.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/identity/ValueStore.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- ValueStore.cpp 18 May 2003 14:02:09 -0000 1.7 +++ ValueStore.cpp 16 Dec 2003 18:41:15 -0000 1.8 @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.8 2003/12/16 18:41:15 knoaman + * Make IC_Field stateless + * * Revision 1.7 2003/05/18 14:02:09 knoaman * Memory manager implementation: pass per instance manager. * @@ -94,6 +97,7 @@ #include <xercesc/internal/XMLScanner.hpp> #include <xercesc/framework/XMLValidator.hpp> #include <xercesc/validators/datatype/DatatypeValidator.hpp> +#include <xercesc/validators/schema/identity/FieldActivator.hpp> #include <xercesc/validators/schema/identity/ValueStore.hpp> #include <xercesc/validators/schema/identity/IC_Field.hpp> #include <xercesc/validators/schema/identity/IC_KeyRef.hpp> @@ -132,7 +136,14 @@ DatatypeValidator* const dv, const XMLCh* const value) { - if (!field->getMayMatch() && fDoReportError) { +} + +void ValueStore::addValue(FieldActivator* const fieldActivator, + IC_Field* const field, + DatatypeValidator* const dv, + const XMLCh* const value) { + + if (!fieldActivator->getMayMatch(field) && fDoReportError) { fScanner->getValidator()->emitError(XMLValid::IC_FieldMultipleMatch); } 1.6 +15 -6 xml-xerces/c/src/xercesc/validators/schema/identity/ValueStore.hpp Index: ValueStore.hpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/identity/ValueStore.hpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- ValueStore.hpp 16 May 2003 21:43:22 -0000 1.5 +++ ValueStore.hpp 16 Dec 2003 18:41:15 -0000 1.6 @@ -94,27 +94,36 @@ MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); ~ValueStore(); - // ----------------------------------------------------------------------- + // ----------------------------------------------------------------------- // Getter methods // ----------------------------------------------------------------------- IdentityConstraint* getIdentityConstraint() const; - // ----------------------------------------------------------------------- + // ----------------------------------------------------------------------- // Helper methods // ----------------------------------------------------------------------- void append(const ValueStore* const other); void startValueScope(); void endValueScope(); - void addValue(IC_Field* const field, DatatypeValidator* const dv, + void addValue(FieldActivator* const fieldActivator, + IC_Field* const field, + DatatypeValidator* const dv, const XMLCh* const value); bool contains(const FieldValueMap* const other); - // ----------------------------------------------------------------------- + /** + * @deprecated + */ + void addValue(IC_Field* const field, DatatypeValidator* const dv, + const XMLCh* const value); + + + // ----------------------------------------------------------------------- // Document handling methods // ----------------------------------------------------------------------- void endDcocumentFragment(ValueStoreCache* const valueStoreCache); - // ----------------------------------------------------------------------- + // ----------------------------------------------------------------------- // Error reporting methods // ----------------------------------------------------------------------- void duplicateValue();
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]