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 <MutablePartition.h> 9 #include <Partition.h> 10 11 12 class BDiskSystemAddOn; 13 class BPartitionHandle; 14 15 16 class BPartition::Delegate { 17 public: 18 Delegate(BPartition* partition); 19 ~Delegate(); 20 21 BPartition* Partition() const { return fPartition; } 22 23 BMutablePartition* MutablePartition(); 24 const BMutablePartition* MutablePartition() const; 25 26 status_t InitHierarchy( 27 const user_partition_data* partitionData, 28 Delegate* parent); 29 status_t InitAfterHierarchy(); 30 31 const user_partition_data* PartitionData() const; 32 33 Delegate* ChildAt(int32 index) const; 34 int32 CountChildren() const; 35 36 bool IsModified() const; 37 38 uint32 SupportedOperations(uint32 mask); 39 uint32 SupportedChildOperations(Delegate* child, 40 uint32 mask); 41 42 // Self Modification 43 44 status_t Defragment(); 45 status_t Repair(bool checkOnly); 46 47 status_t ValidateResize(off_t* size) const; 48 status_t ValidateResizeChild(Delegate* child, 49 off_t* size) const; 50 status_t Resize(off_t size); 51 status_t ResizeChild(Delegate* child, off_t size); 52 53 status_t ValidateMove(off_t* offset) const; 54 status_t ValidateMoveChild(Delegate* child, 55 off_t* offset) const; 56 status_t Move(off_t offset); 57 status_t MoveChild(Delegate* child, off_t offset); 58 59 status_t ValidateSetContentName(BString* name) const; 60 status_t ValidateSetName(Delegate* child, 61 BString* name) const; 62 status_t SetContentName(const char* name); 63 status_t SetName(Delegate* child, const char* name); 64 65 status_t ValidateSetType(Delegate* child, 66 const char* type) const; 67 status_t SetType(Delegate* child, const char* type); 68 69 status_t GetContentParameterEditor( 70 BDiskDeviceParameterEditor** editor) const; 71 status_t GetParameterEditor(Delegate* child, 72 BDiskDeviceParameterEditor** editor) const; 73 status_t SetContentParameters(const char* parameters); 74 status_t SetParameters(Delegate* child, 75 const char* parameters); 76 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 GetInitializationParameterEditor( 84 const char* system, 85 BDiskDeviceParameterEditor** editor) const; 86 status_t ValidateInitialize(const char* diskSystem, 87 BString* name, const char* parameters); 88 status_t Initialize(const char* diskSystem, 89 const char* name, 90 const char* parameters); 91 status_t Uninitialize(); 92 93 // Modification of child partitions 94 95 status_t GetPartitioningInfo(BPartitioningInfo* info); 96 97 status_t GetChildCreationParameterEditor( 98 const char* system, 99 BDiskDeviceParameterEditor** editor) const; 100 status_t ValidateCreateChild(off_t* start, off_t* size, 101 const char* type, BString* name, 102 const char* parameters) const; 103 status_t CreateChild(off_t start, off_t size, 104 const char* type, const char* name, 105 const char* parameters, BPartition** child); 106 107 status_t DeleteChild(Delegate* child); 108 109 private: 110 void _FreeHandle(); 111 112 private: 113 BPartition* fPartition; 114 BMutablePartition fMutablePartition; 115 BDiskSystemAddOn* fDiskSystem; 116 BPartitionHandle* fPartitionHandle; 117 }; 118 119 120 #endif // _PARTITION_DELEGATE_H 121