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

Connector Class Reference

#include <Connector.h>

Inheritance diagram for Connector:

Inheritance graph
[legend]
Collaboration diagram for Connector:

Collaboration graph
[legend]
List of all members.

Detailed Description

Connects a source to one or more sinks.

Author:
Author
darkeye
Version:
Revision
1.6

Definition at line 60 of file Connector.h.

Public Member Functions

 Connector (Source *source) throw ( Exception )
 Constructor based on a Source.
 Connector (Source *source, Sink *sink) throw ( Exception )
 Constructor based on a Source and a Sink.
 Connector (const Connector &connector) throw ( Exception )
 Copy constructor.
virtual ~Connector (void) throw ( Exception )
 Destructor.
virtual Connectoroperator= (const Connector &connector) throw ( Exception )
 Assignment operator.
virtual unsigned int getNumSinks (void) const throw ()
 Get the number of Sinks in the Connector.
virtual void attach (Sink *sink) throw ( Exception )
 Attach a Sink to the Source of this Connector.
virtual bool open (void) throw ( Exception )
 Open the connector.
virtual unsigned int transfer (unsigned long bytes, unsigned int bufSize, unsigned int sec, unsigned int usec) throw ( Exception )
 Transfer a given amount of data from the Source to all the Sinks attached.
virtual void close (void) throw ( Exception )
 Close the Connector.

Protected Member Functions

 Connector (void) throw ( Exception )
 Default constructor.
virtual bool detach (Sink *sink) throw ( Exception )
 Detach an already attached Sink from the Source of this Connector.

Protected Attributes

Ref< Sourcesource
 The source to read from.
Ref< Sink > * sinks
 The sinks to connect the source to.
unsigned int numSinks
 Total number of sinks.


Constructor & Destructor Documentation

Connector::Connector void   )  throw ( Exception ) [inline, protected]
 

Default constructor.

Always throws an Exception.

Exceptions:
Exception 

Definition at line 105 of file Connector.h.

Connector::Connector Source source  )  throw ( Exception ) [inline]
 

Constructor based on a Source.

Parameters:
source the source to connect to the sinks.
Exceptions:
Exception 

Definition at line 130 of file Connector.h.

References source.

Connector::Connector Source source,
Sink sink
throw ( Exception ) [inline]
 

Constructor based on a Source and a Sink.

Parameters:
source the source to connect to the sinks.
sink a sink to connect to the source.
Exceptions:
Exception 

Definition at line 143 of file Connector.h.

References attach(), and source.

Connector::Connector const Connector connector  )  throw ( Exception )
 

Copy constructor.

Parameters:
connector the object to copy.
Exceptions:
Exception 

Definition at line 87 of file Connector.cpp.

References attach().

virtual Connector::~Connector void   )  throw ( Exception ) [inline, virtual]
 

Destructor.

Exceptions:
Exception 

Definition at line 164 of file Connector.h.


Member Function Documentation

void Connector::attach Sink sink  )  throw ( Exception ) [virtual]
 

Attach a Sink to the Source of this Connector.

Parameters:
sink the Sink to attach.
Exceptions:
Exception 

Definition at line 127 of file Connector.cpp.

References Ref< T >::get(), numSinks, and sinks.

Referenced by Connector(), and operator=().

void Connector::close void   )  throw ( Exception ) [virtual]
 

Close the Connector.

The Source and all Sinks are closed.

Exceptions:
Exception 

Reimplemented in MultiThreadedConnector.

Definition at line 332 of file Connector.cpp.

References numSinks, sinks, and source.

Referenced by MultiThreadedConnector::close().

bool Connector::detach Sink sink  )  throw ( Exception ) [protected, virtual]
 

Detach an already attached Sink from the Source of this Connector.

Parameters:
sink the Sink to detach.
Returns:
true if the detachment was successful, false otherwise.
Exceptions:
Exception 

Definition at line 156 of file Connector.cpp.

References numSinks, and sinks.

virtual unsigned int Connector::getNumSinks void   )  const throw () [inline, virtual]
 

Get the number of Sinks in the Connector.

Returns:
the number of Sinks in the Connector.
Exceptions:
Exception 

Definition at line 186 of file Connector.h.

References numSinks.

bool Connector::open void   )  throw ( Exception ) [virtual]
 

Open the connector.

Opens the Source and the Sinks if necessary.

Returns:
true if opening was successful, false otherwise.
Exceptions:
Exception 

Reimplemented in MultiThreadedConnector.

Definition at line 217 of file Connector.cpp.

References numSinks, sinks, and source.

Connector & Connector::operator= const Connector connector  )  throw ( Exception ) [virtual]
 

Assignment operator.

Parameters:
connector the object to assign to this one.
Returns:
a reference to this object.
Exceptions:
Exception 

Definition at line 103 of file Connector.cpp.

References attach().

Referenced by MultiThreadedConnector::operator=().

unsigned int Connector::transfer unsigned long  bytes,
unsigned int  bufSize,
unsigned int  sec,
unsigned int  usec
throw ( Exception ) [virtual]
 

Transfer a given amount of data from the Source to all the Sinks attached.

If an attached Sink closes or encounteres an error during the process, it is detached and the function carries on with the rest of the Sinks. If no Sinks remain, or an error is encountered with the Source, the function returns prematurely.

Parameters:
bytes the amount of data to transfer, in bytes. If 0, transfer forever.
bufSize the size of the buffer to use for transfering. This amount of data is read from the Source and written to each Sink on each turn.
sec the number of seconds to wait for the Source to have data available in each turn, and the number of seconds to wait for the Sinks to accept data.
usec the number of micro seconds to wait for the Source to have data available in each turn, and the number of micro seconds to wait for the Sinks to accept data.
Returns:
the number of bytes read from the Source.
Exceptions:
Exception 

Reimplemented in MultiThreadedConnector.

Definition at line 256 of file Connector.cpp.


Member Data Documentation

unsigned int Connector::numSinks [protected]
 

Total number of sinks.

Definition at line 97 of file Connector.h.

Referenced by attach(), close(), detach(), getNumSinks(), and open().

Ref<Sink>* Connector::sinks [protected]
 

The sinks to connect the source to.

Definition at line 92 of file Connector.h.

Referenced by attach(), close(), detach(), and open().

Ref<Source> Connector::source [protected]
 

The source to read from.

Definition at line 87 of file Connector.h.

Referenced by close(), Connector(), and open().


The documentation for this class was generated from the following files:
Generated on Thu Apr 14 13:59:13 2005 for DarkIce by  doxygen 1.4.1