xref: /haiku/headers/private/package/hpkg/RepositoryWriterImpl.h (revision cbe0a0c436162d78cc3f92a305b64918c839d079)
1 /*
2  * Copyright 2011, Oliver Tappe <zooey@hirschkaefer.de>
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _PACKAGE__HPKG__PRIVATE__REPOSITORY_WRITER_IMPL_H_
6 #define _PACKAGE__HPKG__PRIVATE__REPOSITORY_WRITER_IMPL_H_
7 
8 
9 #include <Entry.h>
10 
11 #include <package/hpkg/PackageContentHandler.h>
12 #include <package/hpkg/RepositoryWriter.h>
13 #include <package/hpkg/WriterImplBase.h>
14 #include <package/PackageInfo.h>
15 
16 
17 namespace BPackageKit {
18 
19 
20 namespace BHPKG {
21 
22 
23 class BPackageEntry;
24 class BPackageEntryAttribute;
25 struct BPackageInfoAttributeValue;
26 
27 
28 namespace BPrivate {
29 
30 
31 struct hpkg_header;
32 
33 class RepositoryWriterImpl : public WriterImplBase {
34 	typedef	WriterImplBase		inherited;
35 
36 public:
37 								RepositoryWriterImpl(
38 									BRepositoryWriterListener* listener,
39 									BRepositoryInfo* repositoryInfo);
40 								~RepositoryWriterImpl();
41 
42 			status_t			Init(const char* fileName);
43 			status_t			AddPackage(const BEntry& packageEntry);
44 			status_t			AddPackageInfo(const BPackageInfo& packageInfo);
45 			status_t			Finish();
46 
47 private:
48 			status_t			_Init(const char* fileName);
49 			status_t			_AddPackage(const BEntry& packageEntry);
50 			status_t			_AddPackageInfo(
51 									const BPackageInfo& packageInfo);
52 			status_t			_Finish();
53 
54 			status_t			_RegisterCurrentPackageInfo();
55 			status_t			_WriteRepositoryInfo(hpkg_repo_header& header,
56 									uint64& _length);
57 			void				_WritePackageAttributes(
58 									hpkg_repo_header& header, uint64& _length);
59 
60 			struct PackageNameSet;
61 
62 private:
63 			BRepositoryWriterListener*	fListener;
64 
65 			BRepositoryInfo*	fRepositoryInfo;
66 
67 			BPackageInfo		fPackageInfo;
68 			uint32				fPackageCount;
69 			PackageNameSet*		fPackageNames;
70 };
71 
72 
73 }	// namespace BPrivate
74 
75 }	// namespace BHPKG
76 
77 }	// namespace BPackageKit
78 
79 
80 #endif	// _PACKAGE__HPKG__PRIVATE__REPOSITORY_WRITER_IMPL_H_
81