http://xml.apache.org/http://www.apache.org/http://www.w3.org/

Home

Readme
Charter
Release Info

Installation
Download
Build Instructions

FAQs
Samples
API Docs

DOM C++ Binding
Programming
Migration Guide

Feedback
Bug-Reporting
PDF Document

Source Repository
User Mail Archive
Devel Mail Archive

API Docs for SAX and DOM
 

SynchronizedStringPool.hpp

Go to the documentation of this file.
00001 /*
00002  * Copyright 1999-2004 The Apache Software Foundation.
00003  * 
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  * 
00008  *      http://www.apache.org/licenses/LICENSE-2.0
00009  * 
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 /*
00018  * $Id: SynchronizedStringPool.hpp 191054 2005-06-17 02:56:35Z jberry $
00019  */
00020 
00021 #if !defined(SYNCHRONIZEDSTRINGPOOL_HPP)
00022 #define SYNCHRONIZEDSTRINGPOOL_HPP
00023 
00024 #include <xercesc/framework/MemoryManager.hpp>
00025 #include <xercesc/util/StringPool.hpp>
00026 #include <xercesc/util/Mutexes.hpp>
00027 
00028 XERCES_CPP_NAMESPACE_BEGIN
00029 
00030 //
00031 //  This class provides a synchronized string pool implementation.
00032 //  This will necessarily be slower than the regular StringPool, so it
00033 //  should only be used when updates need to be made in a thread-safe
00034 //  way.  Updates will be made on datastructures local to this object;
00035 //  all queries that don't involve mutation will first be directed at
00036 //  the StringPool implementation with which this object is
00037 //  constructed.
00038 class  XMLSynchronizedStringPool : public XMLStringPool
00039 {
00040 public :
00041     // -----------------------------------------------------------------------
00042     //  Constructors and Destructor
00043     // -----------------------------------------------------------------------
00044     XMLSynchronizedStringPool
00045     (
00046         const XMLStringPool *  constPool
00047         , const unsigned int   modulus = 109
00048         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
00049     );
00050     virtual ~XMLSynchronizedStringPool();
00051 
00052 
00053     // -----------------------------------------------------------------------
00054     //  Pool management methods
00055     // -----------------------------------------------------------------------
00056     virtual unsigned int addOrFind(const XMLCh* const newString);
00057     virtual bool exists(const XMLCh* const newString) const;
00058     virtual bool exists(const unsigned int id) const;
00059     virtual void flushAll();
00060     virtual unsigned int getId(const XMLCh* const toFind) const;
00061     virtual const XMLCh* getValueForId(const unsigned int id) const;
00062     virtual unsigned int getStringCount() const;
00063 
00064 
00065 private :
00066     // -----------------------------------------------------------------------
00067     //  Unimplemented constructors and operators
00068     // -----------------------------------------------------------------------
00069     XMLSynchronizedStringPool(const XMLSynchronizedStringPool&);
00070     XMLSynchronizedStringPool& operator=(const XMLSynchronizedStringPool&);
00071 
00072 
00073     // -----------------------------------------------------------------------
00074     // private data members
00075     //  fConstPool
00076     //      the pool whose immutability we're protecting
00077     // fMutex
00078     //      mutex to permit synchronous updates of our StringPool
00079     const XMLStringPool* fConstPool;
00080     XMLMutex             fMutex;
00081 };
00082 
00083 XERCES_CPP_NAMESPACE_END
00084 
00085 #endif


Copyright © 1994-2004 The Apache Software Foundation. All Rights Reserved.