xref: /haiku/headers/os/package/hpkg/PackageDataReader.h (revision b46615c55ad2c8fe6de54412055a0713da3d610a)
1 /*
2  * Copyright 2009,2011, Haiku, Inc.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _PACKAGE__HPKG__PACKAGE_DATA_READER_H_
6 #define _PACKAGE__HPKG__PACKAGE_DATA_READER_H_
7 
8 
9 #include <package/hpkg/DataReader.h>
10 
11 
12 namespace BPackageKit {
13 
14 namespace BHPKG {
15 
16 
17 class BBufferCache;
18 class BDataOutput;
19 class BPackageData;
20 
21 
22 class BPackageDataReader : public BDataReader {
23 public:
24 								BPackageDataReader(BDataReader* dataReader);
25 	virtual						~BPackageDataReader();
26 
27 	virtual	status_t			Init(const BPackageData& data) = 0;
28 
29 	virtual	status_t			ReadData(off_t offset, void* buffer,
30 									size_t size);
31 	virtual	status_t			ReadDataToOutput(off_t offset, size_t size,
32 									BDataOutput* output) = 0;
33 
34 	virtual	uint64				Size() const = 0;
35 	virtual	size_t				BlockSize() const = 0;
36 
37 protected:
38 			BDataReader*			fDataReader;
39 };
40 
41 
42 class BPackageDataReaderFactory {
43 public:
44 								BPackageDataReaderFactory(
45 									BBufferCache* bufferCache);
46 
47 			status_t			CreatePackageDataReader(BDataReader* dataReader,
48 									const BPackageData& data,
49 									BPackageDataReader*& _reader);
50 
51 private:
52 			BBufferCache*		fBufferCache;
53 };
54 
55 
56 }	// namespace BHPKG
57 
58 }	// namespace BPackageKit
59 
60 
61 #endif	// _PACKAGE__HPKG__PACKAGE_DATA_READER_H_
62