home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 1997 October
/
Chip_1997-10_cd.bin
/
tema
/
sybase
/
powerj
/
hpp.z
/
WGLOBALM.HPP
< prev
next >
Wrap
C/C++ Source or Header
|
1996-10-18
|
4KB
|
134 lines
/*************************************************************************
*
* WGlobalMemory
*
* This class is a cover class for accessing and using global
* memory objects.
*
*************************************************************************/
#ifndef _WGLOBALM_HPP_INCLUDED
#define _WGLOBALM_HPP_INCLUDED
#ifndef _WNO_PRAGMA_PUSH
#pragma pack(push,8);
#pragma enum int;
#endif
#ifndef _WREFOBJ_HPP_INCLUDED
# include "wrefobj.hpp"
#endif
typedef WULong WGlobalMemoryFlags;
#define WGMFFixed 0x0000
#define WGMFMoveable 0x0002
#define WGMFZeroInit 0x0040
#define WGMFHandle (WGMFMoveable|WGMFZeroInit)
#define WGMFPointer (WGMFFixed|WGMFZeroInit)
#define GHND (GMEM_MOVEABLE | GMEM_ZEROINIT)
#define GPTR (GMEM_FIXED | GMEM_ZEROINIT)
//
// WGlobalMemory
//
class WCMCLASS WGlobalMemory : public WReferenceObject {
WDeclareSubclass( WGlobalMemory, WReferenceObject );
/**********************************************************
* Constructors and Destructors
*********************************************************/
// This class is meant to be used as a reference class, with
// objects allocated via new. As such we don't allow
// copies to be made except via the MakeCopy method. New
// objects are allocated via the static function Allocate.
private:
WGlobalMemory( const WGlobalMemory & gm );
WGlobalMemory& operator=( const WGlobalMemory & gm );
protected:
WGlobalMemory( const WMemoryHandle handle, WBool delHandle=FALSE );
WGlobalMemory( WULong size, WULong flags=WGMFHandle );
public:
~WGlobalMemory();
/**********************************************************
* Properties
*********************************************************/
// Data
//
// Returns a pointer to the data in a global memory
// object. NULL is returned if the memory is moveable
// and Lock has not been called to lock down the memory.
void *GetData() const;
// Handle
//
// Returns the global memory handle.
WMemoryHandle GetHandle() const;
// Size
//
// Returns the size (in bytes) of the memory.
WULong GetSize() const;
/**********************************************************
* Methods
*********************************************************/
// Allocate
//
// Allocates a new object.
static WGlobalMemory *Allocate( WULong sizeInBytes,
WULong flags=WGMFHandle );
static WGlobalMemory *Allocate( WMemoryHandle handle,
WBool delHandle=FALSE );
// Lock
//
// Lock moveable memory. Returns the lock count.
WLong Lock();
// MakeCopy
//
// Creates a new memory object based on the current
// one, copying the data.
WGlobalMemory *MakeCopy();
// Unlock
//
// Unlock moveable memory. Return the lock count.
WLong Unlock();
/**********************************************************
* Private
*********************************************************/
private:
WMemoryHandle _handle;
WLong _lockCount;
WBool _deleteHandle;
void * _data;
};
#ifndef _WNO_PRAGMA_PUSH
#pragma enum pop;
#pragma pack(pop);
#endif
#endif // _WGLOBALM_HPP_INCLUDED