Xerces-C++: SynchronizedStringPool.hpp Source File

- Main Page
- Related Pages
- Classes
- Files

# SynchronizedStringPool.hpp

Go to the documentation of this file.

    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: SynchronizedStringPool.hpp 527149 2007-04-10 14:56:39Z amassari $
    00020  */
    00021
    00022 #if !defined(XERCESC_INCLUDE_GUARD_SYNCHRONIZEDSTRINGPOOL_HPP)
    00023 #define XERCESC_INCLUDE_GUARD_SYNCHRONIZEDSTRINGPOOL_HPP
    00024
    00025 #include <xercesc/framework/MemoryManager.hpp>
    00026 #include <xercesc/util/StringPool.hpp>
    00027 #include <xercesc/util/Mutexes.hpp>
    00028
    00029 XERCES_CPP_NAMESPACE_BEGIN
    00030
    00031 //
    00032 //  This class provides a synchronized string pool implementation.
    00033 //  This will necessarily be slower than the regular XMLStringPool, so it
    00034 //  should only be used when updates need to be made in a thread-safe
    00035 //  way.  Updates will be made on datastructures local to this object;
    00036 //  all queries that don't involve mutation will first be directed at
    00037 //  the XMLStringPool implementation with which this object is
    00038 //  constructed.
    00039 class XMLUTIL_EXPORT XMLSynchronizedStringPool : public XMLStringPool
    00040 {
    00041 public :
    00042     // -----------------------------------------------------------------------
    00043     //  Constructors and Destructor
    00044     // -----------------------------------------------------------------------
    00045     XMLSynchronizedStringPool
    00046     (
    00047         const XMLStringPool *  constPool
    00048         , const unsigned int   modulus = 109
    00049         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
    00050     );
    00051     virtual ~XMLSynchronizedStringPool();
    00052
    00053
    00054     // -----------------------------------------------------------------------
    00055     //  Pool management methods
    00056     // -----------------------------------------------------------------------
    00057     virtual unsigned int addOrFind(const XMLCh* const newString);
    00058     virtual bool exists(const XMLCh* const newString) const;
    00059     virtual bool exists(const unsigned int id) const;
    00060     virtual void flushAll();
    00061     virtual unsigned int getId(const XMLCh* const toFind) const;
    00062     virtual const XMLCh* getValueForId(const unsigned int id) const;
    00063     virtual unsigned int getStringCount() const;
    00064
    00065
    00066 private :
    00067     // -----------------------------------------------------------------------
    00068     //  Unimplemented constructors and operators
    00069     // -----------------------------------------------------------------------
    00070     XMLSynchronizedStringPool(const XMLSynchronizedStringPool&);
    00071     XMLSynchronizedStringPool& operator=(const XMLSynchronizedStringPool&);
    00072
    00073
    00074     // -----------------------------------------------------------------------
    00075     // private data members
    00076     //  fConstPool
    00077     //      the pool whose immutability we're protecting
    00078     // fMutex
    00079     //      mutex to permit synchronous updates of our StringPool
    00080     const XMLStringPool* fConstPool;
    00081     XMLMutex             fMutex;
    00082 };
    00083
    00084 XERCES_CPP_NAMESPACE_END
    00085
    00086 #endif