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