wxrust_base/generated/class_r.rs
1use super::*;
2
3// wxRefCounter
4wxwidgets! {
5 /// This class is used to manage reference-counting providing a simple interface and a counter.
6 /// - [`RefCounter`] represents a C++ `wxRefCounter` class instance which your code has ownership, [`RefCounterIsOwned`]`<false>` represents one which don't own.
7 /// - Use [`RefCounter`]'s `new()` to create an instance of this class.
8 /// - See [C++ `wxRefCounter` class's documentation](https://docs.wxwidgets.org/3.2/classwx_ref_counter.html) for more details.
9 #[doc(alias = "wxRefCounter")]
10 #[doc(alias = "RefCounter")]
11 class RefCounter
12 = RefCounterIsOwned<true>(wxRefCounter) impl
13 RefCounterMethods
14}
15impl<const OWNED: bool> RefCounterIsOwned<OWNED> {
16 /// Default constructor.
17 ///
18 /// See [C++ `wxRefCounter::wxRefCounter()`'s documentation](https://docs.wxwidgets.org/3.2/classwx_ref_counter.html#aebcddb8241dfea7f60f8e4df6776a0e3).
19 pub fn new() -> RefCounterIsOwned<OWNED> {
20 unsafe { RefCounterIsOwned(ffi::wxRefCounter_new()) }
21 }
22 pub fn none() -> Option<&'static Self> {
23 None
24 }
25}
26impl Clone for RefCounterIsOwned<false> {
27 fn clone(&self) -> Self {
28 Self(self.0)
29 }
30}
31impl<const OWNED: bool> Drop for RefCounterIsOwned<OWNED> {
32 fn drop(&mut self) {
33 if OWNED {
34 unsafe { ffi::wxRefCounter_delete(self.0) }
35 }
36 }
37}