xref: /haiku/src/kits/storage/disk_device/PartitionDelegate.h (revision 54a5f0b7318666dcd83c4ecab416218b15dd669f)
123b03456SIngo Weinhold /*
223b03456SIngo Weinhold  * Copyright 2007, Ingo Weinhold, bonefish@users.sf.net.
323b03456SIngo Weinhold  * Distributed under the terms of the MIT License.
423b03456SIngo Weinhold  */
523b03456SIngo Weinhold #ifndef _PARTITION_DELEGATE_H
623b03456SIngo Weinhold #define _PARTITION_DELEGATE_H
723b03456SIngo Weinhold 
823b03456SIngo Weinhold #include <MutablePartition.h>
923b03456SIngo Weinhold #include <Partition.h>
1023b03456SIngo Weinhold 
1123b03456SIngo Weinhold 
1223b03456SIngo Weinhold class BDiskSystemAddOn;
1323b03456SIngo Weinhold class BPartitionHandle;
1423b03456SIngo Weinhold 
1523b03456SIngo Weinhold 
1623b03456SIngo Weinhold class BPartition::Delegate {
1723b03456SIngo Weinhold public:
1823b03456SIngo Weinhold 								Delegate(BPartition* partition);
1923b03456SIngo Weinhold 								~Delegate();
2023b03456SIngo Weinhold 
2123b03456SIngo Weinhold 			BPartition*			Partition() const	{ return fPartition; }
2223b03456SIngo Weinhold 
2323b03456SIngo Weinhold 			BMutablePartition*	MutablePartition();
2423b03456SIngo Weinhold 			const BMutablePartition* MutablePartition() const;
2523b03456SIngo Weinhold 
2623b03456SIngo Weinhold 			status_t			InitHierarchy(
2723b03456SIngo Weinhold 									const user_partition_data* partitionData,
2823b03456SIngo Weinhold 									Delegate* parent);
2923b03456SIngo Weinhold 			status_t			InitAfterHierarchy();
3023b03456SIngo Weinhold 
3123b03456SIngo Weinhold 			const user_partition_data* PartitionData() const;
3223b03456SIngo Weinhold 
3323b03456SIngo Weinhold 			Delegate*			ChildAt(int32 index) const;
3423b03456SIngo Weinhold 			int32				CountChildren() const;
3523b03456SIngo Weinhold 
36*54a5f0b7SIngo Weinhold 			bool				IsModified() const;
37*54a5f0b7SIngo Weinhold 
3823b03456SIngo Weinhold 			uint32				SupportedOperations(uint32 mask);
3923b03456SIngo Weinhold 			uint32				SupportedChildOperations(Delegate* child,
4023b03456SIngo Weinhold 									uint32 mask);
4123b03456SIngo Weinhold 
4223b03456SIngo Weinhold 			// Self Modification
4323b03456SIngo Weinhold 
4423b03456SIngo Weinhold 			status_t			Defragment();
4523b03456SIngo Weinhold 			status_t			Repair(bool checkOnly);
4623b03456SIngo Weinhold 
4723b03456SIngo Weinhold 			status_t			ValidateResize(off_t* size) const;
4823b03456SIngo Weinhold 			status_t			ValidateResizeChild(Delegate* child,
4923b03456SIngo Weinhold 									off_t* size) const;
5023b03456SIngo Weinhold 			status_t			Resize(off_t size);
5123b03456SIngo Weinhold 			status_t			ResizeChild(Delegate* child, off_t size);
5223b03456SIngo Weinhold 
5323b03456SIngo Weinhold 			status_t			ValidateMove(off_t* offset) const;
5423b03456SIngo Weinhold 			status_t			ValidateMoveChild(Delegate* child,
5523b03456SIngo Weinhold 									off_t* offset) const;
5623b03456SIngo Weinhold 			status_t			Move(off_t offset);
5723b03456SIngo Weinhold 			status_t			MoveChild(Delegate* child, off_t offset);
5823b03456SIngo Weinhold 
5923b03456SIngo Weinhold 			status_t			ValidateSetContentName(BString* name) const;
6023b03456SIngo Weinhold 			status_t			ValidateSetName(Delegate* child,
6123b03456SIngo Weinhold 									BString* name) const;
6223b03456SIngo Weinhold 			status_t			SetContentName(const char* name);
6323b03456SIngo Weinhold 			status_t			SetName(Delegate* child, const char* name);
6423b03456SIngo Weinhold 
6523b03456SIngo Weinhold 			status_t			ValidateSetType(Delegate* child,
6623b03456SIngo Weinhold 									const char* type) const;
6723b03456SIngo Weinhold 			status_t			SetType(Delegate* child, const char* type);
6823b03456SIngo Weinhold 
6923b03456SIngo Weinhold 			status_t			GetContentParameterEditor(
7023b03456SIngo Weinhold 									BDiskDeviceParameterEditor** editor) const;
7123b03456SIngo Weinhold 			status_t			GetParameterEditor(Delegate* child,
7223b03456SIngo Weinhold 									BDiskDeviceParameterEditor** editor) const;
7323b03456SIngo Weinhold 			status_t			SetContentParameters(const char* parameters);
7423b03456SIngo Weinhold 			status_t			SetParameters(Delegate* child,
7523b03456SIngo Weinhold 									const char* parameters);
7623b03456SIngo Weinhold 
7723b03456SIngo Weinhold 			status_t			GetNextSupportedChildType(Delegate* child,
7823b03456SIngo Weinhold 									int32 *cookie, BString* type) const;
7923b03456SIngo Weinhold 			bool				IsSubSystem(Delegate* child,
8023b03456SIngo Weinhold 									const char* diskSystem) const;
8123b03456SIngo Weinhold 
8223b03456SIngo Weinhold 			bool				CanInitialize(const char* diskSystem) const;
8323b03456SIngo Weinhold 			status_t			GetInitializationParameterEditor(
8423b03456SIngo Weinhold 									const char* system,
8523b03456SIngo Weinhold 									BDiskDeviceParameterEditor** editor) const;
8623b03456SIngo Weinhold 			status_t			ValidateInitialize(const char* diskSystem,
8723b03456SIngo Weinhold 									BString* name, const char* parameters);
8823b03456SIngo Weinhold 			status_t			Initialize(const char* diskSystem,
8923b03456SIngo Weinhold 									const char* name,
9023b03456SIngo Weinhold 									const char* parameters);
9123b03456SIngo Weinhold 			status_t			Uninitialize();
9223b03456SIngo Weinhold 
9323b03456SIngo Weinhold 			// Modification of child partitions
9423b03456SIngo Weinhold 
9523b03456SIngo Weinhold 			status_t			GetPartitioningInfo(BPartitioningInfo* info);
9623b03456SIngo Weinhold 
9723b03456SIngo Weinhold 			status_t			GetChildCreationParameterEditor(
9823b03456SIngo Weinhold 									const char* system,
9923b03456SIngo Weinhold 									BDiskDeviceParameterEditor** editor) const;
10023b03456SIngo Weinhold 			status_t			ValidateCreateChild(off_t* start, off_t* size,
10123b03456SIngo Weinhold 									const char* type, BString* name,
10223b03456SIngo Weinhold 									const char* parameters) const;
10323b03456SIngo Weinhold 			status_t			CreateChild(off_t start, off_t size,
10423b03456SIngo Weinhold 									const char* type, const char* name,
10523b03456SIngo Weinhold 									const char* parameters, BPartition** child);
10623b03456SIngo Weinhold 
10723b03456SIngo Weinhold 			status_t			DeleteChild(Delegate* child);
10823b03456SIngo Weinhold 
10923b03456SIngo Weinhold private:
11023b03456SIngo Weinhold 			void				_FreeHandle();
11123b03456SIngo Weinhold 
11223b03456SIngo Weinhold private:
11323b03456SIngo Weinhold 			BPartition*			fPartition;
11423b03456SIngo Weinhold 			BMutablePartition	fMutablePartition;
11523b03456SIngo Weinhold 			BDiskSystemAddOn*	fDiskSystem;
11623b03456SIngo Weinhold 			BPartitionHandle*	fPartitionHandle;
11723b03456SIngo Weinhold };
11823b03456SIngo Weinhold 
11923b03456SIngo Weinhold 
12023b03456SIngo Weinhold #endif	// _PARTITION_DELEGATE_H
121