mirror of
https://review.haiku-os.org/haiku
synced 2025-01-23 23:04:48 +01:00
0d6b3b20e1
* added class BPackageInfo, which contains packaging attributes of a package (the values relevant for package management) * implemented parser (mostly) for reading a BPackageInfo from a config file (.PackageInfo) in order to pass them on to the PackageWriter when creating a package * pulled hpkg-related stuff from bin/package into the package kit * adjusted packagefs-Volume to skip .PackageInfo files when populating the mountpoint, as those files shouldn't appear as part of an activated package git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40301 a95241bf-73f2-0310-859d-f6bbb57e9c96
106 lines
2.1 KiB
C++
106 lines
2.1 KiB
C++
/*
|
|
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
|
* Distributed under the terms of the MIT License.
|
|
*/
|
|
#ifndef _PACKAGE__HPKG__BUFFER_CACHE_H_
|
|
#define _PACKAGE__HPKG__BUFFER_CACHE_H_
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <util/DoublyLinkedList.h>
|
|
|
|
|
|
namespace BPackageKit {
|
|
|
|
namespace BHaikuPackage {
|
|
|
|
namespace BPrivate {
|
|
|
|
|
|
class CachedBuffer : public DoublyLinkedListLinkImpl<CachedBuffer> {
|
|
public:
|
|
CachedBuffer(size_t size);
|
|
~CachedBuffer();
|
|
|
|
void* Buffer() const { return fBuffer; }
|
|
size_t Size() const { return fSize; }
|
|
|
|
|
|
// implementation private
|
|
CachedBuffer** Owner() const { return fOwner; }
|
|
void SetOwner(CachedBuffer** owner)
|
|
{ fOwner = owner; }
|
|
|
|
void SetCached(bool cached) { fCached = cached; }
|
|
bool IsCached() const { return fCached; }
|
|
|
|
private:
|
|
CachedBuffer** fOwner;
|
|
void* fBuffer;
|
|
size_t fSize;
|
|
bool fCached;
|
|
};
|
|
|
|
|
|
class BufferCache {
|
|
public:
|
|
virtual ~BufferCache();
|
|
|
|
virtual CachedBuffer* GetBuffer(size_t size,
|
|
CachedBuffer** owner = NULL,
|
|
bool* _newBuffer = NULL) = 0;
|
|
virtual void PutBufferAndCache(CachedBuffer** owner) = 0;
|
|
// caller is buffer owner and wants the
|
|
// buffer cached, if possible
|
|
virtual void PutBuffer(CachedBuffer** owner) = 0;
|
|
// puts the buffer for good, owner might
|
|
// have called PutBufferAndCache() before
|
|
// and might not own a buffer anymore
|
|
};
|
|
|
|
|
|
class CachedBufferPutter {
|
|
public:
|
|
CachedBufferPutter(BufferCache* cache, CachedBuffer** owner)
|
|
:
|
|
fCache(cache),
|
|
fOwner(owner),
|
|
fBuffer(NULL)
|
|
{
|
|
}
|
|
|
|
CachedBufferPutter(BufferCache* cache, CachedBuffer* buffer)
|
|
:
|
|
fCache(cache),
|
|
fOwner(NULL),
|
|
fBuffer(buffer)
|
|
{
|
|
}
|
|
|
|
~CachedBufferPutter()
|
|
{
|
|
if (fCache != NULL) {
|
|
if (fOwner != NULL)
|
|
fCache->PutBufferAndCache(fOwner);
|
|
else if (fBuffer != NULL)
|
|
fCache->PutBuffer(&fBuffer);
|
|
}
|
|
}
|
|
|
|
private:
|
|
BufferCache* fCache;
|
|
CachedBuffer** fOwner;
|
|
CachedBuffer* fBuffer;
|
|
};
|
|
|
|
|
|
} // namespace BPrivate
|
|
|
|
} // namespace BHaikuPackage
|
|
|
|
} // namespace BPackageKit
|
|
|
|
|
|
#endif // _PACKAGE__HPKG__BUFFER_CACHE_H_
|