]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
2d21ac55 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
1c79356b | 5 | * |
2d21ac55 A |
6 | * This file contains Original Code and/or Modifications of Original Code |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. The rights granted to you under the License | |
10 | * may not be used to create, or enable the creation or redistribution of, | |
11 | * unlawful or unlicensed copies of an Apple operating system, or to | |
12 | * circumvent, violate, or enable the circumvention or violation of, any | |
13 | * terms of an Apple operating system software license agreement. | |
8f6c56a5 | 14 | * |
2d21ac55 A |
15 | * Please obtain a copy of the License at |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
17 | * | |
18 | * The Original Code and all software distributed under the License are | |
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
8f6c56a5 A |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
2d21ac55 A |
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
23 | * Please see the License for the specific language governing rights and | |
24 | * limitations under the License. | |
8f6c56a5 | 25 | * |
2d21ac55 | 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
1c79356b A |
27 | */ |
28 | /* IOSet.h created by rsulack on Thu 11-Jun-1998 */ | |
29 | /* IOSet.h converted to C++ by gvdl on Fri 1998-10-30 */ | |
30 | ||
31 | #ifndef _OS_OSSET_H | |
32 | #define _OS_OSSET_H | |
33 | ||
34 | #include <libkern/c++/OSCollection.h> | |
35 | ||
36 | class OSArray; | |
37 | ||
38 | /*! | |
b0d623f7 A |
39 | * @header |
40 | * | |
41 | * @abstract | |
42 | * This header declares the OSSet collection class. | |
43 | */ | |
44 | ||
45 | ||
46 | /*! | |
47 | * @class OSSet | |
48 | * | |
49 | * @abstract | |
50 | * OSSet provides an unordered set store of objects. | |
51 | * | |
52 | * @discussion | |
53 | * OSSet is a container for Libkern C++ objects | |
54 | * (those derived from | |
55 | * @link //apple_ref/doc/class/OSMetaClassBase OSMetaClassBase@/link, | |
56 | * in particular @link //apple_ref/doc/class/OSObject OSObject@/link). | |
57 | * Storage and access follow basic set logic: you can add or remove an object, | |
58 | * and test whether the set contains a particular object. | |
59 | * A given object is only stored in the set once, | |
60 | * and there is no ordering of objects in the set. | |
61 | * A subclass @link //apple_ref/doc/class/OSOrderedSet OSOrderedSet@/link, | |
62 | * provides for ordered set logic. | |
63 | * | |
64 | * As with all Libkern collection classes, | |
65 | * OSSet retains objects added to it, | |
66 | * and releases objects removed from it. | |
67 | * An OSSet also grows as necessary to accommodate new objects, | |
68 | * <i>unlike</i> Core Foundation collections (it does not, however, shrink). | |
69 | * | |
70 | * <b>Use Restrictions</b> | |
71 | * | |
72 | * With very few exceptions in the I/O Kit, all Libkern-based C++ | |
73 | * classes, functions, and macros are <b>unsafe</b> | |
74 | * to use in a primary interrupt context. | |
75 | * Consult the I/O Kit documentation related to primary interrupts | |
76 | * for more information. | |
77 | * | |
78 | * OSSet provides no concurrency protection; | |
79 | * it's up to the usage context to provide any protection necessary. | |
80 | * Some portions of the I/O Kit, such as | |
81 | * @link //apple_ref/doc/class/IORegistryEntry IORegistryEntry@/link, | |
82 | * handle synchronization via defined member functions for setting | |
83 | * properties. | |
84 | */ | |
1c79356b A |
85 | class OSSet : public OSCollection |
86 | { | |
87 | OSDeclareDefaultStructors(OSSet) | |
88 | ||
89 | private: | |
b0d623f7 | 90 | OSArray * members; |
1c79356b A |
91 | |
92 | protected: | |
93 | /* | |
94 | * OSCollectionIterator interfaces. | |
95 | */ | |
96 | virtual unsigned int iteratorSize() const; | |
b0d623f7 A |
97 | virtual bool initIterator(void * iterator) const; |
98 | virtual bool getNextObjectForIterator(void * iterator, OSObject ** ret) const; | |
1c79356b A |
99 | |
100 | struct ExpansionData { }; | |
101 | ||
b0d623f7 A |
102 | /* Reserved for future use. (Internal use only) */ |
103 | ExpansionData * reserved; | |
1c79356b A |
104 | |
105 | public: | |
b0d623f7 A |
106 | |
107 | ||
108 | /*! | |
109 | * @function withCapacity | |
110 | * | |
111 | * @abstract | |
112 | * Creates and initializes an empty OSSet. | |
113 | * | |
114 | * @param capacity The initial storage capacity of the new set object. | |
115 | * | |
116 | * @result | |
117 | * An empty instance of OSSet | |
118 | * with a retain count of 1; | |
119 | * <code>NULL</code> on failure. | |
120 | * | |
121 | * @discussion | |
122 | * <code>capacity</code> must be nonzero. | |
123 | * The new OSSet will grow as needed to accommodate more key/object pairs | |
124 | * (<i>unlike</i> @link //apple_ref/doc/uid/20001503 CFMutableSet@/link, | |
125 | * for which the initial capacity is a hard limit). | |
1c79356b | 126 | */ |
b0d623f7 A |
127 | static OSSet * withCapacity(unsigned int capacity); |
128 | ||
129 | ||
130 | /*! | |
131 | * @function withObjects | |
132 | * | |
133 | * @abstract | |
134 | * Creates and initializes an OSSet | |
135 | * populated with objects provided. | |
136 | * | |
137 | * @param objects A C array of OSMetaClassBase-derived objects. | |
138 | * @param count The number of objects to be placed into the set. | |
139 | * @param capacity The initial storage capacity of the new set object. | |
140 | * If 0, <code>count</code> is used; otherwise this value | |
141 | * must be greater than or equal to <code>count</code>. | |
142 | * | |
143 | * @result | |
144 | * An instance of OSSet | |
145 | * containing the objects provided, | |
146 | * with a retain count of 1; | |
147 | * <code>NULL</code> on failure. | |
148 | * | |
149 | * @discussion | |
150 | * <code>objects</code> must be non-<code>NULL</code>, | |
151 | * and <code>count</code> must be nonzero. | |
152 | * If <code>capacity</code> is nonzero, | |
153 | * it must be greater than or equal to <code>count</code>. | |
154 | * The new OSSet will grow as needed to accommodate more objects | |
155 | * (<i>unlike</i> @link //apple_ref/doc/uid/20001503 CFMutableSet@/link, | |
156 | * for which the initial capacity is a hard limit). | |
157 | * | |
158 | * The objects in <code>objects</code> are retained for storage in the new set, | |
159 | * not copied. | |
1c79356b | 160 | */ |
b0d623f7 A |
161 | static OSSet * withObjects( |
162 | const OSObject * objects[], | |
163 | unsigned int count, | |
164 | unsigned int capacity = 0); | |
165 | ||
166 | ||
167 | /*! | |
168 | * @function withArray | |
169 | * | |
170 | * @abstract | |
171 | * Creates and initializes an OSSet | |
172 | * populated with the contents of an OSArray. | |
173 | * | |
174 | * @param array An array whose objects will be stored in the new OSSet. | |
175 | * @param capacity The initial storage capacity of the new set object. | |
176 | * If 0, the capacity is set to the number of objects | |
177 | * in <code>array</code>; | |
178 | * otherwise <code>capacity</code> must be greater than or equal to | |
179 | * the number of objects in <code>array</code>. | |
180 | * @result | |
181 | * An instance of OSSet containing | |
182 | * the objects of <code>array</code>, | |
183 | * with a retain count of 1; | |
184 | * <code>NULL</code> on failure. | |
185 | * | |
186 | * @discussion | |
187 | * Each distinct object in <code>array</code> is added to the new set. | |
188 | * | |
189 | * <code>array</code> must be non-<code>NULL</code>. | |
190 | * If <code>capacity</code> is nonzero, | |
191 | * it must be greater than or equal to <code>count</code>. | |
192 | * The new OSSet will grow as needed to accommodate more key-object pairs | |
193 | * (<i>unlike</i> @link //apple_ref/doc/uid/20001503 CFMutableSet@/link, | |
194 | * for which the initial capacity is a hard limit). | |
195 | * | |
196 | * The objects in <code>array</code> are retained for storage in the new set, | |
197 | * not copied. | |
1c79356b | 198 | */ |
b0d623f7 A |
199 | static OSSet * withArray( |
200 | const OSArray * array, | |
201 | unsigned int capacity = 0); | |
202 | ||
203 | ||
204 | /*! | |
205 | * @function withSet | |
206 | * | |
207 | * @abstract | |
208 | * Creates and initializes an OSSet | |
209 | * populated with the contents of another OSSet. | |
210 | * | |
211 | * @param set An OSSet whose contents will be stored | |
212 | * in the new instance. | |
213 | * @param capacity The initial storage capacity of the set object. | |
214 | * If 0, the capacity is set to the number of objects | |
215 | * in <code>set</code>; | |
216 | * otherwise <code>capacity</code> must be greater than or equal to | |
217 | * the number of objects in <code>array</code>. | |
218 | * @result | |
219 | * An instance of OSArray | |
220 | * containing the objects of <code>set</code>, | |
221 | * with a retain count of 1; | |
222 | * <code>NULL</code> on failure. | |
223 | * | |
224 | * @discussion | |
225 | * <code>set</code> must be non-<code>NULL</code>. | |
226 | * If <code>capacity</code> is nonzero, | |
227 | * it must be greater than or equal to <code>count</code>. | |
228 | * The array will grow as needed to accommodate more key-object pairs | |
229 | * (<i>unlike</i> @link //apple_ref/doc/uid/20001503 CFMutableSet@/link, | |
230 | * for which the initial capacity is a hard limit). | |
231 | * | |
232 | * The objects in <code>set</code> are retained for storage in the new set, | |
233 | * not copied. | |
1c79356b | 234 | */ |
b0d623f7 | 235 | static OSSet * withSet(const OSSet * set, |
1c79356b A |
236 | unsigned int capacity = 0); |
237 | ||
b0d623f7 A |
238 | |
239 | /*! | |
240 | * @function initWithCapacity | |
241 | * | |
242 | * @abstract | |
243 | * Initializes a new instance of OSSet. | |
244 | * | |
245 | * @param capacity The initial storage capacity of the new set object. | |
246 | * | |
247 | * @result | |
248 | * <code>true</code> on success, <code>false</code> on failure. | |
249 | * | |
250 | * @discussion | |
251 | * Not for general use. Use the static instance creation method | |
252 | * <code>@link | |
253 | * //apple_ref/cpp/clm/OSSet/withCapacity/staticOSSet*\/(unsignedint) | |
254 | * withCapacity@/link</code> | |
255 | * instead. | |
256 | * | |
257 | * <code>capacity</code> must be nonzero. | |
258 | * The new set will grow as needed to accommodate more key/object pairs | |
259 | * (<i>unlike</i> @link //apple_ref/doc/uid/20001503 CFMutableSet@/link, | |
260 | * for which the initial capacity is a hard limit). | |
1c79356b A |
261 | */ |
262 | virtual bool initWithCapacity(unsigned int capacity); | |
b0d623f7 A |
263 | |
264 | ||
265 | /*! | |
266 | * @function initWithObjects | |
267 | * | |
268 | * @abstract | |
269 | * Initializes a new OSSet populated with objects provided. | |
270 | * | |
271 | * @param objects A C array of OSObject-derived objects. | |
272 | * @param count The number of objects to be placed into the set. | |
273 | * @param capacity The initial storage capacity of the new set object. | |
274 | * If 0, <code>count</code> is used; otherwise this value | |
275 | * must be greater than or equal to <code>count</code>. | |
276 | * | |
277 | * @result | |
278 | * <code>true</code> on success, <code>false</code> on failure. | |
279 | * | |
280 | * @discussion | |
281 | * Not for general use. Use the static instance creation method | |
282 | * <code>@link | |
283 | * //apple_ref/cpp/clm/OSSet/withObjects/staticOSSet*\/(constOSObject*,unsignedint,unsignedint) | |
284 | * withObjects@/link</code> | |
285 | * instead. | |
286 | * | |
287 | * <code>objects</code> must be non-<code>NULL</code>, | |
288 | * and <code>count</code> must be nonzero. | |
289 | * If <code>capacity</code> is nonzero, it must be greater than or equal to <code>count</code>. | |
290 | * The new array will grow as needed to accommodate more key-object pairs | |
291 | * (<i>unlike</i> @link //apple_ref/doc/uid/20001503 CFMutableSet@/link, | |
292 | * for which the initial capacity is a hard limit). | |
293 | * | |
294 | * The objects in <code>objects</code> are retained for storage in the new set, | |
295 | * not copied. | |
1c79356b | 296 | */ |
b0d623f7 A |
297 | virtual bool initWithObjects( |
298 | const OSObject * objects[], | |
299 | unsigned int count, | |
300 | unsigned int capacity = 0); | |
301 | ||
302 | ||
303 | /*! | |
304 | * @function initWithArray | |
305 | * | |
306 | * @abstract Initializes a new OSSet | |
307 | * populated with the contents of an OSArray. | |
308 | * | |
309 | * @param array An OSAray whose contents will be placed | |
310 | * in the new instance. | |
311 | * @param capacity The initial storage capacity of the new set object. | |
312 | * If 0, the capacity is set | |
313 | * to the number of objects in <code>array</code>; | |
314 | * otherwise <code>capacity</code> must be greater than or equal to | |
315 | * the number of objects in <code>array</code>. | |
316 | * | |
317 | * @result | |
318 | * <code>true</code> on success, <code>false</code> on failure. | |
319 | * | |
320 | * @discussion | |
321 | * Not for general use. Use the static instance creation method | |
322 | * <code>@link | |
323 | * //apple_ref/cpp/clm/OSSet/withArray/staticOSSet*\/(constOSArray*,unsignedint) | |
324 | * withArray@/link</code> | |
325 | * instead. | |
326 | * | |
327 | * <code>array</code> must be non-<code>NULL</code>. | |
328 | * If <code>capacity</code> is nonzero, | |
329 | * it must be greater than or equal to <code>count</code>. | |
330 | * The new array will grow as needed to accommodate more key-object pairs | |
331 | * (<i>unlike</i> @link //apple_ref/doc/uid/20001503 CFMutableSet@/link, | |
332 | * for which the initial capacity is a hard limit). | |
333 | * | |
334 | * The objects in <code>array</code> are retained for storage in the new set, | |
335 | * not copied. | |
1c79356b | 336 | */ |
b0d623f7 A |
337 | virtual bool initWithArray( |
338 | const OSArray * array, | |
339 | unsigned int capacity = 0); | |
340 | ||
341 | ||
342 | /*! | |
343 | * @function initWithSet | |
344 | * | |
345 | * @abstract | |
346 | * Initializes a new OSSet | |
347 | * populated with the contents of another OSSet. | |
348 | * | |
349 | * @param set A set whose contents will be placed in the new instance. | |
350 | * @param capacity The initial storage capacity of the new set object. | |
351 | * If 0, the capacity is set | |
352 | * to the number of objects in <code>set</code>; | |
353 | * otherwise <code>capacity</code> must be greater than or equal to | |
354 | * the number of objects in <code>set</code>. | |
355 | * | |
356 | * @result | |
357 | * <code>true</code> on success, <code>false</code> on failure. | |
358 | * | |
359 | * @discussion | |
360 | * Not for general use. Use the static instance creation method | |
361 | * <code>@link withSet withSet@/link</code> instead. | |
362 | * | |
363 | * <code>set</code> must be non-<code>NULL</code>. | |
364 | * If <code>capacity</code> is nonzero, | |
365 | * it must be greater than or equal to <code>count</code>. | |
366 | * The new set will grow as needed to accommodate more key-object pairs | |
367 | * (<i>unlike</i> @link //apple_ref/doc/uid/20001503 CFMutableSet@/link, | |
368 | * for which the initial capacity is a hard limit). | |
369 | * | |
370 | * The objects in <code>set</code> are retained for storage in the new set, | |
371 | * not copied. | |
1c79356b A |
372 | */ |
373 | virtual bool initWithSet(const OSSet *set, | |
374 | unsigned int capacity = 0); | |
b0d623f7 A |
375 | |
376 | ||
377 | /*! | |
378 | * @function free | |
379 | * | |
380 | * @abstract | |
381 | * Deallocates or releases any resources | |
382 | * used by the OSSet instance. | |
383 | * | |
384 | * @discussion | |
385 | * This function should not be called directly; | |
386 | * use | |
387 | * <code>@link | |
388 | * //apple_ref/cpp/instm/OSObject/release/virtualvoid/() | |
389 | * release@/link</code> | |
390 | * instead. | |
1c79356b A |
391 | */ |
392 | virtual void free(); | |
393 | ||
b0d623f7 A |
394 | |
395 | /*! | |
396 | * @function getCount | |
397 | * | |
398 | * @abstract | |
399 | * Returns the current number of objects within the set. | |
400 | * | |
401 | * @result | |
402 | * The current number of objects within the set. | |
1c79356b A |
403 | */ |
404 | virtual unsigned int getCount() const; | |
b0d623f7 A |
405 | |
406 | ||
407 | /*! | |
408 | * @function getCapacity | |
409 | * | |
410 | * @abstract | |
411 | * Returns the number of objects the set | |
412 | * can store without reallocating. | |
413 | * | |
414 | * @result | |
415 | * The number objects the set | |
416 | * can store without reallocating. | |
417 | * | |
418 | * @discussion | |
419 | * OSSet objects grow when full to accommodate additional objects. | |
420 | * See | |
421 | * <code>@link | |
422 | * //apple_ref/cpp/instm/OSSet/getCapacityIncrement/virtualunsignedint/() | |
423 | * getCapacityIncrement@/link</code> | |
424 | * and | |
425 | * <code>@link | |
426 | * //apple_ref/cpp/instm/OSSet/ensureCapacity/virtualunsignedint/(unsignedint) | |
427 | * ensureCapacity@/link</code>. | |
1c79356b A |
428 | */ |
429 | virtual unsigned int getCapacity() const; | |
b0d623f7 A |
430 | |
431 | ||
432 | /*! | |
433 | * @function getCapacityIncrement | |
434 | * | |
435 | * @abstract | |
436 | * Returns the storage increment of the set. | |
437 | * | |
438 | * @result | |
439 | * The storage increment of the set. | |
440 | * | |
441 | * @discussion | |
442 | * An OSSet allocates storage for objects in multiples | |
443 | * of the capacity increment. | |
1c79356b A |
444 | */ |
445 | virtual unsigned int getCapacityIncrement() const; | |
b0d623f7 A |
446 | |
447 | ||
448 | /*! | |
449 | * @function setCapacityIncrement | |
450 | * | |
451 | * @abstract | |
452 | * Sets the storage increment of the set. | |
453 | * | |
454 | * @result | |
455 | * The new storage increment of the set, | |
456 | * which may be different from the number requested. | |
457 | * | |
458 | * @discussion | |
459 | * An OSSet allocates storage for objects in multiples | |
460 | * of the capacity increment. | |
461 | * Calling this function does not immediately reallocate storage. | |
1c79356b A |
462 | */ |
463 | virtual unsigned int setCapacityIncrement(unsigned increment); | |
464 | ||
b0d623f7 A |
465 | |
466 | /*! | |
467 | * @function ensureCapacity | |
468 | * | |
469 | * @abstract | |
470 | * Ensures the set has enough space | |
471 | * to store the requested number of distinct objects. | |
472 | * | |
473 | * @param newCapacity The total number of distinct objects the set | |
474 | * should be able to store. | |
475 | * @result | |
476 | * The new capacity of the set, | |
477 | * which may be different from the number requested | |
478 | * (if smaller, reallocation of storage failed). | |
479 | * | |
480 | * @discussion | |
481 | * This function immediately resizes the set, if necessary, | |
482 | * to accommodate at least <code>newCapacity</code> distinct objects. | |
483 | * If <code>newCapacity</code> is not greater than the current capacity, | |
484 | * or if an allocation error occurs, the original capacity is returned. | |
485 | * | |
486 | * There is no way to reduce the capacity of an OSSet. | |
1c79356b A |
487 | */ |
488 | virtual unsigned int ensureCapacity(unsigned int newCapacity); | |
489 | ||
b0d623f7 A |
490 | |
491 | /*! | |
492 | * @function flushCollection | |
493 | * | |
494 | * @abstract | |
495 | * Removes and releases all objects within the set. | |
496 | * | |
497 | * @discussion | |
498 | * The set's capacity (and therefore direct memory consumption) | |
499 | * is not reduced by this function. | |
1c79356b A |
500 | */ |
501 | virtual void flushCollection(); | |
502 | ||
b0d623f7 A |
503 | |
504 | /*! | |
505 | * @function setObject | |
506 | * | |
507 | * @abstract | |
508 | * Adds an object to the OSSet if it is not already present. | |
509 | * | |
510 | * @param anObject The OSMetaClassBase-derived object to be added to the set. | |
511 | * | |
512 | * @result | |
513 | * <code>true</code> if <code>anObject</code> was successfully | |
514 | * added to the set, <code>false</code> otherwise | |
515 | * (including if it was already in the set). | |
516 | * | |
517 | * @discussion | |
518 | * The set adds storage to accomodate the new object, if necessary. | |
519 | * If successfully added, the object is retained. | |
520 | * | |
521 | * A <code>false</code> return value can mean either | |
522 | * that <code>anObject</code> is already present in the set, | |
523 | * or that a memory allocation failure occurred. | |
524 | * If you need to know whether the object | |
525 | * is already present, use | |
526 | * <code>@link containsObject containsObject@/link</code>. | |
1c79356b | 527 | */ |
b0d623f7 A |
528 | virtual bool setObject(const OSMetaClassBase * anObject); |
529 | ||
530 | ||
531 | /*! | |
532 | * @function merge | |
533 | * | |
534 | * @abstract | |
535 | * Adds the contents of an OSArray to the set. | |
536 | * | |
537 | * @param array The OSArray object containing the objects to be added. | |
538 | * | |
539 | * @result | |
6d2010ae A |
540 | * <code>true</code> if all objects from <code>array</code> |
541 | * are successfully added the receiver (or were already present), | |
b0d623f7 A |
542 | * <code>false</code> otherwise. |
543 | * | |
544 | * @discussion | |
545 | * This functions adds to the receiving set | |
546 | * all objects from <code>array</code> | |
6d2010ae A |
547 | * that are not already in the receiving set. |
548 | * Objects added to the receiver are retained. | |
b0d623f7 | 549 | * |
6d2010ae A |
550 | * In releases prior to 10.7, this function would return <code>false</code> |
551 | * if an object from <code>array</code> was already present in the set, | |
552 | * or if <code>array</code> was empty. | |
553 | * This is no longer the case, so this function correctly returns <code>true</code> | |
554 | * when the semantic of merging is met. | |
1c79356b | 555 | */ |
b0d623f7 A |
556 | virtual bool merge(const OSArray * array); |
557 | ||
558 | ||
559 | /*! | |
560 | * @function merge | |
561 | * | |
562 | * @abstract | |
563 | * Adds the contents of an OSet to the set. | |
564 | * | |
565 | * @param set The OSSet object containing the objects to be added. | |
566 | * | |
567 | * @result | |
568 | * <code>true</code> if any object from <code>set</code> | |
6d2010ae | 569 | * are successfully added the receiver (or were already present), |
b0d623f7 A |
570 | * <code>false</code> otherwise. |
571 | * | |
572 | * @discussion | |
573 | * This functions adds to the receiving set | |
574 | * all objects from <code>set</code> | |
575 | * that are not already in the receiving set. | |
6d2010ae | 576 | * Objects added to the receiver are retained. |
b0d623f7 | 577 | * |
6d2010ae A |
578 | * In releases prior to 10.7, this function would return <code>false</code> |
579 | * if an object from <code>set</code> was already present in the set, | |
580 | * or if <code>set</code> was empty. | |
581 | * This is no longer the case, so this function correctly returns <code>true</code> | |
582 | * when the semantic of merging is met. | |
1c79356b | 583 | */ |
b0d623f7 A |
584 | virtual bool merge(const OSSet * set); |
585 | ||
1c79356b | 586 | |
b0d623f7 A |
587 | /*! |
588 | * @function removeObject | |
589 | * | |
590 | * @abstract | |
591 | * Removes an object from the set. | |
592 | * | |
593 | * @param anObject The OSMetaClassBase-derived object | |
594 | * to be removed from the set. | |
595 | * | |
596 | * @discussion | |
597 | * The object removed from the set is released. | |
1c79356b A |
598 | */ |
599 | virtual void removeObject(const OSMetaClassBase * anObject); | |
600 | ||
b0d623f7 A |
601 | |
602 | /*! | |
603 | * @function containsObject | |
604 | * | |
605 | * @abstract | |
606 | * Checks the set for the presence of an object. | |
607 | * | |
608 | * @param anObject The OSMetaClassBase-derived object | |
609 | * to check for in the set. | |
610 | * | |
611 | * @result | |
612 | * <code>true</code> if <code>anObject</code> is present within the set, | |
613 | * <code>false</code> otherwise. | |
614 | * | |
615 | * @discussion | |
616 | * Pointer equality is used. | |
617 | * This function returns <code>false</code> if passed <code>NULL</code>. | |
1c79356b | 618 | */ |
b0d623f7 A |
619 | virtual bool containsObject(const OSMetaClassBase * anObject) const; |
620 | ||
621 | ||
622 | /*! | |
623 | * @function member | |
624 | * | |
625 | * @abstract | |
626 | * Checks the set for the presence of an object. | |
627 | * | |
628 | * @param anObject The OSMetaClassBase-derived object | |
629 | * to check for in the set. | |
630 | * | |
631 | * @result | |
632 | * <code>true</code> if <code>anObject</code> is present | |
633 | * within the set, <code>false</code> otherwise. | |
634 | * | |
635 | * @discussion | |
636 | * Pointer equality is used. This function returns <code>false</code> | |
637 | * if passed <code>NULL</code>. | |
638 | * | |
639 | * <code>@link containsObject containsObject@/link</code> | |
640 | * checks for <code>NULL</code> first, | |
641 | * and is therefore more efficient than this function. | |
1c79356b | 642 | */ |
b0d623f7 A |
643 | virtual bool member(const OSMetaClassBase * anObject) const; |
644 | ||
645 | ||
646 | /*! | |
647 | * @function getAnyObject | |
648 | * | |
649 | * @abstract | |
650 | * Returns an arbitrary (not random) object from the set. | |
651 | * | |
652 | * @result | |
653 | * An arbitrary (not random) object | |
654 | * if one exists within the set. | |
655 | * | |
656 | * @discussion | |
657 | * The returned object will be released if removed from the set; | |
658 | * if you plan to store the reference, you should call | |
659 | * <code>@link | |
660 | * //apple_ref/cpp/instm/OSObject/retain/virtualvoid/() | |
661 | * retain@/link</code> | |
662 | * on that object. | |
663 | */ | |
664 | virtual OSObject * getAnyObject() const; | |
665 | ||
666 | ||
667 | /*! | |
668 | * @function isEqualTo | |
669 | * | |
670 | * @abstract | |
671 | * Tests the equality of two OSSet objects. | |
672 | * | |
673 | * @param aSet The set object being compared against the receiver. | |
674 | * @result | |
675 | * <code>true</code> if the two sets are equivalent, | |
676 | * <code>false</code> otherwise. | |
677 | * | |
678 | * @discussion | |
679 | * Two OSSet objects are considered equal if they have same count | |
680 | * and the same object pointer values. | |
1c79356b | 681 | */ |
b0d623f7 | 682 | virtual bool isEqualTo(const OSSet * aSet) const; |
1c79356b | 683 | |
b0d623f7 A |
684 | |
685 | /*! | |
686 | * @function isEqualTo | |
687 | * | |
688 | * @abstract | |
689 | * Tests the equality of an OSSet against an arbitrary object. | |
690 | * | |
691 | * @param anObject The object being compared against the receiver. | |
692 | * @result | |
693 | * <code>true</code> if the two objects are equivalent, | |
694 | * <code>false</code> otherwise. | |
695 | * | |
696 | * @discussion | |
697 | * An OSSet object is considered equal to another object if the other object | |
698 | * is derived from OSSet and compares equal as a set. | |
1c79356b | 699 | */ |
b0d623f7 A |
700 | virtual bool isEqualTo(const OSMetaClassBase * anObject) const; |
701 | ||
702 | ||
703 | /*! | |
704 | * @function serialize | |
705 | * | |
706 | * @abstract | |
707 | * Archives the receiver into the provided | |
708 | * @link //apple_ref/doc/class/OSSerialize OSSerialize@/link object. | |
709 | * | |
710 | * @param serializer The OSSerialize object. | |
711 | * | |
712 | * @result | |
713 | * <code>true</code> if serialization succeeds, <code>false</code> if not. | |
1c79356b | 714 | */ |
b0d623f7 A |
715 | virtual bool serialize(OSSerialize * serializer) const; |
716 | ||
1c79356b | 717 | |
b0d623f7 A |
718 | /*! |
719 | * @function setOptions | |
720 | * | |
721 | * @abstract | |
722 | * Recursively sets option bits in the set | |
723 | * and all child collections. | |
724 | * | |
725 | * @param options A bitfield whose values turn the options on (1) or off (0). | |
726 | * @param mask A mask indicating which bits | |
727 | * in <code>options</code> to change. | |
728 | * Pass 0 to get the whole current options bitfield | |
729 | * without changing any settings. | |
730 | * @param context Unused. | |
731 | * | |
732 | * @result | |
733 | * The options bitfield as it was before the set operation. | |
734 | * | |
735 | * @discussion | |
736 | * Kernel extensions should not call this function. | |
737 | * | |
738 | * Child collections' options are changed only if the receiving set's | |
739 | * options actually change. | |
1c79356b | 740 | */ |
b0d623f7 A |
741 | virtual unsigned setOptions(unsigned options, unsigned mask, void * context = 0); |
742 | ||
743 | ||
744 | /*! | |
745 | * @function copyCollection | |
746 | * | |
747 | * @abstract | |
748 | * Creates a deep copy of this set and its child collections. | |
749 | * | |
750 | * @param cycleDict A dictionary of all of the collections | |
751 | * that have been copied so far, | |
752 | * which is used to track circular references. | |
753 | * To start the copy at the top level, | |
754 | * pass <code>NULL</code>. | |
755 | * | |
756 | * @result | |
757 | * The newly copied set, with a retain count of 1, | |
758 | * or <code>NULL</code> if there is insufficient memory to do the copy. | |
759 | * | |
760 | * @discussion | |
761 | * The receiving set, and any collections it contains, | |
762 | * recursively, are copied. | |
763 | * Objects that are not derived from OSCollection are retained | |
764 | * rather than copied. | |
91447636 A |
765 | */ |
766 | OSCollection *copyCollection(OSDictionary *cycleDict = 0); | |
1c79356b A |
767 | |
768 | OSMetaClassDeclareReservedUnused(OSSet, 0); | |
769 | OSMetaClassDeclareReservedUnused(OSSet, 1); | |
770 | OSMetaClassDeclareReservedUnused(OSSet, 2); | |
771 | OSMetaClassDeclareReservedUnused(OSSet, 3); | |
772 | OSMetaClassDeclareReservedUnused(OSSet, 4); | |
773 | OSMetaClassDeclareReservedUnused(OSSet, 5); | |
774 | OSMetaClassDeclareReservedUnused(OSSet, 6); | |
775 | OSMetaClassDeclareReservedUnused(OSSet, 7); | |
776 | }; | |
777 | ||
778 | #endif /* !_OS_OSSET_H */ |