objc2_gameplay_kit/generated/
GKRTree.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9/// Used to adjust the way in which RTree nodes are split when they grow too large.
10///
11/// See also [Apple's documentation](https://developer.apple.com/documentation/gameplaykit/gkrtreesplitstrategy?language=objc)
12// NS_ENUM
13#[repr(transparent)]
14#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
15pub struct GKRTreeSplitStrategy(pub NSInteger);
16impl GKRTreeSplitStrategy {
17    #[doc(alias = "GKRTreeSplitStrategyHalve")]
18    pub const Halve: Self = Self(0);
19    #[doc(alias = "GKRTreeSplitStrategyLinear")]
20    pub const Linear: Self = Self(1);
21    #[doc(alias = "GKRTreeSplitStrategyQuadratic")]
22    pub const Quadratic: Self = Self(2);
23    #[doc(alias = "GKRTreeSplitStrategyReduceOverlap")]
24    pub const ReduceOverlap: Self = Self(3);
25}
26
27unsafe impl Encode for GKRTreeSplitStrategy {
28    const ENCODING: Encoding = NSInteger::ENCODING;
29}
30
31unsafe impl RefEncode for GKRTreeSplitStrategy {
32    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
33}
34
35extern_class!(
36    /// An R-tree is a data structure that partitions axis aligned bounding rectangles into groups spatially.
37    /// When a group goes to large, it is split according to its split strategy into two new groups.
38    /// Fast queries can be made on these partition bounding rectangles.
39    ///
40    /// See also [Apple's documentation](https://developer.apple.com/documentation/gameplaykit/gkrtree?language=objc)
41    #[unsafe(super(NSObject))]
42    #[derive(Debug, PartialEq, Eq, Hash)]
43    pub struct GKRTree<ElementType: ?Sized = AnyObject>;
44);
45
46impl<ElementType: ?Sized + Message + AsRef<NSObject>> GKRTree<ElementType> {
47    /// Unchecked conversion of the generic parameter.
48    ///
49    /// # Safety
50    ///
51    /// The generic must be valid to reinterpret as the given type.
52    #[inline]
53    pub unsafe fn cast_unchecked<NewElementType: ?Sized + Message + AsRef<NSObject>>(
54        &self,
55    ) -> &GKRTree<NewElementType> {
56        unsafe { &*((self as *const Self).cast()) }
57    }
58}
59
60extern_conformance!(
61    unsafe impl<ElementType: ?Sized + AsRef<NSObject>> NSObjectProtocol for GKRTree<ElementType> {}
62);
63
64impl<ElementType: Message + AsRef<NSObject>> GKRTree<ElementType> {
65    extern_methods!(
66        /// Amount of array items to reserve before a query.
67        /// This improves query performance at the cost of memory
68        #[unsafe(method(queryReserve))]
69        #[unsafe(method_family = none)]
70        pub unsafe fn queryReserve(&self) -> NSUInteger;
71
72        /// Setter for [`queryReserve`][Self::queryReserve].
73        #[unsafe(method(setQueryReserve:))]
74        #[unsafe(method_family = none)]
75        pub unsafe fn setQueryReserve(&self, query_reserve: NSUInteger);
76
77        /// Creates an RTree with a given maximum number of children per node.  Nodes that grow beyond this number of children will be split.
78        ///
79        ///
80        /// Parameter `maxNumberOfChildren`: the maximum number of children per node before splitting
81        #[unsafe(method(treeWithMaxNumberOfChildren:))]
82        #[unsafe(method_family = none)]
83        pub unsafe fn treeWithMaxNumberOfChildren(
84            max_number_of_children: NSUInteger,
85        ) -> Retained<Self>;
86
87        #[unsafe(method(initWithMaxNumberOfChildren:))]
88        #[unsafe(method_family = init)]
89        pub unsafe fn initWithMaxNumberOfChildren(
90            this: Allocated<Self>,
91            max_number_of_children: NSUInteger,
92        ) -> Retained<Self>;
93    );
94}
95
96/// Methods declared on superclass `NSObject`.
97impl<ElementType: Message + AsRef<NSObject>> GKRTree<ElementType> {
98    extern_methods!(
99        #[unsafe(method(init))]
100        #[unsafe(method_family = init)]
101        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
102
103        #[unsafe(method(new))]
104        #[unsafe(method_family = new)]
105        pub unsafe fn new() -> Retained<Self>;
106    );
107}