1/* 2 * Copyright (c) 2004 Apple Computer, Inc. All Rights Reserved. 3 * 4 * @APPLE_LICENSE_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. Please obtain a copy of the License at 10 * http://www.opensource.apple.com/apsl/ and read it before using this 11 * file. 12 * 13 * The Original Code and all software distributed under the License are 14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 * Please see the License for the specific language governing rights and 19 * limitations under the License. 20 * 21 * @APPLE_LICENSE_HEADER_END@ 22 */ 23 24 25 26#ifndef __DATA_STORAGE_LIBRARY_H__ 27#define __DATA_STORAGE_LIBRARY_H__ 28 29 30 31#include <Security/Security.h> 32#include "AttachedInstance.h" 33#include "Mutex.h" 34 35#include <map> 36 37 38typedef std::map<CSSM_MODULE_HANDLE, AttachedInstance*> InstanceMap; 39 40// a class which creates, deallocates, and finds attached instances 41 42class DataStorageLibrary 43{ 44protected: 45 46 CSSM_SPI_ModuleEventHandler mEventHandler; 47 void* mCallbackContext; 48 InstanceMap mInstanceMap; 49 DynamicMutex mInstanceMapMutex; 50 51public: 52 static DataStorageLibrary* gDL; 53 static pthread_mutex_t *gGlobalLock; 54 55 DataStorageLibrary (pthread_mutex_t *globalLock, CSSM_SPI_ModuleEventHandler eventHandler, void* CssmNotifyCallbackCtx); 56 virtual ~DataStorageLibrary (); 57 58 void Attach (const CSSM_GUID *ModuleGuid, 59 const CSSM_VERSION *Version, 60 uint32 SubserviceID, 61 CSSM_SERVICE_TYPE SubserviceType, 62 CSSM_ATTACH_FLAGS AttachFlags, 63 CSSM_MODULE_HANDLE ModuleHandle, 64 CSSM_KEY_HIERARCHY KeyHierarchy, 65 const CSSM_GUID *CssmGuid, 66 const CSSM_GUID *ModuleManagerGuid, 67 const CSSM_GUID *CallerGuid, 68 const CSSM_UPCALLS *Upcalls, 69 CSSM_MODULE_FUNCS_PTR *FuncTbl); 70 71 void Detach (CSSM_MODULE_HANDLE moduleHandle); 72 73 virtual AttachedInstance* MakeAttachedInstance () = 0; 74 75 AttachedInstance* HandleToInstance (CSSM_MODULE_HANDLE handle); 76}; 77 78 79 80#endif 81