1/* 2 * Copyright (c) 1998-2008 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/*! @class IOFWUserObjectExporter 24 @discussion An IOFWUserObjectExporter is for internal use only. You should never subclass IOFWUserObjectExporter 25*/ 26 27 namespace IOFireWireLib 28 { 29 typedef UInt32 UserObjectHandle; 30 } 31 32#ifdef KERNEL 33 34 class IOFWUserObjectExporter : public OSObject 35 { 36 OSDeclareDefaultStructors (IOFWUserObjectExporter ) 37 38 public : 39 40 typedef void (*CleanupFunction)( const OSObject * obj ); 41 typedef void (*CleanupFunctionWithExporter)( const OSObject * obj, IOFWUserObjectExporter * ); 42 43 private : 44 45 unsigned fCapacity; 46 unsigned fObjectCount; 47 const OSObject ** fObjects; 48 CleanupFunctionWithExporter * fCleanupFunctions; 49 IOLock * fLock; 50 OSObject * fOwner; 51 52 public : 53 54 static IOFWUserObjectExporter * createWithOwner( OSObject * owner ); 55 bool initWithOwner( OSObject * owner ); 56 57 virtual bool init(); 58 59 virtual void free (); 60 virtual bool serialize ( OSSerialize * s ) const; 61 62 // me 63 IOReturn addObject ( OSObject * obj, CleanupFunction cleanup, IOFireWireLib::UserObjectHandle * outHandle ); 64 void removeObject ( IOFireWireLib::UserObjectHandle handle ); 65 66 // the returned object is retained! This is for thread safety.. if someone else released 67 // the object from the pool after you got it, you be in for Trouble 68 // Release the returned value when you're done!! 69 const OSObject * lookupObject ( IOFireWireLib::UserObjectHandle handle ) const; 70 const OSObject * lookupObjectForType( IOFireWireLib::UserObjectHandle handle, const OSMetaClass * toType ) const; 71 void removeAllObjects (); 72 73 void lock () const; 74 void unlock () const; 75 76 OSObject * getOwner() const; 77 78 const IOFireWireLib::UserObjectHandle lookupHandle ( OSObject * object ) const; 79 80 // don't subclass, but just in case someone does... 81 82 private: 83 84 OSMetaClassDeclareReservedUnused(IOFWUserObjectExporter, 0); 85 OSMetaClassDeclareReservedUnused(IOFWUserObjectExporter, 1); 86 OSMetaClassDeclareReservedUnused(IOFWUserObjectExporter, 2); 87 OSMetaClassDeclareReservedUnused(IOFWUserObjectExporter, 3); 88 OSMetaClassDeclareReservedUnused(IOFWUserObjectExporter, 4); 89 OSMetaClassDeclareReservedUnused(IOFWUserObjectExporter, 5); 90 OSMetaClassDeclareReservedUnused(IOFWUserObjectExporter, 6); 91 OSMetaClassDeclareReservedUnused(IOFWUserObjectExporter, 7); 92 93 }; 94 95#endif 96