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

Conduit Class Reference

Inheritance diagram for Conduit:

Resource IConduit DeviceConduit ConsoleConduit FileConduit List of all members.

Public Member Functions

 this (ConduitStyle style, bool seekable)
IBuffer createBuffer ()
int read (void[] dst)
int write (void[] src)
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)
ConduitStyle getStyle ()

Protected Member Functions

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 read, write, 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 typically reads and writes from/to an IBuffer in large chunks, typically the entire buffer. Alternatively, one can invoke read(dst[]) and/or write(src[]) directly.

Definition at line 69 of file Conduit.d.


Member Enumeration Documentation

anonymous enum [inherited]
 

Declare the End Of File identifer

Enumeration values:
Eof 

Definition at line 68 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.

Reimplemented in DeviceConduit.

Definition at line 83 of file Conduit.d.

References input, output, seekable, and style.

IBuffer createBuffer  ) 
 

Create a Buffer of a conduit-specific size

Reimplemented from IConduit.

Reimplemented in DeviceConduit.

Referenced by copy().

int read void[]  dst  ) 
 

conduit-specific reader

Reimplemented from IConduit.

Referenced by DeviceConduit::VersionPosix::read().

int write void[]  src  ) 
 

conduit-specific writer

Reimplemented from IConduit.

Referenced by copy(), and DeviceConduit::VersionPosix::write().

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 DeviceConduit.

Definition at line 124 of file Conduit.d.

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

void attach IConduitSource  input  )  [inline]
 

Please refer to IConduit.attach for details

Reimplemented from IConduit.

Definition at line 136 of file Conduit.d.

References IConduitSource::bind().

void attach IConduitSink  output  )  [inline]
 

Please refer to IConduit.attach for details

Reimplemented from IConduit.

Definition at line 148 of file Conduit.d.

References IConduitSink::bind().

void bind IConduitSink  next  )  [inline, protected]
 

Reimplemented from IConduitSink.

Definition at line 158 of file Conduit.d.

void bind IConduitSource  next  )  [inline, protected]
 

Reimplemented from IConduitSource.

Definition at line 166 of file Conduit.d.

void unbind  )  [inline, protected]
 

Reimplemented from IConduitSource.

Definition at line 174 of file Conduit.d.

int read IBuffer  target  )  [inline]
 

read from conduit into a target buffer

Reimplemented from IConduit.

Definition at line 184 of file Conduit.d.

References assert().

int write IBuffer  source  )  [inline]
 

write to conduit from a source buffer

Reimplemented from IConduit.

Definition at line 197 of file Conduit.d.

References assert().

bool isSeekable  )  [inline]
 

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

Reimplemented from IConduit.

Definition at line 216 of file Conduit.d.

References seekable.

bool isReadable  )  [inline]
 

Returns true is this conduit can be read from

Reimplemented from IConduit.

Definition at line 227 of file Conduit.d.

References ConduitStyle::access(), ConduitStyle::Read, and style.

bool isWritable  )  [inline]
 

Returns true if this conduit can be written to

Reimplemented from IConduit.

Definition at line 238 of file Conduit.d.

References ConduitStyle::access(), style, and ConduitStyle::Write.

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 250 of file Conduit.d.

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

ConduitStyle getStyle  )  [inline]
 

Return the style used when creating this conduit

Definition at line 269 of file Conduit.d.

References style.

this  )  [inline, inherited]
 

Set the default lock to be this object

Reimplemented in DatagramSocket, and SocketConduit.

Definition at line 77 of file Resource.d.

References Resource::_lock.

Object getLock  )  [inline, inherited]
 

Return the lock used by this resource

Reimplemented from IResource.

Definition at line 104 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 118 of file Resource.d.

References assert().

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 133 of file Resource.d.

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

Referenced by Socket::set(), Socket::this(), FileConduit::this(), and DeviceConduit::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 152 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 171 of file Resource.d.

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

Referenced by Resource::~this().


Member Data Documentation

ConduitStyle style [private]
 

Definition at line 71 of file Conduit.d.

Referenced by getStyle(), isReadable(), isWritable(), and this().

IConduitSource input [private]
 

Definition at line 72 of file Conduit.d.

Referenced by closure(), and this().

IConduitSink output [private]
 

Definition at line 73 of file Conduit.d.

Referenced by closure(), and this().

bool seekable [private]
 

Definition at line 74 of file Conduit.d.

Referenced by isSeekable(), and this().

Object _lock [protected, inherited]
 

Definition at line 54 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 Fri May 27 18:12:00 2005 for Mango by  doxygen 1.4.0