Taxonomy Categories:
Member Functions:
Interface Category:
API.
Inherits From:
TChunkyMemory
Inherited By:
None.
Purpose:
THeapChunkyMemory is a concrete derived class of TChunkyMemory. It implements a chunky memory that takes its storage from the heap object passed to it at construction time.
Instantiation:
Allocate on the heap or the stack.
Deriving Classes:
Derived classes of this class override its virtual member functions to implement the defined protocol.
Concurrency:
Not multithread safe.
Resource Use:
No special requirements.
- THeapChunkyMemory (size_t theChunkSize =kDefaultChunkSize)
- THeapChunkyMemory (TMemoryHeap * aHeap, size_t theChunkSize =kDefaultChunkSize)
- THeapChunkyMemory (const THeapChunkyMemory & aHeapChunkyMemory)
Interface Category:
API.
Purpose:
- Default constructor.
- Creates a THeapChunkyMemory that obtains its memory from a specific heap.
- Copy constructor.
Calling Context:
- Called to create an object that will be streamed into or to create a THeapChunkyMemory that obtains its memory from the default heap.
- Called to create a THeapChunkyMemory that does not use the default heap.
- Called to copy an object.
Parameters:
- size_t theChunkSize =kDefaultChunkSize -The size of chunk to allocate when AllocateMemoryChunk is called.
- TMemoryHeap * aHeap -The heap object from which to obtain memory chunks.
- size_t theChunkSize =kDefaultChunkSize -The size of chunk to allocate when AllocateMemoryChunk is called.
- const THeapChunkyMemory & aHeapChunkyMemory -Specifies the object to copy.
Return Value:
None.
Exceptions:
The copy constructor throws TGeneralKernelException(kInsufficientMemory) if there is not enough memory to copy the source object. Otherwise, throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
The copy constructor performs a deep copy of the source object.
THeapChunkyMemory & operator =(const THeapChunkyMemory & theHeapChunkyMemory)
Interface Category:
API.
Purpose:
Assignment operator.
Calling Context:
Called when an object is assigned to another compatible object.
Parameters:
- const THeapChunkyMemory & theHeapChunkyMemory -The object that supplies the value for the right-hand side of the assignment statement.
Return Value:
A non-const reference to the left-hand side object.
Exceptions:
Throws TGeneralKernelException(kInsufficientMemory) if there is not enough memory to copy the source object.
Concurrency:
Not multithread safe.
Other Considerations:
This member function performs a deep copy of the source object.
virtual ~ THeapChunkyMemory ()
Interface Category:
API.
Purpose:
Destructor.
Calling Context:
Called to destroy an object.
Parameters:
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
Calling the destructor releases all memory allocated for the chunky memory.
virtual TStream & operator <<= (TStream & fromWhere)
Interface Category:
API.
Purpose:
Stream-in operator.
Calling Context:
Called to stream in data.
Parameters:
- TStream & fromWhere -The stream the object streams itself in from.
Return Value:
Returns a reference to the stream the object streams itself in from.
Exceptions:
Throws TInvalidVersionError if the object read in from the stream has an invalid version number.
Concurrency:
Not multithread safe.
Other Considerations:
None.
virtual TStream & operator >>=(TStream & toWhere) const
Interface Category:
API.
Purpose:
Stream-out operator.
Calling Context:
Called to stream out data.
Parameters:
- TStream & toWhere -The stream the object streams itself out to.
Return Value:
Returns a reference to the stream the object streams itself out to.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
virtual void SetChunkSize (size_t chunkSize)
Interface Category:
API.
Purpose:
Sets the size of chunk to allocate when more memory is requested.
Calling Context:
Called to change the size of chunk allocated by the THeapChunkyMemory.
Parameters:
- size_t chunkSize -The new size of chunk to allocate when AllocateMemoryChunk is called.
Return Value:
None.
Exceptions:
Throws TGeneralKernelException(kBadArgument) if an invalid chunk size is passed.
Concurrency:
Not multithread safe.
Other Considerations:
None.
virtual size_t GetChunkSize () const
Interface Category:
API.
Purpose:
Returns the size of chunk to allocate when more memory is requested.
Calling Context:
Called to determine information about how the THeapChunkyMemory object allocates new chunks.
Parameters:
Return Value:
A size_t that indicates the size of chunk that is allocated when AllocateMemoryChunk is called.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
Member Function: THeapChunkyMemory::GetDefaultChunkSize
virtual size_t GetDefaultChunkSize () const
Interface Category:
API.
Purpose:
Returns the size of chunk to allocate when more memory is requested if a chunk size has not been specified.
Calling Context:
Called to determine information about how the THeapChunkyMemory object allocates new chunks.
Parameters:
Return Value:
A size_t that indicates the size of chunk that is allocated when AllocateMemoryChunk is called if a different chunk size has not been set by calling the SetChunkSize member function.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
virtual size_t GetTotalSize () const
Interface Category:
API.
Purpose:
Returns the length of the chunky memory in bytes.
Calling Context:
Called to query the state of the THeapChunkyMemory object.
Parameters:
Return Value:
A size_t that is the length of the chunky memory in bytes.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
virtual void LocateChunk (size_t where, TMemorySurrogate & theContainingRange, size_t & offset)
Interface Category:
API.
Purpose:
Returns a TMemorySurrogate that describes the chunk that contains a specified offset.
Calling Context:
Called to query the state of the THeapChunkyMemory object or in preparation to access the memory that comprises the chunky memory.
Parameters:
- size_t where -The byte offset within the chunky memory to locate.
- TMemorySurrogate & theContainingRange -The output parameter filled in by LocateChunk with the memory range (chunk) that contains the byte offset where.
- size_t & offset -The output parameter filled in by LocateChunk with the offset into theContainingRange of where.
Return Value:
None.
Exceptions:
Throw a TGeneralKernelException(kBadArgument) if where is beyond the end of the chunky memory.
Concurrency:
Not multithread safe.
Other Considerations:
None.
virtual void CutBackTo (size_t numberOfBytes)
Interface Category:
API.
Purpose:
Truncates the length of the chunky memory to the size passed.
Calling Context:
Called to modify the state of the THeapChunkyMemory.
Parameters:
- size_t numberOfBytes -The number of bytes that should remain in the chunky memory.
Return Value:
None.
Exceptions:
Throws TGeneralKernelException(kBadArgument) if numberOfBytes is beyond the current end of the chunky memory.
Concurrency:
Not multithread safe.
Other Considerations:
None.
Member Function: THeapChunkyMemory::AllocateMemoryChunk
virtual void AllocateMemoryChunk (TMemorySurrogate & theAllocatedRange)
Interface Category:
API.
Purpose:
Allocates a new chunk of memory and appends it to the chunky memory.
Calling Context:
Called when the chunky memory needs to be extended.
Parameters:
- TMemorySurrogate & theAllocatedRange -The output parameter filled in with the newly allocated chunk.
Return Value:
None.
Exceptions:
Throws TGeneralKernelException(kInsufficientMemory) if there is not enough memory to allocate another chunk.
Concurrency:
Not multithread safe.
Other Considerations:
None.
Member Function: THeapChunkyMemory::GetChunkCollection
virtual void GetChunkCollection (TCollectionOf < TMemorySurrogate > & theCollection)
Interface Category:
API.
Purpose:
Appends, in order, TMemorySurrogates describing each chunk in the chunky memory to the collection passed in.
Calling Context:
Called to query the state of the THeapChunkyMemory object.
Parameters:
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.