Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.10

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  * 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 #if !defined(XPATHFACTORY_HEADER_GUARD_1357924680)
00017 #define XPATHFACTORY_HEADER_GUARD_1357924680
00018 
00019 
00020 
00021 // Base include file.  Must be first.
00022 #include <xalanc/XPath/XPathDefinitions.hpp>
00023 
00024 #include <xalanc/Include/XalanMemoryManagement.hpp>
00025 
00026 #include <cassert>
00027 #include <functional>
00028 
00029 
00030 
00031 XALAN_CPP_NAMESPACE_BEGIN
00032 
00033 
00034 
00035 class XPath;
00036 
00037 
00038 
00039 class XALAN_XPATH_EXPORT XPathFactory
00040 {
00041 public:
00042 
00043     explicit
00044     XPathFactory();
00045 
00046     virtual
00047     ~XPathFactory();
00048 
00055     bool
00056     returnObject(const XPath*   theXPath)
00057     {
00058         return doReturnObject(theXPath);
00059     }
00060 
00065     virtual void
00066     reset() = 0;
00067 
00073     virtual XPath*
00074     create() = 0;
00075 
00081 #if defined(XALAN_NO_STD_NAMESPACE)
00082     struct DeleteXPathFunctor : public unary_function<const XPath*, void>
00083 #else
00084     struct DeleteXPathFunctor : public std::unary_function<const XPath*, void>
00085 #endif
00086     {
00087     public:
00088 
00089         DeleteXPathFunctor(
00090             XPathFactory&       theFactoryInstance,
00091             bool                fInReset = false) :
00092             m_factoryInstance(theFactoryInstance),
00093             m_fInReset(fInReset)
00094         {
00095         }
00096 
00097         result_type
00098         operator()(argument_type    theXPath) const
00099         {
00100             if (m_fInReset == true)
00101             {
00102                 m_factoryInstance.doReturnObject(theXPath,
00103                                                  true);
00104             }
00105             else
00106             {
00107                 m_factoryInstance.returnObject(theXPath);
00108             }
00109         }
00110 
00111     private:
00112 
00113         XPathFactory&       m_factoryInstance;
00114 
00115         const bool          m_fInReset;
00116     };
00117 
00118     friend struct DeleteXPathFunctor;
00119 
00120 protected:
00121 
00122     virtual bool
00123     doReturnObject(
00124             const XPath*    theXPath,
00125             bool            fInReset = false) = 0;
00126 };
00127 
00128 
00129 
00133 class XPathGuard
00134 {
00135 public:
00136 
00143     XPathGuard(
00144             XPathFactory&   theFactory,
00145             const XPath*    theXPath) :
00146         m_factory(&theFactory),
00147         m_object(theXPath)
00148     {
00149     }
00150 
00151     // Note that copy construction transfers ownership, just
00152     // as std::auto_ptr.
00153     XPathGuard(XPathGuard&  theRHS)
00154     {
00155         // Release the current object...
00156         release();
00157 
00158         // Copy the factory and object pointers...
00159         m_factory = theRHS.m_factory;
00160         m_object = theRHS.m_object;
00161 
00162         // The source object no longer points to
00163         // the object...
00164         theRHS.m_factory = 0;
00165         theRHS.m_object = 0;
00166     }
00167 
00168     ~XPathGuard()
00169     {
00170         reset();
00171     }
00172 
00178     const XPath*
00179     operator->() const
00180     {
00181         assert(m_object != 0);
00182 
00183         return m_object;
00184     }
00185 
00191     const XPath*
00192     get() const
00193     {
00194         return m_object;
00195     }
00196 
00200     void
00201     reset()
00202     {
00203         if (m_object != 0)
00204         {
00205             assert(m_factory != 0);
00206 
00207             m_factory->returnObject(m_object);
00208 
00209             m_object = 0;
00210         }
00211 
00212         m_factory = 0;
00213     }
00214 
00220     const XPath*
00221     release()
00222     {
00223         const XPath* const  theTemp = m_object;
00224 
00225         m_object = 0;
00226 
00227         return theTemp;
00228     }
00229 
00230 private:
00231 
00232     XPathGuard&
00233     operator=(const XPathGuard&);
00234 
00235     bool
00236     operator==(const XPathGuard&) const;
00237 
00238 
00239     // Data members...
00240     XPathFactory*   m_factory;
00241     const XPath*    m_object;
00242 };
00243 
00244 
00245 
00246 XALAN_CPP_NAMESPACE_END
00247 
00248 
00249 
00250 #endif  // XPATHFACTORY_HEADER_GUARD_1357924680

Interpreting class diagrams

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

dot

Xalan-C++ XSLT Processor Version 1.10
Copyright © 1999-2004 The Apache Software Foundation. All Rights Reserved.

Apache Logo