Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.10

XPathFactory.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #if !defined(XPATHFACTORY_HEADER_GUARD_1357924680)
17 #define XPATHFACTORY_HEADER_GUARD_1357924680
18 
19 
20 
21 // Base include file. Must be first.
23 
25 
26 #include <cassert>
27 #include <functional>
28 
29 
30 
31 XALAN_CPP_NAMESPACE_BEGIN
32 
33 
34 
35 class XPath;
36 
37 
38 
40 {
41 public:
42 
43  explicit
44  XPathFactory();
45 
46  virtual
47  ~XPathFactory();
48 
55  bool
56  returnObject(const XPath* theXPath)
57  {
58  return doReturnObject(theXPath);
59  }
60 
65  virtual void
66  reset() = 0;
67 
73  virtual XPath*
74  create() = 0;
75 
81 #if defined(XALAN_NO_STD_NAMESPACE)
82  struct DeleteXPathFunctor : public unary_function<const XPath*, void>
83 #else
84  struct DeleteXPathFunctor : public std::unary_function<const XPath*, void>
85 #endif
86  {
87  public:
88 
90  XPathFactory& theFactoryInstance,
91  bool fInReset = false) :
92  m_factoryInstance(theFactoryInstance),
93  m_fInReset(fInReset)
94  {
95  }
96 
97  result_type
98  operator()(argument_type theXPath) const
99  {
100  if (m_fInReset == true)
101  {
102  m_factoryInstance.doReturnObject(theXPath,
103  true);
104  }
105  else
106  {
107  m_factoryInstance.returnObject(theXPath);
108  }
109  }
110 
111  private:
112 
113  XPathFactory& m_factoryInstance;
114 
115  const bool m_fInReset;
116  };
117 
118  friend struct DeleteXPathFunctor;
119 
120 protected:
121 
122  virtual bool
123  doReturnObject(
124  const XPath* theXPath,
125  bool fInReset = false) = 0;
126 };
127 
128 
129 
134 {
135 public:
136 
144  XPathFactory& theFactory,
145  const XPath* theXPath) :
146  m_factory(&theFactory),
147  m_object(theXPath)
148  {
149  }
150 
151  // Note that copy construction transfers ownership, just
152  // as std::auto_ptr.
154  {
155  // Release the current object...
156  release();
157 
158  // Copy the factory and object pointers...
159  m_factory = theRHS.m_factory;
160  m_object = theRHS.m_object;
161 
162  // The source object no longer points to
163  // the object...
164  theRHS.m_factory = 0;
165  theRHS.m_object = 0;
166  }
167 
169  {
170  reset();
171  }
172 
178  const XPath*
179  operator->() const
180  {
181  assert(m_object != 0);
182 
183  return m_object;
184  }
185 
191  const XPath*
192  get() const
193  {
194  return m_object;
195  }
196 
200  void
202  {
203  if (m_object != 0)
204  {
205  assert(m_factory != 0);
206 
207  m_factory->returnObject(m_object);
208 
209  m_object = 0;
210  }
211 
212  m_factory = 0;
213  }
214 
220  const XPath*
222  {
223  const XPath* const theTemp = m_object;
224 
225  m_object = 0;
226 
227  return theTemp;
228  }
229 
230 private:
231 
232  XPathGuard&
233  operator=(const XPathGuard&);
234 
235  bool
236  operator==(const XPathGuard&) const;
237 
238 
239  // Data members...
240  XPathFactory* m_factory;
241  const XPath* m_object;
242 };
243 
244 
245 
246 XALAN_CPP_NAMESPACE_END
247 
248 
249 
250 #endif // XPATHFACTORY_HEADER_GUARD_1357924680
~XPathGuard()
Definition: XPathFactory.hpp:168
Manages the lifetime of an XPath instance.
Definition: XPathFactory.hpp:133
Definition: XPath.hpp:62
const XPath * release()
Transfers ownership of XPath to caller.
Definition: XPathFactory.hpp:221
XPathGuard(XPathGuard &theRHS)
Definition: XPathFactory.hpp:153
bool returnObject(const XPath *theXPath)
Return an XPath to the factory.
Definition: XPathFactory.hpp:56
result_type operator()(argument_type theXPath) const
Definition: XPathFactory.hpp:98
Definition: XPathFactory.hpp:39
DeleteXPathFunctor(XPathFactory &theFactoryInstance, bool fInReset=false)
Definition: XPathFactory.hpp:89
XPathGuard(XPathFactory &theFactory, const XPath *theXPath)
Construct an XPathGuard instance from a factory object and an XPath.
Definition: XPathFactory.hpp:143
#define XALAN_XPATH_EXPORT
Definition: XPathDefinitions.hpp:33
A functor for use with stl algorithms.
Definition: XPathFactory.hpp:84
const XPath * operator->() const
Retrieve the object pointer (must not be null)
Definition: XPathFactory.hpp:179
void reset()
Return the referenced object to the factory and set pointers to null.
Definition: XPathFactory.hpp:201

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