1/* 2 * Copyright (c) 1998-2002 Apple Computer, Inc. All rights reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 6 * The contents of this file constitute Original Code as defined in and 7 * are subject to the Apple Public Source License Version 1.1 (the 8 * "License"). You may not use this file except in compliance with the 9 * License. Please obtain a copy of the License at 10 * http://www.apple.com/publicsource and read it before using this file. 11 * 12 * This Original Code and all software distributed under the License are 13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER 14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the 17 * License for the specific language governing rights and limitations 18 * under the License. 19 * 20 * @APPLE_LICENSE_HEADER_END@ 21 */ 22 23// public 24#import <IOKit/firewire/IOConfigDirectory.h> 25#import <IOKit/firewire/IOFireWireDevice.h> 26 27// private 28#import "FWDebugging.h" 29#import "IOConfigDirectoryIterator.h" 30 31// system 32#import <libkern/c++/OSIterator.h> 33 34OSDefineMetaClassAndStructors(IOConfigDirectoryIterator, OSIterator) 35 36// init 37// 38// 39 40IOReturn IOConfigDirectoryIterator::init(IOConfigDirectory *owner, 41 UInt32 testVal, UInt32 testMask) 42{ 43 IOReturn status = kIOReturnSuccess; 44 45 if( !OSIterator::init() ) 46 status = kIOReturnError; 47 48 if( status == kIOReturnSuccess ) 49 { 50 fDirectorySet = OSSet::withCapacity(2); 51 if( fDirectorySet == NULL ) 52 status = kIOReturnNoMemory; 53 } 54 55 int position = 0; 56 while( status == kIOReturnSuccess && position < owner->getNumEntries() ) 57 { 58 UInt32 value; 59 IOConfigDirectory * next; 60 61 status = owner->getIndexEntry( position, value ); 62 if( status == kIOReturnSuccess && (value & testMask) == testVal ) 63 { 64 status = owner->getIndexValue( position, next ); 65 if( status == kIOReturnSuccess ) 66 { 67 fDirectorySet->setObject( next ); 68 next->release(); 69 } 70 } 71 72 position++; 73 } 74 75 if( status == kIOReturnSuccess ) 76 { 77 fDirectoryIterator = OSCollectionIterator::withCollection( fDirectorySet ); 78 if( fDirectoryIterator == NULL ) 79 status = kIOReturnNoMemory; 80 } 81 82 return status; 83} 84 85// free 86// 87// 88 89void IOConfigDirectoryIterator::free() 90{ 91 if( fDirectoryIterator != NULL ) 92 { 93 fDirectoryIterator->release(); 94 fDirectoryIterator = NULL; 95 } 96 97 if( fDirectorySet != NULL ) 98 { 99 fDirectorySet->release(); 100 fDirectorySet = NULL; 101 } 102 103 OSIterator::free(); 104} 105 106// reset 107// 108// 109 110void IOConfigDirectoryIterator::reset() 111{ 112 fDirectoryIterator->reset(); 113} 114 115// isValid 116// 117// 118 119bool IOConfigDirectoryIterator::isValid() 120{ 121 return true; 122} 123 124// getNextObject 125// 126// 127 128OSObject *IOConfigDirectoryIterator::getNextObject() 129{ 130 return fDirectoryIterator->getNextObject(); 131} 132