1//----------------------------------------------------------------------
2//  This software is part of the OpenBeOS distribution and is covered
3//  by the OpenBeOS license.
4//
5//  Copyright (c) 2003 Tyler Dauwalder, tyler@dauwalder.net
6//----------------------------------------------------------------------
7
8/*! \file PhysicalPartitionAllocator.h
9
10	Udf physical partition allocator (declarations).
11*/
12
13#ifndef _PHYSICAL_PARTITION_ALLOCATOR_H
14#define _PHYSICAL_PARTITION_ALLOCATOR_H
15
16#include <list>
17
18#include "Allocator.h"
19#include "UdfStructures.h"
20
21/*! \brief Allocates blocks and extents from a Udf physical partition.
22*/
23class PhysicalPartitionAllocator {
24public:
25	PhysicalPartitionAllocator(uint16 number, uint32 offset, Allocator &allocator);
26
27	status_t GetNextBlock(uint32 &block, uint32 &physicalBlock);
28	status_t GetNextExtent(uint32 length, bool contiguous, Udf::long_address &extent,
29	                       Udf::extent_address &physicalExtent = dummyExtent);
30	status_t GetNextExtents(off_t length, std::list<Udf::long_address> &extents,
31	                        std::list<Udf::extent_address> &physicalExtents);
32
33
34	uint16 PartitionNumber() const { return fNumber; }
35	uint32 Length() const;
36private:
37	static Udf::extent_address dummyExtent;
38	uint16 fNumber;	//!< The partition number of this partition
39	uint32 fOffset;	//!< The offset of the start of this partition in physical space
40	Allocator &fAllocator;
41};
42
43#endif	// _PHYSICAL_PARTITION_ALLOCATOR_H
44