2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Copyright 2011, Oliver Tappe <zooey@hirschkaefer.de>
4 * Distributed under the terms of the MIT License.
6 #ifndef _PACKAGE__HPKG__PRIVATE__POOL_BUFFER_H_
7 #define _PACKAGE__HPKG__PRIVATE__POOL_BUFFER_H_
12 #include <util/DoublyLinkedList.h>
14 #include <package/hpkg/BufferPool.h>
17 namespace BPackageKit
{
24 class PoolBuffer
: public DoublyLinkedListLinkImpl
<PoolBuffer
> {
26 PoolBuffer(size_t size
);
29 void* Buffer() const { return fBuffer
; }
30 size_t Size() const { return fSize
; }
33 // implementation private
34 PoolBuffer
** Owner() const { return fOwner
; }
35 void SetOwner(PoolBuffer
** owner
)
38 void SetCached(bool cached
) { fCached
= cached
; }
39 bool IsCached() const { return fCached
; }
49 class PoolBufferPutter
{
51 PoolBufferPutter(BBufferPool
* pool
, PoolBuffer
** owner
)
59 PoolBufferPutter(BBufferPool
* pool
, PoolBuffer
* buffer
)
71 fPool
->PutBufferAndCache(fOwner
);
72 else if (fBuffer
!= NULL
)
73 fPool
->PutBuffer(&fBuffer
);
84 } // namespace BPrivate
88 } // namespace BPackageKit
91 #endif // _PACKAGE__HPKG__PRIVATE__POOL_BUFFER_H_