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