Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

Conduit Class Reference

Inheritance diagram for Conduit:

Resource IConduit FileConduit List of all members.

Public Member Functions

 this (ConduitStyle style, bool seekable)
IBuffer createBuffer ()
void attach (IConduitSource input)
void attach (IConduitSink output)
int read (IBuffer target)
int write (IBuffer source)
bool isSeekable ()
bool isReadable ()
bool isWritable ()
IConduit copy (IConduit source)
IConduit flush (IBuffer source)
ConduitStyle getStyle ()

Protected Member Functions

abstract int reader (void[] dst)
abstract int writer (void[] src)
override void closure ()
void bind (IConduitSink next)
void bind (IConduitSource next)
void unbind ()

Private Types

enum  { Eof = -1 }

Private Member Functions

 this ()
Object getLock ()
void setLock (Object lock)
void acquire ()
bool acquireIfOpen ()
void close ()

Private Attributes

ConduitStyle style
IConduitSource input
IConduitSink output
bool seekable
Object _lock

Detailed Description

Conduit abstract base-class, implementing interface IConduit. Only the conduit-specific reader, writer, and buffer-factory need to be implemented for a concrete conduit implementation. See FileConduit for an example.

Conduits provide virtualized access to external content, and represent things like files or Internet connections. Conduits are modelled by mango.io.model.IConduit, and implemented via classes FileConduit and SocketConduit.

Additional kinds of conduit are easy to construct: one either subclasses mango.io.Conduit, or implements mango.io.model.IConduit. A conduit reads and writes from/to an IBuffer in large chunks, typically the entire buffer.

Definition at line 65 of file Conduit.d.


Member Enumeration Documentation

anonymous enum [inherited]
 

Declare the End Of File identifer

Enumeration values:
Eof 

Definition at line 64 of file IConduit.d.


Member Function Documentation

this ConduitStyle  style,
bool  seekable
[inline]
 

Construct a conduit with the given style and seek abilities. Conduits are either seekable or non-seekable.

Definition at line 79 of file Conduit.d.

References seekable.

IBuffer createBuffer  ) 
 

Create a Buffer of a conduit-specific size

Reimplemented from IConduit.

Reimplemented in FileConduit.

abstract int reader void[]  dst  )  [protected, pure virtual]
 

conduit-specific reader

Reimplemented from IConduitSource.

abstract int writer void[]  src  )  [protected, pure virtual]
 

conduit-specific writer

Reimplemented from IConduitSink.

override void closure  )  [inline, protected]
 

Method to close the filters. This is invoked from the Resource base-class when the resource is being closed. You should ensure that a subclass invokes this as part of its closure mechanics.

Reimplemented from Resource.

Reimplemented in FileConduit.

Definition at line 120 of file Conduit.d.

References IConduitSink::unbind(), and IConduitSource::unbind().

void attach IConduitSource  input  )  [inline]
 

Please refer to IConduit.attach for details

Reimplemented from IConduit.

Definition at line 132 of file Conduit.d.

References IConduitSource::bind().

Referenced by testConduitFilters().

void attach IConduitSink  output  )  [inline]
 

Please refer to IConduit.attach for details

Reimplemented from IConduit.

Definition at line 144 of file Conduit.d.

References IConduitSink::bind().

void bind IConduitSink  next  )  [inline, protected]
 

Reimplemented from IConduitSink.

Definition at line 154 of file Conduit.d.

void bind IConduitSource  next  )  [inline, protected]
 

Reimplemented from IConduitSource.

Definition at line 162 of file Conduit.d.

void unbind  )  [inline, protected]
 

Reimplemented from IConduitSource.

Definition at line 170 of file Conduit.d.

int read IBuffer  target  )  [inline]
 

read from conduit into a target buffer

Reimplemented from IConduit.

Definition at line 180 of file Conduit.d.

Referenced by FileBucket::Record::read(), testDirectIO(), and testFile5().

int write IBuffer  source  )  [inline]
 

write to conduit from a source buffer

Reimplemented from IConduit.

Definition at line 193 of file Conduit.d.

Referenced by copy(), flush(), and testDirectIO().

bool isSeekable  )  [inline]
 

Returns true if this conduit is seekable (whether it implements ISeekable)

Reimplemented from IConduit.

Definition at line 212 of file Conduit.d.

References seekable.

bool isReadable  )  [inline]
 

Returns true is this conduit can be read from

Reimplemented from IConduit.

Definition at line 223 of file Conduit.d.

References ConduitStyle::access().

bool isWritable  )  [inline]
 

Returns true if this conduit can be written to

Reimplemented from IConduit.

Definition at line 234 of file Conduit.d.

References ConduitStyle::access().

IConduit copy IConduit  source  )  [inline]
 

Transfer the content of another conduit to this one. Returns a reference to this class, and throws IOException on failure.

Reimplemented from IConduit.

Definition at line 246 of file Conduit.d.

References flush(), IConduit::read(), and write().

IConduit flush IBuffer  source  )  [inline]
 

Flush buffer content out to this conduit.

Throws an IOException if flushing results in an Eof condition.

Reimplemented from IConduit.

Definition at line 266 of file Conduit.d.

References IBuffer::readable(), and write().

Referenced by copy(), and FileBucket::Record::write().

ConduitStyle getStyle  )  [inline]
 

Return the style used when creating this conduit

Definition at line 280 of file Conduit.d.

this  )  [inline, inherited]
 

Set the default lock to be this object

Reimplemented in DatagramSocket, and SocketConduit.

Definition at line 74 of file Resource.d.

References Resource::_lock.

Object getLock  )  [inline, inherited]
 

Return the lock used by this resource

Reimplemented from IResource.

Definition at line 101 of file Resource.d.

References Resource::_lock.

void setLock Object  lock  )  [inline, inherited]
 

Set an alternate lock. Typically one would use this to synchronize multiple different Resource via a common object.

Reimplemented from IResource.

Definition at line 115 of file Resource.d.

void acquire  )  [inline, inherited]
 

hold a reference to this resource. The caller is now responsible for invoking close() upon this resource;

Reimplemented from IResource.

Definition at line 130 of file Resource.d.

References Resource::_lock, and Resource::usage.

Referenced by Socket::set(), Socket::this(), and FileConduit::this().

bool acquireIfOpen  )  [inline, inherited]
 

If this resource is still open, acquire it and return true. This is a threadsafe test-and-set mechanism that fails only if the resource is already closed, or was never opened.

Note that you are responsible for invoking close() whenever this method returns true.

Reimplemented from IResource.

Definition at line 149 of file Resource.d.

References Resource::_lock, and Resource::usage.

void close  )  [inline, inherited]
 

release a reference to this resource

Reimplemented from IResource.

Definition at line 168 of file Resource.d.

References Resource::_lock, Resource::closure(), and Resource::usage.

Referenced by Resource::~this(), and FileConduit::VersionWin32::Win32MappedBuffer::~this().


Member Data Documentation

ConduitStyle style [private]
 

Definition at line 67 of file Conduit.d.

IConduitSource input [private]
 

Definition at line 68 of file Conduit.d.

IConduitSink output [private]
 

Definition at line 69 of file Conduit.d.

bool seekable [private]
 

Definition at line 70 of file Conduit.d.

Referenced by isSeekable(), and this().

Object _lock [protected, inherited]
 

Definition at line 51 of file Resource.d.

Referenced by Resource::acquire(), Resource::acquireIfOpen(), Resource::close(), Resource::getLock(), and Resource::this().


The documentation for this class was generated from the following file:
Generated on Sun Nov 7 19:07:01 2004 for Mango by doxygen 1.3.6