![](../../Home/Icons/Home.gif)
![](../icons/UpCNM.gif)
![](../icons/CNMContext.gif)
![](../../Home/Icons/Search.gif)
Taxonomy Categories:
Member Functions:
Interface Category:
API.
Inherits From:
MCollectible
Inherited By:
THeapChunkyMemory
Purpose:
TChunkyMemory is an abstract base class that specifies a protocol for managing memory as a sequence of discontiguous chunks. The protocol allows the user of a TChunkyMemory to view the memory as a sequence of bytes.
Instantiation:
Allocate on the heap or the stack.
Deriving Classes:
Derived classes of this abstract class override its pure virtual member functions to implement the defined protocol. This is done by the classes THeapChunkyMemory and TVMChunkyMemory. The primary reason one might define a new derived class is to implement a different chunk allocation scheme.
Concurrency:
Not multithread safe.
Resource Use:
No special requirements.
virtual ~ TChunkyMemory ()
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:
Derived classes of TChunkyMemory should release all of the memory allocated they have allocated in their destructors.
Member Function: TChunkyMemory::operator<<=
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:
Derived classes should throw a TInvalidVersionError if the object read in from the stream has an invalid version number.
Concurrency:
Not multithread safe.
Other Considerations:
This is a pure virtual function. Derived classes of TChunkyMemory should not call this operator.
Member Function: TChunkyMemory::operator>>=
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:
Derived classes of TChunkyMemory should implement this operator to stream out the entire contents of the chunky memory.
This is a pure virtual function. Derived classes of TChunkyMemory should not call this operator.
Member Function: TChunkyMemory::SetChunkSize
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 TChunkyMemory.
Parameters:
- size_t chunkSize -The new size of chunk to allocate when AllocateMemoryChunk is called.
Return Value:
None.
Exceptions:
Derived classes should throw a TGeneralKernelException(kBadArgument) if an invalid chunk size is passed.
Concurrency:
Not multithread safe.
Other Considerations:
This is a pure virtual function. Derived classes of TChunkyMemory should not call this operator.
Member Function: TChunkyMemory::GetChunkSize
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 TChunkyMemory 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:
This is a pure virtual function. Derived classes of TChunkyMemory should not call this operator.
Member Function: TChunkyMemory::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 TChunkyMemory 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:
This is a pure virtual function. Derived classes of TChunkyMemory should not call this operator.
Member Function: TChunkyMemory::GetTotalSize
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 TChunkyMemory 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:
This is a pure virtual function. Derived classes of TChunkyMemory should not call this operator.
Member Function: TChunkyMemory::LocateChunk
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 TChunkyMemory 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:
Derived classes should throw a TGeneralKernelException(kBadArgument) if where is beyond the end of the chunky memory.
Concurrency:
Not multithread safe.
Other Considerations:
This is a pure virtual function. Derived classes of TChunkyMemory should not call this operator.
Member Function: TChunkyMemory::CutBackTo
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 TChunkyMemory.
Parameters:
- size_t numberOfBytes -The number of bytes that should remain in the chunky memory.
Return Value:
None.
Exceptions:
Derived classes should throw a TGeneralKernelException(kBadArgument) if numberOfBytes is beyond the current end of the chunky memory.
Concurrency:
Not multithread safe.
Other Considerations:
This is a pure virtual function. Derived classes of TChunkyMemory should not call this operator.
Member Function: TChunkyMemory::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:
Derived classes should throw a TGeneralKernelException(kInsufficientMemory) if there is not enough memory to allocate another chunk.
Concurrency:
Not multithread safe.
Other Considerations:
This is a pure virtual function. Derived classes of TChunkyMemory should not call this operator.
- TChunkyMemory ()
- TChunkyMemory (const TChunkyMemory & aChunkyMemory)
Interface Category:
API.
Purpose:
- Default constructor.
- Copy constructor.
Calling Context:
- Called by the stream-in operators.
- Called to copy an object.
Parameters:
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
Member Function: TChunkyMemory::operator=
TChunkyMemory & operator =(const TChunkyMemory & theChunkyMemory)
Interface Category:
API.
Purpose:
Assignment operator.
Calling Context:
Called when an object is assigned to another compatible object.
Parameters:
- const TChunkyMemory & theChunkyMemory -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 no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
Member Function: TChunkyMemory::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 TChunkyMemory object.
Parameters:
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
This is a pure virtual function. Derived classes of TChunkyMemory should not call this operator.
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.