Xalan-C++ API Documentation

The Xalan-C++ XSL Transformer Version 1.0

Main Page   Namespace List   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 
00111     virtual XPath*
00112     create(bool     fOptimize = true) = 0;
00113 
00119 #if defined(XALAN_NO_NAMESPACES)
00120     struct DeleteXPathFunctor : public unary_function<const XPath*, void>
00121 #else
00122     struct DeleteXPathFunctor : public std::unary_function<const XPath*, void>
00123 #endif
00124     {
00125     public:
00126 
00127         DeleteXPathFunctor(
00128             XPathFactory&       theFactoryInstance,
00129             bool                fInReset = false) :
00130             m_factoryInstance(theFactoryInstance),
00131             m_fInReset(fInReset)
00132         {
00133         }
00134 
00135         result_type
00136         operator()(argument_type    theXPath) const
00137         {
00138             if (m_fInReset == true)
00139             {
00140                 m_factoryInstance.doReturnObject(theXPath,
00141                                                  true);
00142             }
00143             else
00144             {
00145                 m_factoryInstance.returnObject(theXPath);
00146             }
00147         }
00148 
00149     private:
00150 
00151         XPathFactory&       m_factoryInstance;
00152 
00153         const bool          m_fInReset;
00154     };
00155 
00156     friend struct DeleteXPathFunctor;
00157 
00158 protected:
00159 
00160     virtual bool
00161     doReturnObject(
00162             const XPath*    theXPath,
00163             bool            fInReset = false) = 0;
00164 };
00165 
00166 
00167 
00171 class XPathGuard
00172 {
00173 public:
00174 
00181     XPathGuard(
00182             XPathFactory&   theFactory,
00183             const XPath*    theXPath) :
00184         m_factory(&theFactory),
00185         m_object(theXPath)
00186     {
00187     }
00188 
00189     // Note that copy construction transfers ownership, just
00190     // as std::auto_ptr.
00191     XPathGuard(XPathGuard&  theRHS)
00192     {
00193         // Release the current object...
00194         release();
00195 
00196         // Copy the factory and object pointers...
00197         m_factory = theRHS.m_factory;
00198         m_object = theRHS.m_object;
00199 
00200         // The source object no longer points to
00201         // the object...
00202         theRHS.m_factory = 0;
00203         theRHS.m_object = 0;
00204     }
00205 
00206     ~XPathGuard()
00207     {
00208         reset();
00209     }
00210 
00216     const XPath*
00217     operator->() const
00218     {
00219         assert(m_object != 0);
00220 
00221         return m_object;
00222     }
00223 
00229     const XPath*
00230     get() const
00231     {
00232         return m_object;
00233     }
00234 
00238     void
00239     reset()
00240     {
00241         if (m_object != 0)
00242         {
00243             assert(m_factory != 0);
00244 
00245             m_factory->returnObject(m_object);
00246 
00247             m_object = 0;
00248         }
00249 
00250         m_factory = 0;
00251     }
00252 
00258     const XPath*
00259     release()
00260     {
00261         const XPath* const  theTemp = m_object;
00262 
00263         m_object = 0;
00264 
00265         return theTemp;
00266     }
00267 
00268 private:
00269 
00270     XPathGuard&
00271     operator=(const XPathGuard&);
00272 
00273     bool
00274     operator==(const XPathGuard&) const;
00275 
00276 
00277     // Data members...
00278     XPathFactory*   m_factory;
00279     const XPath*    m_object;
00280 };
00281 
00282 #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.0
Copyright © 2000 The Apache Software Foundation. All Rights Reserved.