Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:27:26

0001 /*
0002  * Licensed to the Apache Software Foundation (ASF) under one or more
0003  * contributor license agreements.  See the NOTICE file distributed with
0004  * this work for additional information regarding copyright ownership.
0005  * The ASF licenses this file to You under the Apache License, Version 2.0
0006  * (the "License"); you may not use this file except in compliance with
0007  * the License.  You may obtain a copy of the License at
0008  * 
0009  *      http://www.apache.org/licenses/LICENSE-2.0
0010  * 
0011  * Unless required by applicable law or agreed to in writing, software
0012  * distributed under the License is distributed on an "AS IS" BASIS,
0013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014  * See the License for the specific language governing permissions and
0015  * limitations under the License.
0016  */
0017 
0018 /*
0019  * $Id$
0020  */
0021 
0022 #if !defined(XERCESC_INCLUDE_GUARD_SYNCHRONIZEDSTRINGPOOL_HPP)
0023 #define XERCESC_INCLUDE_GUARD_SYNCHRONIZEDSTRINGPOOL_HPP
0024 
0025 #include <xercesc/framework/MemoryManager.hpp>
0026 #include <xercesc/util/StringPool.hpp>
0027 #include <xercesc/util/Mutexes.hpp>
0028 
0029 XERCES_CPP_NAMESPACE_BEGIN
0030 
0031 //
0032 //  This class provides a synchronized string pool implementation.
0033 //  This will necessarily be slower than the regular XMLStringPool, so it
0034 //  should only be used when updates need to be made in a thread-safe
0035 //  way.  Updates will be made on datastructures local to this object;
0036 //  all queries that don't involve mutation will first be directed at
0037 //  the XMLStringPool implementation with which this object is
0038 //  constructed.
0039 class XMLUTIL_EXPORT XMLSynchronizedStringPool : public XMLStringPool
0040 {
0041 public :
0042     // -----------------------------------------------------------------------
0043     //  Constructors and Destructor
0044     // -----------------------------------------------------------------------
0045     XMLSynchronizedStringPool
0046     (
0047         const XMLStringPool *  constPool
0048         , const unsigned int   modulus = 109
0049         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
0050     );
0051     virtual ~XMLSynchronizedStringPool();
0052 
0053 
0054     // -----------------------------------------------------------------------
0055     //  Pool management methods
0056     // -----------------------------------------------------------------------
0057     virtual unsigned int addOrFind(const XMLCh* const newString);
0058     virtual bool exists(const XMLCh* const newString) const;
0059     virtual bool exists(const unsigned int id) const;
0060     virtual void flushAll();
0061     virtual unsigned int getId(const XMLCh* const toFind) const;
0062     virtual const XMLCh* getValueForId(const unsigned int id) const;
0063     virtual unsigned int getStringCount() const;
0064 
0065 
0066 private :
0067     // -----------------------------------------------------------------------
0068     //  Unimplemented constructors and operators
0069     // -----------------------------------------------------------------------
0070     XMLSynchronizedStringPool(const XMLSynchronizedStringPool&);
0071     XMLSynchronizedStringPool& operator=(const XMLSynchronizedStringPool&);
0072 
0073 
0074     // -----------------------------------------------------------------------
0075     // private data members
0076     //  fConstPool
0077     //      the pool whose immutability we're protecting
0078     // fMutex
0079     //      mutex to permit synchronous updates of our StringPool
0080     const XMLStringPool* fConstPool;
0081     XMLMutex             fMutex;
0082 };
0083 
0084 XERCES_CPP_NAMESPACE_END
0085 
0086 #endif