1/*
2 * Copyright 2007, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef _MUTABLE_PARTITION_H
6#define _MUTABLE_PARTITION_H
7
8#include <List.h>
9#include <Partition.h>
10
11
12struct user_partition_data;
13
14
15class BMutablePartition {
16public:
17			void				UninitializeContents();
18
19			off_t				Offset() const;
20			void				SetOffset(off_t offset);
21
22			off_t				Size() const;
23			void				SetSize(off_t size);
24
25			off_t				ContentSize() const;
26			void				SetContentSize(off_t size);
27
28			off_t				BlockSize() const;
29			void				SetBlockSize(off_t blockSize);
30
31			uint32				Status() const;
32			void				SetStatus(uint32 status);
33
34			uint32				Flags() const;
35			void				SetFlags(uint32 flags);
36			void				ClearFlags(uint32 flags);
37
38			dev_t				VolumeID() const;
39			void				SetVolumeID(dev_t volumeID);
40
41			int32				Index() const;
42
43			const char*			Name() const;
44			status_t			SetName(const char* name);
45
46			BString				ContentName() const;
47			status_t			SetContentName(const char* name);
48
49			const char*			Type() const;
50			status_t			SetType(const char* type);
51
52			const char*			ContentType() const;
53			status_t			SetContentType(const char* type);
54
55			const char*			Parameters() const;
56			status_t			SetParameters(const char* parameters);
57
58			const char*			ContentParameters() const;
59			status_t			SetContentParameters(const char* parameters);
60
61			status_t			CreateChild(int32 index,
62									BMutablePartition** child);
63			status_t			CreateChild(int32 index, const char* type,
64									const char* name, const char* parameters,
65									BMutablePartition** child);
66			status_t			DeleteChild(int32 index);
67			status_t			DeleteChild(BMutablePartition* child);
68			void				DeleteAllChildren();
69
70			BMutablePartition*	Parent() const;
71			BMutablePartition*	ChildAt(int32 index) const;
72			int32				CountChildren() const;
73			int32				IndexOfChild(BMutablePartition* child) const;
74
75			void				SetChangeFlags(uint32 flags);
76			uint32				ChangeFlags() const;
77			void				Changed(uint32 flags, uint32 clearFlags = 0);
78
79			// for the partitioning system managing the parent
80			void*				ChildCookie() const;
81			void				SetChildCookie(void* cookie);
82
83private:
84								BMutablePartition(
85									BPartition::Delegate* delegate);
86								~BMutablePartition();
87
88			status_t			Init(const user_partition_data* partitionData,
89									BMutablePartition* parent);
90
91			const user_partition_data* PartitionData() const;
92
93private:
94			friend class BPartition::Delegate;
95
96			BPartition::Delegate* GetDelegate() const;
97
98			BPartition::Delegate* fDelegate;
99			user_partition_data* fData;
100			BMutablePartition*	fParent;
101			BList				fChildren;
102			uint32				fChangeFlags;
103			void*				fChildCookie;
104};
105
106
107#endif	// _MUTABLE_PARTITION_H
108