Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

CP_MacOSHandle Class Reference

A class to provide a wrapper around a MacOS Handle. This class can also be used if QuickTime for Windows is defined.

Inheritance diagram for CP_MacOSHandle:

CP_M_RefCounted List of all members.

Public Member Functions

Constructor / Destructor
 CP_MacOSHandle ()
 Constructor.
 CP_MacOSHandle (UInt32 inSize)
 CP_MacOSHandle (CP_MacOSHandle &inHandleBlock)
 CP_MacOSHandle (Handle inMacHandle, bool inOwnsHandle=true)
 ~CP_MacOSHandle () throw ()
 Destructor.
Copying
void CopyTo (void *inBuffer, UInt32 inNumBytes)
void CopyFrom (void *ioBuffer, UInt32 inNumBytes)
Getters
Handle GetHandle ()
char * GetPtr ()
Length
UInt32 Length () const
void SetLength (UInt32 inLength)
Locking
void Lock ()
void Unlock ()
bool IsLocked ()
Operators
CP_MacOSHandleoperator= (CP_MacOSHandle &inHandleBlock)
 operator Handle ()
Ownership
void Adopt (Handle inHandle)
Handle Release () const
Testers
bool IsValid ()
bool OwnsHandle ()
Utility
void Wrap (Handle inExistingHandle, bool inOwnsHandle=true)
void Detach ()
CP_MacOSHandleClone ()

Protected Attributes

Handle fBlock
bool fOwnsHandle
bool fLocked
UInt32 fActualBlockLength

Private Member Functions

Allocation
void Allocate (UInt32 inSize)
void Deallocate ()

Constructor & Destructor Documentation

CPLAT_Begin_Namespace_CPLAT CP_MacOSHandle::CP_MacOSHandle  ) 
 

Constructor.

Exceptions:
none 

CP_MacOSHandle::CP_MacOSHandle UInt32  inSize  ) 
 

Constructor.

Parameters:
inSize The size of the desired memory allocation in bytes.
Exceptions:
none 

CP_MacOSHandle::CP_MacOSHandle CP_MacOSHandle inHandleBlock  ) 
 

Copy constructor.

Parameters:
inHandleBlock The object to copy the fields from. This will increase the reference count of the passed in handle block, since the copying operation will now point to the same memory block of OS memory.
Exceptions:
none 

CP_MacOSHandle::CP_MacOSHandle Handle  inMacHandle,
bool  inOwnsHandle = true
 

Constructor.

Parameters:
inMacHandle An existing MacOS Handle to assign to this object.
inOwnsHandle Flag to indicate if this class becomes responsible for the deletion of the OSHandle.
Exceptions:
none 

CP_MacOSHandle::~CP_MacOSHandle  )  throw ()
 

Destructor.

Exceptions:
none 


Member Function Documentation

void CP_MacOSHandle::CopyTo void *  inBuffer,
UInt32  inNumBytes
 

Copies the passed in number of bytes of this memory block to the passed in destination buffer. The copy will start at the beginning of the memory block.

Parameters:
inBuffer Points to the location the bytes will be copied to.
inNumBytes The number of bytes to copy.
Exceptions:
none 
Returns:
void

void CP_MacOSHandle::CopyFrom void *  ioBuffer,
UInt32  inNumBytes
 

Copies the passed in number of bytes from the passed in buffer to this block of memory, starting at the first byte of this memory block.

Parameters:
ioBuffer Points to the location of the bytes to copy from.
inNumBytes The number of bytes to copy.
Exceptions:
none 
Returns:
void

Handle CP_MacOSHandle::GetHandle  ) 
 

Returns the Handle for the memory block of this object. If this object still owns this memory, be careful not to delete the OSHandle, otherwise there will be a problem when this object tries to release the already released memory.

Exceptions:
none 
Returns:
Handle The Handle for the memory of this object.

Ptr CP_MacOSHandle::GetPtr  ) 
 

Returns a char * to the actual bytes of this memory. This will lock the handle for accessing, in case the underlying OS can move a handle. You are responsible for calling the Unlock() memory when done to unlock the memory.

Exceptions:
none 
Returns:
char * Points to the first byte in the memory block.

UInt32 CP_MacOSHandle::Length  )  const
 

Returns the length of this memory block.

Exceptions:
OSErr OSErr if there is a problem getting length.
Returns:
SInt32 const The length of the memory block

void CP_MacOSHandle::SetLength UInt32  inLength  ) 
 

Set the length of the memory block. This will cause the platforms memory block to be resized to accommodate these changes.

Parameters:
inLength The length to resize this memory block to.
Exceptions:
OSErr OSError if setting length failed.
Returns:
void

void CP_MacOSHandle::Lock  ) 
 

Locks the platforms OSHandle.

Exceptions:
none 
Returns:
void

void CP_MacOSHandle::Unlock  ) 
 

Unlocks the platforms OSHandle.

Exceptions:
none 
Returns:
void

bool CP_MacOSHandle::IsLocked  ) 
 

Returns true if the memory block is locked.

Exceptions:
none 
Returns:
bool Returns true if the memory block is locked.

CP_MacOSHandle & CP_MacOSHandle::operator= CP_MacOSHandle inHandleBlock  ) 
 

Assignment operator. This will cause any memory in this object to be deallocated first, if we own the handle. Then the OS memory block will point to that of the passed in handle block object. The passed in handle block objects reference count will also be increased, since the underlying OSHandle is now shareed by this class.

Exceptions:
none 
Returns:
void

CP_MacOSHandle::operator Handle  ) 
 

Returns the MacOS Handle.

Exceptions:
none 
Returns:
Handle

void CP_MacOSHandle::Adopt Handle  inHandle  ) 
 

Adopts the passed in handle for this object.

Exceptions:
none 
Returns:
void

Handle CP_MacOSHandle::Release  )  const
 

Releases the handle owned by this object, and returns the handle.

Exceptions:
none 
Returns:
Handle The handle for the data in this object.

bool CP_MacOSHandle::IsValid  ) 
 

Returns true if the memory block is not NULL.

Exceptions:
none 
Returns:
bool Returns true if the memory block is not NULL.

bool CP_MacOSHandle::OwnsHandle  ) 
 

Returns true if this object owns the block of memory, and is therefore responsible for its deletion. Otherwise the memory block held by this object will not be deleted by this class.

Exceptions:
none 
Returns:
bool Returns true if this object owns the memory handle.

void CP_MacOSHandle::Wrap Handle  inExistingHandle,
bool  inOwnsHandle = true
 

Wrap ourselves around an existing platforms Handle. If inOwnsHandle is true, then this object takes over ownership of the Handle and will be responsible for deleting the memory.

Parameters:
inExistingHandle The existing Handle to take ownership of.
inOwnsHandle Flag to indicate if this class takes on ownership of the handle, and will be responsible for its deletion.
Exceptions:
none 
Returns:
void

void CP_MacOSHandle::Detach  ) 
 

Notifies this class that it no longer owns the memory, and will not delete it. You are now responsible for deleting the memory to avoid a memory leak.

Exceptions:
none 
Returns:
void

CP_MacOSHandle * CP_MacOSHandle::Clone  ) 
 

Return a new CP_MacOSHandle object that is a duplicate of this one. Use this method if you want to duplicate the data inside another CP_MacOSHandle object without retaining a reference to it.

Exceptions:
none 
Returns:
CP_MacOSHandle * The new object that is a clone of this one.

void CP_MacOSHandle::Allocate UInt32  inSize  )  [private]
 

Private routine to handle the allocation of the platforms memory block.

Parameters:
inSize The desired size of the memory allocation.
Exceptions:
NULL NULL exception if the memory can't be allocated.
Returns:
void

void CP_MacOSHandle::Deallocate  )  [private]
 

Private routine to handle the deallocation of the platforms memory block. This will only happen if this object owns the allocated memory, otherwise you are responsible for the deallocation of the memory.

Exceptions:
none 
Returns:
void

UInt32 CP_M_RefCounted::AddReference  )  const [inherited]
 

Add a reference to our object, returning the new reference count.

Exceptions:
none 
Returns:
UInt32 const Returns the new reference count.

UInt32 CP_M_RefCounted::RemoveReference  )  const [inherited]
 

Remove a reference to our object, returning the new reference count. If the count is 0, then this object is also deleted, and 0 is returned.

Exceptions:
none 
Returns:
UInt32 const Returns the new reference count.

void CP_M_RefCounted::Autorelease  )  const [inherited]
 

Add the object to the topmost auto-release pool. This will ensure that the object is eventually released.

See also:
CP_AutoReleasePool
Exceptions:
none 
Returns:
void

UInt32 CP_M_RefCounted::GetRefCount  )  const [inherited]
 

Returns the current ref count.

Exceptions:
none 
Returns:
UInt32 The current referencce count.


Member Data Documentation

Handle CP_MacOSHandle::fBlock [protected]
 

bool CP_MacOSHandle::fOwnsHandle [mutable, protected]
 

Platforms memory object.

bool CP_MacOSHandle::fLocked [protected]
 

Flag to indicate who is responsible for deleting the platforms memory.

UInt32 CP_MacOSHandle::fActualBlockLength [protected]
 

Flag to indicate if the block is locked.


The documentation for this class was generated from the following files:
Generated on Tue Sep 20 20:21:52 2005 for CPLAT_MacOS by  doxygen 1.4.0