1 /** 2 * @copyright 3 * ==================================================================== 4 * Licensed to the Apache Software Foundation (ASF) under one 5 * or more contributor license agreements. See the NOTICE file 6 * distributed with this work for additional information 7 * regarding copyright ownership. The ASF licenses this file 8 * to you under the Apache License, Version 2.0 (the 9 * "License"); you may not use this file except in compliance 10 * with the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, 15 * software distributed under the License is distributed on an 16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 * KIND, either express or implied. See the License for the 18 * specific language governing permissions and limitations 19 * under the License. 20 * ==================================================================== 21 * @endcopyright 22 * 23 * @file Pool.h 24 * @brief Interface of the class Pool 25 */ 26 27 #ifndef POOL_H 28 #define POOL_H 29 30 #include "svn_pools.h" 31 32 namespace SVN { 33 /** 34 * This class manages one APR pool. Objects of this class are 35 * allocated on the stack of the SVNClient and SVNAdmin methods as the 36 * request pool. Leaving the methods will destroy the pool. 37 */ 38 class Pool 39 { 40 public: 41 Pool(); 42 explicit Pool(const Pool &parent_pool); 43 Pool(apr_pool_t *parent_pool); 44 ~Pool(); 45 apr_pool_t *getPool() const; 46 void clear() const; 47 48 private: 49 /** 50 * The apr pool request pool. 51 */ 52 apr_pool_t *m_pool; 53 54 /** 55 * We declare the assignment operator private here, so that the compiler 56 * won't inadvertently use them for us. 57 * The default code just copies all the data members, which would create 58 * two pointers to the same pool, one of which would get destroyed while 59 * the other thought it was still valid...and BOOM! 60 * 61 * Hence the private declaration. 62 */ 63 Pool &operator=(Pool &that); 64 }; 65 66 // The following one-line functions are best inlined by the compiler, and 67 // need to be implemented in the header file for that to happen. 68 69 inline getPool()70 apr_pool_t *Pool::getPool() const 71 { 72 return m_pool; 73 } 74 75 inline clear()76 void Pool::clear() const 77 { 78 svn_pool_clear(m_pool); 79 } 80 } 81 82 83 #endif // POOL_H 84