xref: /haiku/src/kits/package/hpkg/RepositoryWriter.cpp (revision 9f81ca838ce7b92b5689e57d3f86765db4705a7b)
14ee7d007SOliver Tappe /*
24ee7d007SOliver Tappe  * Copyright 2011, Oliver Tappe <zooey@hirschkaefer.de>
34ee7d007SOliver Tappe  * Distributed under the terms of the MIT License.
44ee7d007SOliver Tappe  */
54ee7d007SOliver Tappe 
64ee7d007SOliver Tappe 
74ee7d007SOliver Tappe #include <package/hpkg/RepositoryWriter.h>
84ee7d007SOliver Tappe 
94ee7d007SOliver Tappe #include <new>
104ee7d007SOliver Tappe 
114ee7d007SOliver Tappe #include <package/hpkg/RepositoryWriterImpl.h>
120d68f6afSOliver Tappe #include <package/RepositoryInfo.h>
134ee7d007SOliver Tappe 
144ee7d007SOliver Tappe 
154ee7d007SOliver Tappe namespace BPackageKit {
164ee7d007SOliver Tappe 
174ee7d007SOliver Tappe namespace BHPKG {
184ee7d007SOliver Tappe 
194ee7d007SOliver Tappe 
BRepositoryWriter(BRepositoryWriterListener * listener,BRepositoryInfo * repositoryInfo)200d68f6afSOliver Tappe BRepositoryWriter::BRepositoryWriter(BRepositoryWriterListener* listener,
21c2388992SOliver Tappe 	BRepositoryInfo* repositoryInfo)
224ee7d007SOliver Tappe 	:
230d68f6afSOliver Tappe 	fImpl(new (std::nothrow) RepositoryWriterImpl(listener, repositoryInfo))
244ee7d007SOliver Tappe {
254ee7d007SOliver Tappe }
264ee7d007SOliver Tappe 
274ee7d007SOliver Tappe 
~BRepositoryWriter()284ee7d007SOliver Tappe BRepositoryWriter::~BRepositoryWriter()
294ee7d007SOliver Tappe {
304ee7d007SOliver Tappe 	delete fImpl;
314ee7d007SOliver Tappe }
324ee7d007SOliver Tappe 
334ee7d007SOliver Tappe 
344ee7d007SOliver Tappe status_t
Init(const char * fileName)354ee7d007SOliver Tappe BRepositoryWriter::Init(const char* fileName)
364ee7d007SOliver Tappe {
374ee7d007SOliver Tappe 	if (fImpl == NULL)
384ee7d007SOliver Tappe 		return B_NO_MEMORY;
394ee7d007SOliver Tappe 
404ee7d007SOliver Tappe 	return fImpl->Init(fileName);
414ee7d007SOliver Tappe }
424ee7d007SOliver Tappe 
434ee7d007SOliver Tappe 
444ee7d007SOliver Tappe status_t
AddPackage(const BEntry & packageEntry)458b94d2ffSOliver Tappe BRepositoryWriter::AddPackage(const BEntry& packageEntry)
464ee7d007SOliver Tappe {
474ee7d007SOliver Tappe 	if (fImpl == NULL)
484ee7d007SOliver Tappe 		return B_NO_INIT;
494ee7d007SOliver Tappe 
508b94d2ffSOliver Tappe 	return fImpl->AddPackage(packageEntry);
514ee7d007SOliver Tappe }
524ee7d007SOliver Tappe 
534ee7d007SOliver Tappe 
544ee7d007SOliver Tappe status_t
AddPackageInfo(const BPackageInfo & packageInfo)55*50ae264dSOliver Tappe BRepositoryWriter::AddPackageInfo(const BPackageInfo& packageInfo)
56*50ae264dSOliver Tappe {
57*50ae264dSOliver Tappe 	if (fImpl == NULL)
58*50ae264dSOliver Tappe 		return B_NO_INIT;
59*50ae264dSOliver Tappe 
60*50ae264dSOliver Tappe 	return fImpl->AddPackageInfo(packageInfo);
61*50ae264dSOliver Tappe }
62*50ae264dSOliver Tappe 
63*50ae264dSOliver Tappe 
64*50ae264dSOliver Tappe status_t
Finish()654ee7d007SOliver Tappe BRepositoryWriter::Finish()
664ee7d007SOliver Tappe {
674ee7d007SOliver Tappe 	if (fImpl == NULL)
684ee7d007SOliver Tappe 		return B_NO_INIT;
694ee7d007SOliver Tappe 
704ee7d007SOliver Tappe 	return fImpl->Finish();
714ee7d007SOliver Tappe }
724ee7d007SOliver Tappe 
734ee7d007SOliver Tappe 
744ee7d007SOliver Tappe }	// namespace BHPKG
754ee7d007SOliver Tappe 
764ee7d007SOliver Tappe }	// namespace BPackageKit
77