]> git.saurik.com Git - apple/xnu.git/blob - libkern/libkern/c++/OSCollectionIterator.h
57aa36b5cdb3d89f1e0a284d3c9c41f9d47fd8d3
[apple/xnu.git] / libkern / libkern / c++ / OSCollectionIterator.h
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
5 *
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
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
14 * agreement.
15 *
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
18 * file.
19 *
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
27 *
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
29 */
30 /* IOCollectionIterator.h created by gvdl on Fri 1998-10-30 */
31
32 #ifndef _OS_OSCOLLECTIONITERATOR_H
33 #define _OS_OSCOLLECTIONITERATOR_H
34
35 #include <libkern/c++/OSIterator.h>
36
37 class OSCollection;
38
39 /*!
40 @class OSCollectionIterator
41 @discussion
42 OSCollectionIterator objects provide a consistent mechanism to iterate through all OSCollection derived collections.
43 */
44 class OSCollectionIterator : public OSIterator
45 {
46 OSDeclareDefaultStructors(OSCollectionIterator)
47
48 protected:
49 const OSCollection *collection;
50 void *collIterator;
51 unsigned int initialUpdateStamp;
52 bool valid;
53
54 public:
55 /*!
56 @function withCollection
57 @abstract A static constructor function which creates and initializes an instance of OSCollectionIterator for the provided collection object.
58 @param inColl The OSCollection derived collection object to be iteratated.
59 @result Returns a new instance of OSCollection or 0 on failure.
60 */
61 static OSCollectionIterator *withCollection(const OSCollection *inColl);
62
63 /*!
64 @function withCollection
65 @abstract A member function to initialize the intance of OSCollectionIterator with the provided colleciton object.
66 @param inColl The OSCollection derived collection object to be iteratated.
67 @result Returns true if the initialization was successful or false on failure.
68 */
69 virtual bool initWithCollection(const OSCollection *inColl);
70 /*!
71 @function free
72 @abstract A member function to release and deallocate all resources created or used by the OSCollectionIterator object.
73 @discussion This function should not be called directly, use release() instead.
74 */
75 virtual void free();
76
77 /*!
78 @function reset
79 @abstract A member function which resets the iterator to begin the next iteration from the beginning of the collection.
80 */
81 virtual void reset();
82
83 /*!
84 @function isValid
85 @abstract A member function for determining if the collection was modified during iteration.
86 */
87 virtual bool isValid();
88
89 /*!
90 @function getNextObject
91 @abstract A member function to get the next object in the collection being iterated.
92 @result Returns the next object in the collection or 0 when the end has been reached.
93 */
94 virtual OSObject *getNextObject();
95 };
96
97 #endif /* !_OS_OSCOLLECTIONITERATOR_H */