OLReferenceCountedStream Class Reference
[Streams]

A base class for maintaining reference counts of streams. More...

#import <ObjectiveLib/ReferenceCountedStream.h>

Inheritance diagram for OLReferenceCountedStream:

Inheritance graph
[legend]
List of all members.

Public Member Functions

(id) - copy
 Make a copy of this stream.
(void) - freeStreamResources
 Free the stream's resources.
Initializers and Deallocators
(id) - free
 Decrement the reference count.
(id) - init
 Initialize the stream with a reference count of one.

Protected Attributes

unsigned referenceCount
 The reference count of this stream.

Detailed Description

A base class for maintaining reference counts of streams.

Due to the fact that it is not always possible or safe to copy stream instances, it is necessary, in order to maintain the desired usage model, to count references to streams and only release them when no one is watching anymore. This base class just maintains a simple reference count, incrementing it on init (OLReferenceCountedStream) and copy (OLReferenceCountedStream) and decrementing it on free (OLReferenceCountedStream), releasing the stream's resources when the reference count drops to zero.


Member Function Documentation

- (id) copy  

Make a copy of this stream.

The reference count is incremented and a refernce to this stream is returned.

Returns:
a reference to this stream

- (id) free  

Decrement the reference count.

If the reference count falls to zero, then the stream's freeStreamResources method will be called and the stream will be forever free.

Returns:
a reference to this stream

- (void) freeStreamResources  

Free the stream's resources.

This secondary freeing method is necessary to allow the reference count to be properly manipulated from within the normal free method.

Note:
All sublcasses that allocate resources must implement this method to free those resources and call [super freeStreamResources].

Reimplemented in OLBufferingInStream, OLBufferingOutStream, OLBzlibInStream, OLBzlibOutStream, OLDataInStream, OLDataOutStream, OLFileInStream, OLFileOutStream, OLGzipInStream, OLGzipOutStream, OLLayeredInStream, OLLayeredOutStream, OLObjectInStream, OLObjectOutStream, OLZlibInStream, and OLZlibOutStream.

- (id) init  

Initialize the stream with a reference count of one.

Returns:
a reference to this stream

Reimplemented in OLDataOutStream.


Member Data Documentation

- (unsigned) referenceCount [protected]

The reference count of this stream.


The documentation for this class was generated from the following file:
ObjectiveLibGenerated Sun Apr 22 15:19:01 2007, © 2004-2007 Will Mason
SourceForge.net Logo