xref: /haiku/src/kits/storage/disk_device/PartitionDelegate.h (revision 1e60bdeab63fa7a57bc9a55b032052e95a18bd2c)
1 /*
2  * Copyright 2007, Ingo Weinhold, bonefish@users.sf.net.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _PARTITION_DELEGATE_H
6 #define _PARTITION_DELEGATE_H
7 
8 #include <DiskSystemAddOn.h>
9 #include <MutablePartition.h>
10 #include <Partition.h>
11 
12 
13 class BDiskSystemAddOn;
14 class BPartitionHandle;
15 
16 
17 class BPartition::Delegate {
18 public:
19 								Delegate(BPartition* partition);
20 								~Delegate();
21 
22 			BPartition*			Partition() const	{ return fPartition; }
23 
24 			BMutablePartition*	MutablePartition();
25 			const BMutablePartition* MutablePartition() const;
26 
27 			status_t			InitHierarchy(
28 									const user_partition_data* partitionData,
29 									Delegate* parent);
30 			status_t			InitAfterHierarchy();
31 
32 			const user_partition_data* PartitionData() const;
33 
34 			Delegate*			ChildAt(int32 index) const;
35 			int32				CountChildren() const;
36 
37 			bool				IsModified() const;
38 
39 			uint32				SupportedOperations(uint32 mask);
40 			uint32				SupportedChildOperations(Delegate* child,
41 									uint32 mask);
42 
43 			// Self Modification
44 
45 			status_t			Defragment();
46 			status_t			Repair(bool checkOnly);
47 
48 			status_t			ValidateResize(off_t* size) const;
49 			status_t			ValidateResizeChild(Delegate* child,
50 									off_t* size) const;
51 			status_t			Resize(off_t size);
52 			status_t			ResizeChild(Delegate* child, off_t size);
53 
54 			status_t			ValidateMove(off_t* offset) const;
55 			status_t			ValidateMoveChild(Delegate* child,
56 									off_t* offset) const;
57 			status_t			Move(off_t offset);
58 			status_t			MoveChild(Delegate* child, off_t offset);
59 
60 			status_t			ValidateSetContentName(BString* name) const;
61 			status_t			ValidateSetName(Delegate* child,
62 									BString* name) const;
63 			status_t			SetContentName(const char* name);
64 			status_t			SetName(Delegate* child, const char* name);
65 
66 			status_t			ValidateSetType(Delegate* child,
67 									const char* type) const;
68 			status_t			SetType(Delegate* child, const char* type);
69 
70 			status_t			SetContentParameters(const char* parameters);
71 			status_t			SetParameters(Delegate* child,
72 									const char* parameters);
73 
74 			status_t			GetParameterEditor(
75 									B_PARAMETER_EDITOR_TYPE type,
76 									BPartitionParameterEditor** editor) const;
77 			status_t			GetNextSupportedChildType(Delegate* child,
78 									int32* cookie, BString* type) const;
79 			bool				IsSubSystem(Delegate* child,
80 									const char* diskSystem) const;
81 
82 			bool				CanInitialize(const char* diskSystem) const;
83 			status_t			ValidateInitialize(const char* diskSystem,
84 									BString* name, const char* parameters);
85 			status_t			Initialize(const char* diskSystem,
86 									const char* name,
87 									const char* parameters);
88 			status_t			Uninitialize();
89 
90 			// Modification of child partitions
91 
92 			status_t			GetPartitioningInfo(BPartitioningInfo* info);
93 
94 			status_t			ValidateCreateChild(off_t* start, off_t* size,
95 									const char* type, BString* name,
96 									const char* parameters) const;
97 			status_t			CreateChild(off_t start, off_t size,
98 									const char* type, const char* name,
99 									const char* parameters, BPartition** child);
100 
101 			status_t			DeleteChild(Delegate* child);
102 
103 private:
104 			void				_FreeHandle();
105 
106 private:
107 			BPartition*			fPartition;
108 			BMutablePartition	fMutablePartition;
109 			BDiskSystemAddOn*	fDiskSystem;
110 			BPartitionHandle*	fPartitionHandle;
111 };
112 
113 
114 #endif	// _PARTITION_DELEGATE_H
115 
116