Xalan-C++ API Documentation

The Xalan C++ XSL Transformer Version 1.1

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

XPathFactory.hpp

Go to the documentation of this file.
00001 /*
00002  * The Apache Software License, Version 1.1
00003  *
00004  *
00005  * Copyright (c) 1999 The Apache Software Foundation.  All rights 
00006  * reserved.
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted provided that the following conditions
00010  * are met:
00011  *
00012  * 1. Redistributions of source code must retain the above copyright
00013  *    notice, this list of conditions and the following disclaimer. 
00014  *
00015  * 2. Redistributions in binary form must reproduce the above copyright
00016  *    notice, this list of conditions and the following disclaimer in
00017  *    the documentation and/or other materials provided with the
00018  *    distribution.
00019  *
00020  * 3. The end-user documentation included with the redistribution,
00021  *    if any, must include the following acknowledgment:  
00022  *       "This product includes software developed by the
00023  *        Apache Software Foundation (http://www.apache.org/)."
00024  *    Alternately, this acknowledgment may appear in the software itself,
00025  *    if and wherever such third-party acknowledgments normally appear.
00026  *
00027  * 4. The names "Xalan" and "Apache Software Foundation" must
00028  *    not be used to endorse or promote products derived from this
00029  *    software without prior written permission. For written 
00030  *    permission, please contact apache@apache.org.
00031  *
00032  * 5. Products derived from this software may not be called "Apache",
00033  *    nor may "Apache" appear in their name, without prior written
00034  *    permission of the Apache Software Foundation.
00035  *
00036  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
00037  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00038  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00039  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
00040  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00041  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00042  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
00043  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00044  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00045  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
00046  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00047  * SUCH DAMAGE.
00048  * ====================================================================
00049  *
00050  * This software consists of voluntary contributions made by many
00051  * individuals on behalf of the Apache Software Foundation and was
00052  * originally based on software copyright (c) 1999, International
00053  * Business Machines, Inc., http://www.ibm.com.  For more
00054  * information on the Apache Software Foundation, please see
00055  * <http://www.apache.org/>.
00056  */
00057 #if !defined(XPATHFACTORY_HEADER_GUARD_1357924680)
00058 #define XPATHFACTORY_HEADER_GUARD_1357924680
00059 
00060 
00061 
00062 // Base include file.  Must be first.
00063 #include <XPath/XPathDefinitions.hpp>
00064 
00065 
00066 
00067 #include <cassert>
00068 #include <functional>
00069 
00070 
00071 
00072 class XPath;
00073 
00074 
00075 
00076 class XALAN_XPATH_EXPORT XPathFactory
00077 {
00078 public:
00079 
00080     explicit
00081     XPathFactory();
00082 
00083     virtual
00084     ~XPathFactory();
00085 
00092     bool
00093     returnObject(const XPath*   theXPath)
00094     {
00095         return doReturnObject(theXPath);
00096     }
00097 
00102     virtual void
00103     reset() = 0;
00104 
00110     virtual XPath*
00111     create() = 0;
00112 
00118 #if defined(XALAN_NO_NAMESPACES)
00119     struct DeleteXPathFunctor : public unary_function<const XPath*, void>
00120 #else
00121     struct DeleteXPathFunctor : public std::unary_function<const XPath*, void>
00122 #endif
00123     {
00124     public:
00125 
00126         DeleteXPathFunctor(
00127             XPathFactory&       theFactoryInstance,
00128             bool                fInReset = false) :
00129             m_factoryInstance(theFactoryInstance),
00130             m_fInReset(fInReset)
00131         {
00132         }
00133 
00134         result_type
00135         operator()(argument_type    theXPath) const
00136         {
00137             if (m_fInReset == true)
00138             {
00139                 m_factoryInstance.doReturnObject(theXPath,
00140                                                  true);
00141             }
00142             else
00143             {
00144                 m_factoryInstance.returnObject(theXPath);
00145             }
00146         }
00147 
00148     private:
00149 
00150         XPathFactory&       m_factoryInstance;
00151 
00152         const bool          m_fInReset;
00153     };
00154 
00155     friend struct DeleteXPathFunctor;
00156 
00157 protected:
00158 
00159     virtual bool
00160     doReturnObject(
00161             const XPath*    theXPath,
00162             bool            fInReset = false) = 0;
00163 };
00164 
00165 
00166 
00170 class XPathGuard
00171 {
00172 public:
00173 
00180     XPathGuard(
00181             XPathFactory&   theFactory,
00182             const XPath*    theXPath) :
00183         m_factory(&theFactory),
00184         m_object(theXPath)
00185     {
00186     }
00187 
00188     // Note that copy construction transfers ownership, just
00189     // as std::auto_ptr.
00190     XPathGuard(XPathGuard&  theRHS)
00191     {
00192         // Release the current object...
00193         release();
00194 
00195         // Copy the factory and object pointers...
00196         m_factory = theRHS.m_factory;
00197         m_object = theRHS.m_object;
00198 
00199         // The source object no longer points to
00200         // the object...
00201         theRHS.m_factory = 0;
00202         theRHS.m_object = 0;
00203     }
00204 
00205     ~XPathGuard()
00206     {
00207         reset();
00208     }
00209 
00215     const XPath*
00216     operator->() const
00217     {
00218         assert(m_object != 0);
00219 
00220         return m_object;
00221     }
00222 
00228     const XPath*
00229     get() const
00230     {
00231         return m_object;
00232     }
00233 
00237     void
00238     reset()
00239     {
00240         if (m_object != 0)
00241         {
00242             assert(m_factory != 0);
00243 
00244             m_factory->returnObject(m_object);
00245 
00246             m_object = 0;
00247         }
00248 
00249         m_factory = 0;
00250     }
00251 
00257     const XPath*
00258     release()
00259     {
00260         const XPath* const  theTemp = m_object;
00261 
00262         m_object = 0;
00263 
00264         return theTemp;
00265     }
00266 
00267 private:
00268 
00269     XPathGuard&
00270     operator=(const XPathGuard&);
00271 
00272     bool
00273     operator==(const XPathGuard&) const;
00274 
00275 
00276     // Data members...
00277     XPathFactory*   m_factory;
00278     const XPath*    m_object;
00279 };
00280 
00281 #endif  // XPATHFACTORY_HEADER_GUARD_1357924680

Interpreting class diagrams

Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.

Xalan-C++ XSL Transformer Version 1.1
Copyright © 2000, 2001 The Apache Software Foundation. All Rights Reserved.