xref: /haiku/headers/private/storage/DiskDeviceList.h (revision 93aeb8c3bc3f13cb1f282e3e749258a23790d947)
1 //----------------------------------------------------------------------
2 //  This software is part of the Haiku distribution and is covered
3 //  by the MIT license.
4 //---------------------------------------------------------------------
5 #ifndef _DISK_DEVICE_LIST_H
6 #define _DISK_DEVICE_LIST_H
7 
8 
9 #include <DiskDeviceVisitor.h>
10 #include <Handler.h>
11 #include <ObjectList.h>
12 
13 
14 class BDiskDevice;
15 class BDiskDeviceRoster;
16 class BPartition;
17 class BSession;
18 
19 class BDiskDeviceList : public BHandler {
20 public:
21 	BDiskDeviceList(bool useOwnLocker = true);
22 	virtual ~BDiskDeviceList();
23 
24 	virtual void MessageReceived(BMessage *message);
25 	virtual void SetNextHandler(BHandler *handler);
26 
27 	status_t Fetch();
28 	void Unset();
29 
30 	bool Lock();
31 	void Unlock();
32 
33 	int32 CountDevices() const;
34 	BDiskDevice *DeviceAt(int32 index) const;
35 
36 	BDiskDevice *VisitEachDevice(BDiskDeviceVisitor *visitor);
37 	BPartition *VisitEachPartition(BDiskDeviceVisitor *visitor);
38 
39 	BPartition *VisitEachMountedPartition(BDiskDeviceVisitor *visitor);
40 	BPartition *VisitEachMountablePartition(BDiskDeviceVisitor *visitor);
41 
42 	BDiskDevice *DeviceWithID(partition_id id) const;
43 	BPartition *PartitionWithID(partition_id id) const;
44 
45 	virtual void MountPointMoved(BPartition *partition);
46 	virtual void PartitionMounted(BPartition *partition);
47 	virtual void PartitionUnmounted(BPartition *partition);
48 	virtual void PartitionInitialized(BPartition *partition);
49 	virtual void PartitionResized(BPartition *partition);
50 	virtual void PartitionMoved(BPartition *partition);
51 	virtual void PartitionCreated(BPartition *partition);
52 	virtual void PartitionDeleted(BPartition *partition,
53 		partition_id partitionID);
54 	virtual void PartitionDefragmented(BPartition *partition);
55 	virtual void PartitionRepaired(BPartition *partition);
56 	virtual void PartitionChanged(BPartition *partition, uint32 event);
57 	virtual void MediaChanged(BDiskDevice *device);
58 	virtual void DeviceAdded(BDiskDevice *device);
59 	virtual void DeviceRemoved(BDiskDevice *device);
60 
61 private:
62 	status_t _StartWatching();
63 	void _StopWatching();
64 
65 	void _MountPointMoved(BMessage *message);
66 	void _PartitionMounted(BMessage *message);
67 	void _PartitionUnmounted(BMessage *message);
68 	void _PartitionInitialized(BMessage *message);
69 	void _PartitionResized(BMessage *message);
70 	void _PartitionMoved(BMessage *message);
71 	void _PartitionCreated(BMessage *message);
72 	void _PartitionDeleted(BMessage *message);
73 	void _PartitionDefragmented(BMessage *message);
74 	void _PartitionRepaired(BMessage *message);
75 	void _MediaChanged(BMessage *message);
76 	void _DeviceAdded(BMessage *message);
77 	void _DeviceRemoved(BMessage *message);
78 
79 	BDiskDevice *_FindDevice(BMessage *message);
80 	BPartition *_FindPartition(BMessage *message);
81 
82 	BDiskDevice *_UpdateDevice(BMessage *message);
83 
84 private:
85 	BLocker						*fLocker;
86 	BObjectList<BDiskDevice>	fDevices;
87 	bool						fSubscribed;
88 };
89 
90 #endif	// _DISK_DEVICE_LIST_H
91