home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2001 Mobile
/
Chip_Mobile_2001.iso
/
palm
/
business
/
printcar
/
printcar.exe
/
src
/
Util
/
MemBuffer.h
< prev
next >
Wrap
C/C++ Source or Header
|
2000-06-03
|
1KB
|
65 lines
//
// $Id: MemBuffer.h,v 1.1.1.1 2000/06/02 22:23:04 sergey Exp $
//
#ifndef _MemBuffer_h_
#define _MemBuffer_h_
#include "Serializable.h"
namespace Util
{
class MemBuffer: public Serializable
{
public:
MemBuffer();
MemBuffer(VoidHand handle);
~MemBuffer();
// shallow copy, transfers ovnership to destination
MemBuffer(const MemBuffer& other);
MemBuffer& operator =(const MemBuffer& other);
// operations
void* lock();
const void* lock() const;
// Ensures that buffer size will be not less then lockSize argument.
void* lock(int lockSize);
const void* lock(int lockSize) const;
void unlock() const;
bool allocate(int size);
bool resize(int size);
void free();
VoidHand release();
// attributes
int size() const;
bool isLocked() const { return _lockCount > 0; }
bool isNull() const { return _handle == 0; }
// serialization
virtual void serialize(DataOutputStream& stream) const;
virtual void restore(const DataInputStream& stream);
// implemntation
private:
bool ensureBufferSize(int size);
void unlockAll() const;
// data members
private:
VoidHand _handle;
mutable int _lockCount;
};
}
// namespace Util
#endif // _MemBuffer_h_