1 /* 2 * Copyright 2007, Ingo Weinhold, bonefish@users.sf.net. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _DISK_SYSTEM_ADD_ON_MANAGER_H 6 #define _DISK_SYSTEM_ADD_ON_MANAGER_H 7 8 #include <FindDirectory.h> 9 #include <List.h> 10 #include <Locker.h> 11 12 13 class BDiskSystemAddOn; 14 15 16 namespace BPrivate { 17 18 19 class DiskSystemAddOnManager { 20 public: 21 static DiskSystemAddOnManager* Default(); 22 23 bool Lock(); 24 void Unlock(); 25 26 // load/unload all disk system add-ons 27 status_t LoadDiskSystems(); 28 void UnloadDiskSystems(); 29 30 // manager must be locked 31 int32 CountAddOns() const; 32 BDiskSystemAddOn* AddOnAt(int32 index) const; 33 34 // manager will be locked 35 BDiskSystemAddOn* GetAddOn(const char* name); 36 void PutAddOn(BDiskSystemAddOn* addOn); 37 38 private: 39 struct AddOnImage; 40 struct AddOn; 41 struct StringSet; 42 43 DiskSystemAddOnManager(); 44 45 static void _InitSingleton(); 46 47 AddOn* _AddOnAt(int32 index) const; 48 void _PutAddOn(int32 index); 49 50 status_t _LoadAddOns(StringSet& alreadyLoaded, 51 directory_which directory); 52 53 private: 54 mutable BLocker fLock; 55 BList fAddOns; 56 BList fAddOnsToBeUnloaded; 57 int32 fLoadCount; 58 59 static DiskSystemAddOnManager* sManager; 60 }; 61 62 63 } // namespace BPrivate 64 65 using BPrivate::DiskSystemAddOnManager; 66 67 #endif // _DISK_SYSTEM_ADD_ON_MANAGER_H 68