Debian Codegraph @

src/common/scoped_ptr.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2005 Dizzy
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19 #ifndef PVPGN_SCOPED_PTR_H
20 #define PVPGN_SCOPED_PTR_Hcxx . . $ `src/common/scoped_ptr.h:20:9`!
21
22 #include <memory>
23
24 namespace pvpgncxx . . $ pvpgn/
25 {
26
27 template<typename T>
28 class scoped_ptrcxx . . $ pvpgn/scoped_ptr#
29 {
30 public:
31 /** initilize the object aquiring ownership of the given parameter (0 for no onwership) */
32 explicit scoped_ptrcxx . . $ pvpgn/scoped_ptr#`scoped_ptr<T>`(ebd0a1552f8ce24f).(T* ptr_ = 0)
33 :ptrcxx . . $ pvpgn/scoped_ptr#ptr.(ptr_) {}
34
35 /** initilize from a blind pointer supporting implicit conversion */
36 template<typename V>
37 explicit scoped_ptrcxx . . $ pvpgn/scoped_ptr#`scoped_ptr<T>`(7e6e718d4f0ca9be).(V* ptr_)
38 :ptrcxx . . $ pvpgn/scoped_ptr#ptr.(ptr_) {}
39
40 /** initilize the object transfering ownership from an std::unique_ptr<> */
41 template<typename V>
42 explicit scoped_ptrcxx . . $ pvpgn/scoped_ptr#`scoped_ptr<T>`(b63c835b17144dcb).(stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<V>& aptr)
43 :ptrcxx . . $ pvpgn/scoped_ptr#ptr.(aptr.releasecxx . . $ std/unique_ptr#release(aad4c3669c5e940c).()) {}
44
45 /** release memory if aquired ownershipt */
46 ~cxx . . $ pvpgn/scoped_ptr#`~scoped_ptr<T>`(ced63f7c635d850d).scoped_ptr() throw() {
47 cleanupcxx . . $ pvpgn/scoped_ptr#cleanup(49f6e7a06ebc5aa8).();
48 }
49
50 /** get the wrapped pointer */
51 T* getcxx . . $ pvpgn/scoped_ptr#get(5a2a78a048fb49a8).() const { return ptrcxx . . $ pvpgn/scoped_ptr#ptr.; }
52
53 /** release ownership of the memory */
54 T* releasecxx . . $ pvpgn/scoped_ptr#release(155dc7f103cdb9db).() {
55 T* tmp = ptrcxx . . $ pvpgn/scoped_ptr#ptr.;
56 ptrcxx . . $ pvpgn/scoped_ptr#ptr. = 0;
57 return tmp;
58 }
59
60 /** reinitilize object, release owned resource first if any */
61 void resetcxx . . $ pvpgn/scoped_ptr#reset(ebd0a1552f8ce24f).(T* ptr_ = 0) {
62 cleanupcxx . . $ pvpgn/scoped_ptr#cleanup(49f6e7a06ebc5aa8).();
63 ptrcxx . . $ pvpgn/scoped_ptr#ptr. = ptr_;
64 }
65
66 /** reinitilize object, supports implicit conversions */
67 template<typename V>
68 void resetcxx . . $ pvpgn/scoped_ptr#reset(7e6e718d4f0ca9be).(V* ptr_) {
69 cleanupcxx . . $ pvpgn/scoped_ptr#cleanup(49f6e7a06ebc5aa8).();
70 ptrcxx . . $ pvpgn/scoped_ptr#ptr. = ptr_;
71 }
72
73 /** const-dereference of the wrapped pointer */
74 const T& operatorcxx . . $ pvpgn/scoped_ptr#`operator*`(ea465e50d690edfe).*() const {
75 return *ptrcxx . . $ pvpgn/scoped_ptr#ptr.;
76 }
77
78 /** dereference of the wrapped pointer */
79 T& operatorcxx . . $ pvpgn/scoped_ptr#`operator*`(19b2b6f17af048b).*() {
80 return *ptrcxx . . $ pvpgn/scoped_ptr#ptr.;
81 }
82
83 /** const-member access to the wrapped pointer */
84 const T* operatorcxx . . $ pvpgn/scoped_ptr#`operator->`(1016ee5406d91ab9).->() const {
85 return ptrcxx . . $ pvpgn/scoped_ptr#ptr.;
86 }
87
88 /** member access to the wrapped pointer */
89 T* operatorcxx . . $ pvpgn/scoped_ptr#`operator->`(155dc7f103cdb9db).->() {
90 return ptrcxx . . $ pvpgn/scoped_ptr#ptr.;
91 }
92
93 private:
94 T* ptrcxx . . $ pvpgn/scoped_ptr#ptr.;
95
96 /* do not allow to copy a scoped_ptr (use std::unique_ptr<> if you need that) */
97 scoped_ptrcxx . . $ pvpgn/scoped_ptr#`scoped_ptr<T>`(ff0a8d043271261).(const scoped_ptr&);
98 scoped_ptr& operatorcxx . . $ pvpgn/scoped_ptr#`operator=`(d3cc876436e4ad6b).=(const scoped_ptr&);
99
100 void cleanupcxx . . $ pvpgn/scoped_ptr#cleanup(49f6e7a06ebc5aa8).() {
101 delete ptrcxx . . $ pvpgn/scoped_ptr#ptr.;
102 }
103 };
104
105 }
106
107 #endif