xref: /haiku/src/kits/storage/disk_device/DiskDeviceJobGenerator.h (revision 68ea01249e1e2088933cb12f9c28d4e5c5d1c9ef)
1 /*
2  * Copyright 2003-2007, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _DISK_DEVICE_JOB_GENERATOR_H
6 #define _DISK_DEVICE_JOB_GENERATOR_H
7 
8 #include <DiskDeviceDefs.h>
9 
10 
11 class BDiskDevice;
12 class BMutablePartition;
13 class BPartition;
14 
15 
16 namespace BPrivate {
17 
18 
19 class DiskDeviceJob;
20 class DiskDeviceJobQueue;
21 class PartitionReference;
22 
23 
24 class DiskDeviceJobGenerator {
25 public:
26 								DiskDeviceJobGenerator(BDiskDevice* device,
27 									DiskDeviceJobQueue* jobQueue);
28 								~DiskDeviceJobGenerator();
29 
30 			status_t			GenerateJobs();
31 
32 private:
33 			status_t			_AddJob(DiskDeviceJob* job);
34 
35 			status_t			_GenerateCleanupJobs(BPartition* partition);
36 			status_t			_GeneratePlacementJobs(BPartition* partition);
37 			status_t			_GenerateChildPlacementJobs(
38 									BPartition* partition);
39 			status_t			_GenerateRemainingJobs(BPartition* parent,
40 									BPartition* partition);
41 
42 			BMutablePartition*	_GetMutablePartition(BPartition* partition);
43 
44 			status_t			_GenerateInitializeJob(BPartition* partition);
45 			status_t			_GenerateUninitializeJob(BPartition* partition);
46 			status_t			_GenerateSetContentNameJob(
47 									BPartition* partition);
48 			status_t			_GenerateSetContentParametersJob(
49 									BPartition* partition);
50 			status_t			_GenerateDefragmentJob(BPartition* partition);
51 			status_t			_GenerateRepairJob(BPartition* partition,
52 									bool repair);
53 
54 			status_t			_GenerateCreateChildJob(BPartition* parent,
55 									BPartition* partition);
56 			status_t			_GenerateDeleteChildJob(BPartition* parent,
57 									BPartition* partition);
58 			status_t			_GenerateResizeJob(BPartition* partition);
59 			status_t			_GenerateMoveJob(BPartition* partition);
60 			status_t 			_GenerateSetNameJob(BPartition* parent,
61 									BPartition* partition);
62 			status_t			_GenerateSetTypeJob(BPartition* parent,
63 									BPartition* partition);
64 			status_t			_GenerateSetParametersJob(BPartition* parent,
65 									BPartition* partition);
66 
67 			status_t			_CollectContentsToMove(BPartition* partition);
68 			status_t			_PushContentsToMove(BPartition* partition);
69 
70 			status_t			_GetPartitionReference(BPartition* partition,
71 									PartitionReference*& reference);
72 
73 	static	int					_CompareMoveInfoPosition(const void* _a,
74 									const void* _b);
75 
76 private:
77 			struct MoveInfo;
78 			struct PartitionRefInfo;
79 
80 			BDiskDevice*		fDevice;
81 			DiskDeviceJobQueue*	fJobQueue;
82 			MoveInfo*			fMoveInfos;
83 			int32				fPartitionCount;
84 			PartitionRefInfo*	fPartitionRefs;
85 			PartitionReference** fContentsToMove;
86 			int32				fContentsToMoveCount;
87 };
88 
89 
90 }	// namespace BPrivate
91 
92 using BPrivate::DiskDeviceJobGenerator;
93 
94 #endif	// _DISK_DEVICE_JOB_GENERATOR_H
95