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

Home

Readme
Release Info

Installation
Download
Build

FAQs
Samples
API Docs

DOM C++ Binding
Programming
Migration Guide

Feedback
Bug-Reporting
PDF Document

CVS Repository
Mail Archive

API Docs for SAX and DOM
 

Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

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


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