objc2_gameplay_kit/generated/GKDecisionTree.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::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10extern_class!(
11 /// [Apple's documentation](https://developer.apple.com/documentation/gameplaykit/gkdecisionnode?language=objc)
12 #[unsafe(super(NSObject))]
13 #[derive(Debug, PartialEq, Eq, Hash)]
14 pub struct GKDecisionNode;
15);
16
17extern_conformance!(
18 unsafe impl NSObjectProtocol for GKDecisionNode {}
19);
20
21impl GKDecisionNode {
22 extern_methods!(
23 /// Creates a numeric branch to a node containing the specified attribute
24 ///
25 ///
26 /// Parameter `value`: The value to create a branch with
27 ///
28 /// Parameter `attribute`: The attribute of the created node
29 ///
30 /// Returns: The node lead to by the branch
31 ///
32 /// # Safety
33 ///
34 /// `attribute` should be of the correct type.
35 #[unsafe(method(createBranchWithValue:attribute:))]
36 #[unsafe(method_family = none)]
37 pub unsafe fn createBranchWithValue_attribute(
38 &self,
39 value: &NSNumber,
40 attribute: &ProtocolObject<dyn NSObjectProtocol>,
41 ) -> Retained<Self>;
42
43 /// Creates a predicated branch to a node containing the specified attribute
44 ///
45 ///
46 /// Parameter `predicate`: The predicate to create a branch with
47 ///
48 /// Parameter `attribute`: The attribute of the created node
49 ///
50 /// Returns: The node lead to by the branch
51 ///
52 /// # Safety
53 ///
54 /// `attribute` should be of the correct type.
55 #[unsafe(method(createBranchWithPredicate:attribute:))]
56 #[unsafe(method_family = none)]
57 pub unsafe fn createBranchWithPredicate_attribute(
58 &self,
59 predicate: &NSPredicate,
60 attribute: &ProtocolObject<dyn NSObjectProtocol>,
61 ) -> Retained<Self>;
62
63 /// Creates a random branch to a node containing the specified attribute
64 ///
65 ///
66 /// Parameter `weight`: The weight to create a branch with (weighted for random selection)
67 ///
68 /// Parameter `attribute`: The attribute of the created node
69 ///
70 /// Returns: The node lead to by the branch
71 ///
72 ///
73 /// See: GKDecisionTree
74 ///
75 /// # Safety
76 ///
77 /// `attribute` should be of the correct type.
78 #[unsafe(method(createBranchWithWeight:attribute:))]
79 #[unsafe(method_family = none)]
80 pub unsafe fn createBranchWithWeight_attribute(
81 &self,
82 weight: NSInteger,
83 attribute: &ProtocolObject<dyn NSObjectProtocol>,
84 ) -> Retained<Self>;
85 );
86}
87
88/// Methods declared on superclass `NSObject`.
89impl GKDecisionNode {
90 extern_methods!(
91 #[unsafe(method(init))]
92 #[unsafe(method_family = init)]
93 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
94
95 #[unsafe(method(new))]
96 #[unsafe(method_family = new)]
97 pub unsafe fn new() -> Retained<Self>;
98 );
99}
100
101extern_class!(
102 /// [Apple's documentation](https://developer.apple.com/documentation/gameplaykit/gkdecisiontree?language=objc)
103 #[unsafe(super(NSObject))]
104 #[derive(Debug, PartialEq, Eq, Hash)]
105 pub struct GKDecisionTree;
106);
107
108extern_conformance!(
109 unsafe impl NSCoding for GKDecisionTree {}
110);
111
112extern_conformance!(
113 unsafe impl NSObjectProtocol for GKDecisionTree {}
114);
115
116extern_conformance!(
117 unsafe impl NSSecureCoding for GKDecisionTree {}
118);
119
120impl GKDecisionTree {
121 extern_methods!(
122 /// The node for the decision tree that all other nodes descend from
123 #[unsafe(method(rootNode))]
124 #[unsafe(method_family = none)]
125 pub unsafe fn rootNode(&self) -> Option<Retained<GKDecisionNode>>;
126
127 #[cfg(feature = "GKRandomSource")]
128 /// The random source used by the decision tree when descending on a random branch
129 /// This must be set before creating any weighted branches
130 ///
131 /// See: GKDecisionNode
132 #[unsafe(method(randomSource))]
133 #[unsafe(method_family = none)]
134 pub unsafe fn randomSource(&self) -> Retained<GKRandomSource>;
135
136 #[cfg(feature = "GKRandomSource")]
137 /// Setter for [`randomSource`][Self::randomSource].
138 ///
139 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
140 #[unsafe(method(setRandomSource:))]
141 #[unsafe(method_family = none)]
142 pub unsafe fn setRandomSource(&self, random_source: &GKRandomSource);
143
144 /// Initializes the decision tree with a root node containing the provided attribute
145 ///
146 ///
147 /// Parameter `attribute`: The attribute to be contained at the root of the tree
148 ///
149 /// Returns: GKDecisionTree with the set root
150 ///
151 /// # Safety
152 ///
153 /// `attribute` should be of the correct type.
154 #[unsafe(method(initWithAttribute:))]
155 #[unsafe(method_family = init)]
156 pub unsafe fn initWithAttribute(
157 this: Allocated<Self>,
158 attribute: &ProtocolObject<dyn NSObjectProtocol>,
159 ) -> Retained<Self>;
160
161 /// Initializes and constructs a decision tree by learning from the provided examples
162 /// &
163 /// attributes
164 ///
165 ///
166 /// Parameter `examples`: Must be an array of examples (with each example being a collection of the various attributes at a given state)
167 ///
168 /// Parameter `actions`: An array of the corresponding actions for each example. Ordered such that the first action matches with the first example in examples.
169 ///
170 /// Parameter `attributes`: The list of attributes. Ordered such that the first attribute matches with the first result in each example.
171 /// So if we have two attributes: [distance, jump height], and two examples: [[20, 8], [15, 14]], and the resulting actions here: [Roll, Jump], we can think of this as a matrix:
172 ///
173 /// distance| height
174 /// <
175 /// - Attributes
176 /// _______|_______
177 /// | | |
178 /// | 20 | 8 | jump
179 /// |-------|-------|-------
180 /// <
181 /// - Results
182 /// | 15 | 14 | roll
183 /// |_______|_______|
184 /// ^
185 /// |
186 /// Examples
187 ///
188 ///
189 /// Returns: GKDecisionTree created by learning from the provided examples for the provided attributes
190 ///
191 /// # Safety
192 ///
193 /// - `examples` generic generic should be of the correct type.
194 /// - `actions` generic should be of the correct type.
195 /// - `attributes` generic should be of the correct type.
196 #[unsafe(method(initWithExamples:actions:attributes:))]
197 #[unsafe(method_family = init)]
198 pub unsafe fn initWithExamples_actions_attributes(
199 this: Allocated<Self>,
200 examples: &NSArray<NSArray<ProtocolObject<dyn NSObjectProtocol>>>,
201 actions: &NSArray<ProtocolObject<dyn NSObjectProtocol>>,
202 attributes: &NSArray<ProtocolObject<dyn NSObjectProtocol>>,
203 ) -> Retained<Self>;
204
205 /// Initializes a decision tree from the contents of a file
206 ///
207 ///
208 /// Parameter `url`: The URL from which the contents will be loaded
209 ///
210 /// Returns: The instance of the decision tree constructed
211 #[unsafe(method(initWithURL:error:))]
212 #[unsafe(method_family = init)]
213 pub unsafe fn initWithURL_error(
214 this: Allocated<Self>,
215 url: &NSURL,
216 error: Option<&NSError>,
217 ) -> Retained<Self>;
218
219 /// Exports a decision tree to the given URL
220 ///
221 ///
222 /// Parameter `url`: The URL to which the contents will be exported
223 ///
224 /// Returns: The response indicating the status of the decision tree being successfully exported
225 #[unsafe(method(exportToURL:error:))]
226 #[unsafe(method_family = none)]
227 pub unsafe fn exportToURL_error(&self, url: &NSURL, error: Option<&NSError>) -> bool;
228
229 /// Will branch down from the root node to find the correct action attribute for the given collection of results and their respective attributes
230 ///
231 ///
232 /// Parameter `answers`: The dictionary of attributes (keys) and their answers (values)
233 ///
234 /// Returns: The attribute found by traversing the tree given the provided answers
235 ///
236 /// # Safety
237 ///
238 /// - `answers` generic should be of the correct type.
239 /// - `answers` generic should be of the correct type.
240 #[unsafe(method(findActionForAnswers:))]
241 #[unsafe(method_family = none)]
242 pub unsafe fn findActionForAnswers(
243 &self,
244 answers: &NSDictionary<
245 ProtocolObject<dyn NSObjectProtocol>,
246 ProtocolObject<dyn NSObjectProtocol>,
247 >,
248 ) -> Option<Retained<ProtocolObject<dyn NSObjectProtocol>>>;
249 );
250}
251
252/// Methods declared on superclass `NSObject`.
253impl GKDecisionTree {
254 extern_methods!(
255 #[unsafe(method(init))]
256 #[unsafe(method_family = init)]
257 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
258
259 #[unsafe(method(new))]
260 #[unsafe(method_family = new)]
261 pub unsafe fn new() -> Retained<Self>;
262 );
263}