OLD | NEW |
| 1 // This file was GENERATED by command: |
| 2 // pump.py refcount.h.pump |
| 3 // DO NOT EDIT BY HAND!!! |
| 4 |
1 /* | 5 /* |
2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. | 6 * Copyright 2011 The WebRTC Project Authors. All rights reserved. |
3 * | 7 * |
4 * Use of this source code is governed by a BSD-style license | 8 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 9 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 10 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 11 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 12 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 13 */ |
10 | 14 |
| 15 // To generate refcount.h from refcount.h.pump, execute: |
| 16 // ./testing/gtest/scripts/pump.py ./webrtc/base/refcount.h.pump |
| 17 |
11 #ifndef WEBRTC_BASE_REFCOUNT_H_ | 18 #ifndef WEBRTC_BASE_REFCOUNT_H_ |
12 #define WEBRTC_BASE_REFCOUNT_H_ | 19 #define WEBRTC_BASE_REFCOUNT_H_ |
13 | 20 |
14 #include <string.h> | 21 #include <string.h> |
15 #include <utility> | 22 #include <utility> |
16 | 23 |
17 #include "webrtc/base/atomicops.h" | 24 #include "webrtc/base/atomicops.h" |
18 | 25 |
19 namespace rtc { | 26 namespace rtc { |
20 | 27 |
21 // Reference count interface. | 28 // Reference count interface. |
22 class RefCountInterface { | 29 class RefCountInterface { |
23 public: | 30 public: |
24 virtual int AddRef() const = 0; | 31 virtual int AddRef() const = 0; |
25 virtual int Release() const = 0; | 32 virtual int Release() const = 0; |
26 | 33 |
27 protected: | 34 protected: |
28 virtual ~RefCountInterface() {} | 35 virtual ~RefCountInterface() {} |
29 }; | 36 }; |
30 | 37 |
31 template <class T> | 38 template <class T> |
32 class RefCountedObject : public T { | 39 class RefCountedObject : public T { |
33 public: | 40 public: |
34 RefCountedObject() {} | 41 RefCountedObject() {} |
35 | 42 |
36 template <typename P> | 43 template <class P0> |
37 explicit RefCountedObject(const P& p) : T(p) {} | 44 explicit RefCountedObject(P0&& p0) : T(std::forward<P0>(p0)) {} |
38 | 45 template <class P0, class P1> |
39 template <typename P> | 46 RefCountedObject(P0&& p0, P1&& p1) |
40 explicit RefCountedObject(P&& p) : T(std::move(p)) {} | 47 : T(std::forward<P0>(p0), std::forward<P1>(p1)) {} |
41 | 48 template <class P0, class P1, class P2> |
42 template <typename P1, typename P2> | 49 RefCountedObject(P0&& p0, P1&& p1, P2&& p2) |
43 RefCountedObject(P1 p1, P2 p2) : T(p1, p2) {} | 50 : T(std::forward<P0>(p0), std::forward<P1>(p1), std::forward<P2>(p2)) {} |
44 | 51 template <class P0, class P1, class P2, class P3> |
45 template <typename P1, typename P2, typename P3> | 52 RefCountedObject(P0&& p0, P1&& p1, P2&& p2, P3&& p3) |
46 RefCountedObject(P1 p1, P2 p2, P3 p3) : T(p1, p2, p3) {} | 53 : T(std::forward<P0>(p0), |
47 | 54 std::forward<P1>(p1), |
48 template <typename P1, typename P2, typename P3, typename P4> | 55 std::forward<P2>(p2), |
49 RefCountedObject(P1 p1, P2 p2, P3 p3, P4 p4) : T(p1, p2, p3, p4) {} | 56 std::forward<P3>(p3)) {} |
50 | 57 template <class P0, class P1, class P2, class P3, class P4> |
51 template <typename P1, typename P2, typename P3, typename P4, typename P5> | 58 RefCountedObject(P0&& p0, P1&& p1, P2&& p2, P3&& p3, P4&& p4) |
52 RefCountedObject(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) : T(p1, p2, p3, p4, p5) {} | 59 : T(std::forward<P0>(p0), |
53 | 60 std::forward<P1>(p1), |
54 template <typename P1, | 61 std::forward<P2>(p2), |
55 typename P2, | 62 std::forward<P3>(p3), |
56 typename P3, | 63 std::forward<P4>(p4)) {} |
57 typename P4, | 64 template <class P0, class P1, class P2, class P3, class P4, class P5> |
58 typename P5, | 65 RefCountedObject(P0&& p0, P1&& p1, P2&& p2, P3&& p3, P4&& p4, P5&& p5) |
59 typename P6> | 66 : T(std::forward<P0>(p0), |
60 RefCountedObject(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6) | 67 std::forward<P1>(p1), |
61 : T(p1, p2, p3, p4, p5, p6) {} | 68 std::forward<P2>(p2), |
62 | 69 std::forward<P3>(p3), |
63 template <typename P1, | 70 std::forward<P4>(p4), |
64 typename P2, | 71 std::forward<P5>(p5)) {} |
65 typename P3, | 72 template <class P0, |
66 typename P4, | 73 class P1, |
67 typename P5, | 74 class P2, |
68 typename P6, | 75 class P3, |
69 typename P7> | 76 class P4, |
70 RefCountedObject(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7) | 77 class P5, |
71 : T(p1, p2, p3, p4, p5, p6, p7) {} | 78 class P6> |
72 | 79 RefCountedObject(P0&& p0, |
73 template <typename P1, | 80 P1&& p1, |
74 typename P2, | 81 P2&& p2, |
75 typename P3, | 82 P3&& p3, |
76 typename P4, | 83 P4&& p4, |
77 typename P5, | 84 P5&& p5, |
78 typename P6, | 85 P6&& p6) |
79 typename P7, | 86 : T(std::forward<P0>(p0), |
80 typename P8> | 87 std::forward<P1>(p1), |
81 RefCountedObject(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) | 88 std::forward<P2>(p2), |
82 : T(p1, p2, p3, p4, p5, p6, p7, p8) {} | 89 std::forward<P3>(p3), |
83 | 90 std::forward<P4>(p4), |
84 template <typename P1, | 91 std::forward<P5>(p5), |
85 typename P2, | 92 std::forward<P6>(p6)) {} |
86 typename P3, | 93 template <class P0, |
87 typename P4, | 94 class P1, |
88 typename P5, | 95 class P2, |
89 typename P6, | 96 class P3, |
90 typename P7, | 97 class P4, |
91 typename P8, | 98 class P5, |
92 typename P9> | 99 class P6, |
93 RefCountedObject(P1 p1, | 100 class P7> |
94 P2 p2, | 101 RefCountedObject(P0&& p0, |
95 P3 p3, | 102 P1&& p1, |
96 P4 p4, | 103 P2&& p2, |
97 P5 p5, | 104 P3&& p3, |
98 P6 p6, | 105 P4&& p4, |
99 P7 p7, | 106 P5&& p5, |
100 P8 p8, | 107 P6&& p6, |
101 P9 p9) | 108 P7&& p7) |
102 : T(p1, p2, p3, p4, p5, p6, p7, p8, p9) {} | 109 : T(std::forward<P0>(p0), |
103 | 110 std::forward<P1>(p1), |
104 template <typename P1, | 111 std::forward<P2>(p2), |
105 typename P2, | 112 std::forward<P3>(p3), |
106 typename P3, | 113 std::forward<P4>(p4), |
107 typename P4, | 114 std::forward<P5>(p5), |
108 typename P5, | 115 std::forward<P6>(p6), |
109 typename P6, | 116 std::forward<P7>(p7)) {} |
110 typename P7, | 117 template <class P0, |
111 typename P8, | 118 class P1, |
112 typename P9, | 119 class P2, |
113 typename P10> | 120 class P3, |
114 RefCountedObject(P1 p1, | 121 class P4, |
115 P2 p2, | 122 class P5, |
116 P3 p3, | 123 class P6, |
117 P4 p4, | 124 class P7, |
118 P5 p5, | 125 class P8> |
119 P6 p6, | 126 RefCountedObject(P0&& p0, |
120 P7 p7, | 127 P1&& p1, |
121 P8 p8, | 128 P2&& p2, |
122 P9 p9, | 129 P3&& p3, |
123 P10 p10) | 130 P4&& p4, |
124 : T(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) {} | 131 P5&& p5, |
125 | 132 P6&& p6, |
126 template <typename P1, | 133 P7&& p7, |
127 typename P2, | 134 P8&& p8) |
128 typename P3, | 135 : T(std::forward<P0>(p0), |
129 typename P4, | 136 std::forward<P1>(p1), |
130 typename P5, | 137 std::forward<P2>(p2), |
131 typename P6, | 138 std::forward<P3>(p3), |
132 typename P7, | 139 std::forward<P4>(p4), |
133 typename P8, | 140 std::forward<P5>(p5), |
134 typename P9, | 141 std::forward<P6>(p6), |
135 typename P10, | 142 std::forward<P7>(p7), |
136 typename P11> | 143 std::forward<P8>(p8)) {} |
137 RefCountedObject(P1 p1, | 144 template <class P0, |
138 P2 p2, | 145 class P1, |
139 P3 p3, | 146 class P2, |
140 P4 p4, | 147 class P3, |
141 P5 p5, | 148 class P4, |
142 P6 p6, | 149 class P5, |
143 P7 p7, | 150 class P6, |
144 P8 p8, | 151 class P7, |
145 P9 p9, | 152 class P8, |
146 P10 p10, | 153 class P9> |
147 P11 p11) | 154 RefCountedObject(P0&& p0, |
148 : T(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11) {} | 155 P1&& p1, |
| 156 P2&& p2, |
| 157 P3&& p3, |
| 158 P4&& p4, |
| 159 P5&& p5, |
| 160 P6&& p6, |
| 161 P7&& p7, |
| 162 P8&& p8, |
| 163 P9&& p9) |
| 164 : T(std::forward<P0>(p0), |
| 165 std::forward<P1>(p1), |
| 166 std::forward<P2>(p2), |
| 167 std::forward<P3>(p3), |
| 168 std::forward<P4>(p4), |
| 169 std::forward<P5>(p5), |
| 170 std::forward<P6>(p6), |
| 171 std::forward<P7>(p7), |
| 172 std::forward<P8>(p8), |
| 173 std::forward<P9>(p9)) {} |
| 174 template <class P0, |
| 175 class P1, |
| 176 class P2, |
| 177 class P3, |
| 178 class P4, |
| 179 class P5, |
| 180 class P6, |
| 181 class P7, |
| 182 class P8, |
| 183 class P9, |
| 184 class P10> |
| 185 RefCountedObject(P0&& p0, |
| 186 P1&& p1, |
| 187 P2&& p2, |
| 188 P3&& p3, |
| 189 P4&& p4, |
| 190 P5&& p5, |
| 191 P6&& p6, |
| 192 P7&& p7, |
| 193 P8&& p8, |
| 194 P9&& p9, |
| 195 P10&& p10) |
| 196 : T(std::forward<P0>(p0), |
| 197 std::forward<P1>(p1), |
| 198 std::forward<P2>(p2), |
| 199 std::forward<P3>(p3), |
| 200 std::forward<P4>(p4), |
| 201 std::forward<P5>(p5), |
| 202 std::forward<P6>(p6), |
| 203 std::forward<P7>(p7), |
| 204 std::forward<P8>(p8), |
| 205 std::forward<P9>(p9), |
| 206 std::forward<P10>(p10)) {} |
149 | 207 |
150 virtual int AddRef() const { return AtomicOps::Increment(&ref_count_); } | 208 virtual int AddRef() const { return AtomicOps::Increment(&ref_count_); } |
151 | 209 |
152 virtual int Release() const { | 210 virtual int Release() const { |
153 int count = AtomicOps::Decrement(&ref_count_); | 211 int count = AtomicOps::Decrement(&ref_count_); |
154 if (!count) { | 212 if (!count) { |
155 delete this; | 213 delete this; |
156 } | 214 } |
157 return count; | 215 return count; |
158 } | 216 } |
(...skipping 10 matching lines...) Expand all Loading... |
169 | 227 |
170 protected: | 228 protected: |
171 virtual ~RefCountedObject() {} | 229 virtual ~RefCountedObject() {} |
172 | 230 |
173 mutable volatile int ref_count_ = 0; | 231 mutable volatile int ref_count_ = 0; |
174 }; | 232 }; |
175 | 233 |
176 } // namespace rtc | 234 } // namespace rtc |
177 | 235 |
178 #endif // WEBRTC_BASE_REFCOUNT_H_ | 236 #endif // WEBRTC_BASE_REFCOUNT_H_ |
OLD | NEW |